Skip to content

Commit 68ae7d5

Browse files
Merge pull request #2 from LucaTools/release-workflow
Add `release.yml` workflow
2 parents 42043cd + 49f1b55 commit 68ae7d5

1 file changed

Lines changed: 52 additions & 0 deletions

File tree

.github/workflows/release.yml

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
name: Release
2+
3+
# Triggered when a version tag is pushed (e.g. git tag v1.2.3 && git push --tags).
4+
# The workflow runs the test suite first, then creates a GitHub Release and
5+
# force-updates the corresponding floating major tag (e.g. v1) so that callers
6+
# pinned to `@v1` always get the latest patch within that major version.
7+
on:
8+
push:
9+
tags:
10+
- "v*"
11+
12+
jobs:
13+
test:
14+
name: Run tests before release
15+
uses: ./.github/workflows/test.yml
16+
17+
release:
18+
name: Create GitHub Release
19+
needs: test
20+
runs-on: ubuntu-latest
21+
permissions:
22+
contents: write
23+
steps:
24+
- uses: actions/checkout@v4
25+
26+
- name: Create GitHub Release
27+
env:
28+
GH_TOKEN: ${{ github.token }}
29+
run: |
30+
gh release create "$GITHUB_REF_NAME" \
31+
--title "$GITHUB_REF_NAME" \
32+
--generate-notes
33+
34+
update-major-tag:
35+
name: Update floating major tag
36+
needs: release
37+
runs-on: ubuntu-latest
38+
permissions:
39+
contents: write
40+
steps:
41+
- uses: actions/checkout@v4
42+
43+
- name: Force-update major tag
44+
run: |
45+
TAG="${GITHUB_REF_NAME}"
46+
MAJOR="${TAG%%.*}"
47+
48+
git config user.name "github-actions[bot]"
49+
git config user.email "github-actions[bot]@users.noreply.github.com"
50+
51+
git tag -f "${MAJOR}"
52+
git push origin "${MAJOR}" --force

0 commit comments

Comments
 (0)