Skip to content
This repository has been archived by the owner on May 26, 2022. It is now read-only.

Commit

Permalink
post gorelease output on the PR, split up releaser workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
marten-seemann committed Aug 14, 2021
1 parent 0bf4877 commit c1c59c9
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 33 deletions.
45 changes: 45 additions & 0 deletions .github/workflows/release-check.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
name: Release Checker
on:
pull_request:
paths: [ 'version.json' ]
branches: [ master ]

jobs:
releaser:
runs-on: ubuntu-latest
env:
HIGHESTRELEASED: ""
VERSION: ""
GORELEASE: ""
steps:
- uses: actions/checkout@v2
- uses: actions/setup-go@v2
with:
go-version: "1.16.x"
- name: Install gorelease
run: go install golang.org/x/exp/cmd/[email protected]
- name: Determine version
run: echo "VERSION=$(jq -r .version version.json)" >> $GITHUB_ENV
- name: Determine highest released version
run: echo "HIGHESTRELEASED=$(go list -m -versions | tr " " "\n" | tail -n 1)" >> $GITHUB_ENV
- name: Run gorelease
id: gorelease
if: env.VERSION != env.HIGHESTRELEASED
run: |
output=$(gorelease || true)
# dealing with multi-line strings in GitHub Actions is a pain
echo "GORELEASE<<EOF" >> $GITHUB_ENV
echo "$output" >> $GITHUB_ENV
echo "EOF" >> $GITHUB_ENV
- uses: marocchino/sticky-pull-request-comment@v2
if: env.VERSION != env.HIGHESTRELEASED
with:
header: test
recreate: true
message: |
Most recent release is: ${{ env.HIGHESTRELEASED }}
`gorelease` says:
```
${{ env.GORELEASE }}
```
34 changes: 1 addition & 33 deletions .github/workflows/releaser.yml
Original file line number Diff line number Diff line change
@@ -1,51 +1,19 @@
name: Releaser
on:
push:
paths: [ 'version.json' ]
branches: [ master ]
pull_request:
paths: [ 'version.json' ]
branches: [ master ]

jobs:
releaser:
runs-on: ubuntu-latest
env:
VERSION: ""
HIGHESTRELEASED: ""
steps:
- uses: actions/checkout@v2
with:
repository: fsaintjacques/semver-tool
ref: 20028cb53f340a300b460b423e43f0eac13bcd9a # v3.2.0
path: semver-tool
- name: Install semver-tool
run: |
cd semver-tool
make install
cd ..
rm -rf semver-tool
- uses: actions/setup-go@v2
with:
go-version: "1.16.x"
- name: Install gorelease
run: go install golang.org/x/exp/cmd/[email protected]
- uses: actions/checkout@v2
- name: Determine version
run: echo "VERSION=$(jq -r .version version.json)" >> $GITHUB_ENV
- name: Determine highest released version
run: echo "HIGHESTRELEASED=$(go list -m -versions | tr " " "\n" | tail -n 1)" >> $GITHUB_ENV
- name: Check suggested version against gorelease
if: ${{ env.VERSION != env.HIGHESTRELEASED }}
run: |
suggested=$(gorelease | grep Suggested | sed "s/Suggested version: //")
echo "gorelease suggested: $suggested"
if [[ $(semver compare "${{ env.VERSION }}" "$suggested") == "-1" ]]; then
echo "Need a higher version number. Gorelease suggested $suggested"
echo "::error file=version.json,line=2,col=1::gorelease says we need at least $suggested"
exit 1
fi
- name: Create release
if: ${{ github.event_name == 'push' && env.VERSION != env.HIGHESTRELEASED }}
run: |
git tag ${{ env.VERSION }}
git push --tags

0 comments on commit c1c59c9

Please sign in to comment.