Skip to content

Commit 2d4fef3

Browse files
committed
Add action to shift the 'latest' tag after a successful build.
1 parent ce24790 commit 2d4fef3

File tree

1 file changed

+61
-0
lines changed

1 file changed

+61
-0
lines changed

.github/workflows/latest.yaml

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
name: Publish latest
2+
3+
on:
4+
workflow_run:
5+
workflows: [Unit tests]
6+
types:
7+
- completed
8+
workflow_dispatch:
9+
10+
jobs:
11+
create-latest:
12+
runs-on: ubuntu-latest
13+
if: ${{ github.event.workflow_run.conclusion == 'success' }}
14+
steps:
15+
- name: Create or update latest
16+
uses: actions/github-script@v7
17+
with:
18+
script: |
19+
github.rest.git.createRef({
20+
owner: context.repo.owner,
21+
repo: context.repo.repo,
22+
ref: 'refs/tags/latest'
23+
sha: context.sha
24+
}).catch(err => {
25+
if (err.status !== 422) throw err;
26+
github.rest.git.updateRef({
27+
owner: context.repo.owner,
28+
repo: context.repo.repo,
29+
ref: 'tags/latest'
30+
sha: context.sha
31+
});
32+
})
33+
34+
- name: Create latest release
35+
uses: softprops/action-gh-release@v1
36+
with:
37+
name: 'latest'
38+
tag_name: 'ref/tags/latest'
39+
40+
publish:
41+
runs-on: ubuntu-latest
42+
needs: create-latest
43+
strategy:
44+
matrix:
45+
os: [ linux, darwin ]
46+
arch: [ amd64, arm64 ]
47+
48+
steps:
49+
- name: Check out
50+
uses: actions/checkout@v4
51+
52+
- name: Publish binaries
53+
uses: wangyoucao577/go-release-action@v1
54+
with:
55+
github_token: ${{ secrets.GITHUB_TOKEN }}
56+
goos: ${{ matrix.os }}
57+
goarch: ${{ matrix.arch }}
58+
release_tag: latest
59+
asset_name: SewerRat-${{ matrix.os }}-${{ matrix.arch }}
60+
overwrite: true
61+
compress_assets: false

0 commit comments

Comments
 (0)