Skip to content

Commit 900bc60

Browse files
committed
feat(ci): publish latest tag on every push
1 parent d833e99 commit 900bc60

1 file changed

Lines changed: 34 additions & 26 deletions

File tree

.github/workflows/release.yml

Lines changed: 34 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -9,31 +9,6 @@ on:
99
workflow_dispatch:
1010

1111
jobs:
12-
retag:
13-
name: Update latest tag
14-
needs: release
15-
runs-on: ubuntu-latest
16-
if: startsWith(github.ref, 'refs/tags/')
17-
steps:
18-
- name: Checkout
19-
uses: actions/checkout@v4
20-
with:
21-
fetch-depth: 0
22-
- name: Configure git user
23-
run: |
24-
git config user.name "github-actions[bot]"
25-
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
26-
- name: Move latest tag
27-
env:
28-
COMMIT_SHA: ${{ github.sha }}
29-
run: |
30-
set -euo pipefail
31-
if git rev-parse latest >/dev/null 2>&1; then
32-
git tag -d latest
33-
fi
34-
git push origin :refs/tags/latest || true
35-
git tag latest "$COMMIT_SHA"
36-
git push origin latest --force
3712

3813
build:
3914
name: Build binaries
@@ -87,8 +62,37 @@ jobs:
8762
name: Publish release
8863
needs: build
8964
runs-on: ubuntu-latest
90-
if: startsWith(github.ref, 'refs/tags/')
9165
steps:
66+
- name: Checkout
67+
uses: actions/checkout@v4
68+
with:
69+
fetch-depth: 0
70+
71+
- name: Configure git user
72+
run: |
73+
git config user.name "github-actions[bot]"
74+
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
75+
76+
- name: Determine release tag
77+
id: release_tag
78+
run: |
79+
if [[ "$GITHUB_REF" == refs/tags/* ]]; then
80+
echo "tag=${GITHUB_REF#refs/tags/}" >> "$GITHUB_OUTPUT"
81+
else
82+
echo "tag=latest" >> "$GITHUB_OUTPUT"
83+
fi
84+
85+
- name: Update latest tag
86+
env:
87+
COMMIT_SHA: ${{ github.sha }}
88+
run: |
89+
set -euo pipefail
90+
git fetch --tags
91+
git tag -d latest 2>/dev/null || true
92+
git push origin :refs/tags/latest || true
93+
git tag latest "$COMMIT_SHA"
94+
git push origin latest --force
95+
9296
- name: Download artifacts
9397
uses: actions/download-artifact@v4
9498
with:
@@ -97,6 +101,10 @@ jobs:
97101
- name: Publish GitHub Release
98102
uses: softprops/action-gh-release@v1
99103
with:
104+
tag_name: ${{ steps.release_tag.outputs.tag }}
105+
target_commitish: ${{ github.sha }}
106+
name: ${{ steps.release_tag.outputs.tag == 'latest' && 'Latest' || steps.release_tag.outputs.tag }}
107+
make_latest: true
100108
files: release/**/*
101109
env:
102110
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

0 commit comments

Comments
 (0)