This repository has been archived by the owner on May 26, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 42
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
post gorelease output on the PR, split up releaser workflow
- Loading branch information
1 parent
0bf4877
commit c1c59c9
Showing
2 changed files
with
46 additions
and
33 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 }} | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |