Skip to content

Commit

Permalink
GitHub Actions: trigger on release creation
Browse files Browse the repository at this point in the history
  • Loading branch information
drewda committed May 14, 2020
1 parent 3e787f8 commit 797fea4
Showing 1 changed file with 11 additions and 17 deletions.
28 changes: 11 additions & 17 deletions .github/workflows/test-and-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@ on:
push:
branches:
- '*'
tags:
- 'v*'
release:
types:
- created
jobs:
test:
runs-on: ${{ matrix.os }}
Expand All @@ -29,7 +30,7 @@ jobs:
name: coverage
path: coverage.html
build-linux:
if: startsWith(github.ref, 'refs/tags/v')
if: startsWith(github.ref, 'refs/releases/')
needs: test
runs-on: ubuntu-18.04
steps:
Expand All @@ -48,7 +49,7 @@ jobs:
name: gotransit-linux
path: ${{ github.workspace }}/cmd/gotransit/gotransit
build-macos:
if: startsWith(github.ref, 'refs/tags/v')
if: startsWith(github.ref, 'refs/releases/')
needs: test
runs-on: macos-latest
steps:
Expand All @@ -67,20 +68,13 @@ jobs:
name: gotransit-macos
path: ${{ github.workspace }}/cmd/gotransit/gotransit
release:
if: startsWith(github.ref, 'refs/tags/v')
if: startsWith(github.ref, 'refs/releases/')
needs: [build-linux, build-macos]
runs-on: ubuntu-18.04
steps:
- name: Create GitHub release
id: create_release
uses: actions/[email protected]
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ github.ref }}
release_name: Release ${{ github.ref }}
draft: false
prerelease: false
- name: "Get release upload_url"
run: echo "::set-output name=upload_url::https://uploads.github.com/repos/$GITHUB_REPOSITORY/releases/$(jq --raw-output '.release.id' $GITHUB_EVENT_PATH)/assets{?name,label}"
id: release
- name: Download Linux binary
uses: actions/download-artifact@v1
with:
Expand All @@ -90,7 +84,7 @@ jobs:
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
upload_url: ${{ steps.release.outputs.upload_url }}
asset_path: ${{ github.workspace }}/gotransit-linux/gotransit
asset_name: gotransit-linux
asset_label: Linux AMD-64 binary
Expand All @@ -104,7 +98,7 @@ jobs:
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
upload_url: ${{ steps.release.outputs.upload_url }}
asset_path: ${{ github.workspace }}/gotransit-macos/gotransit
asset_name: gotransit-macos
asset_label: macOS AMD-64 binary
Expand Down

0 comments on commit 797fea4

Please sign in to comment.