-
Notifications
You must be signed in to change notification settings - Fork 0
40 lines (37 loc) · 1.13 KB
/
Copy pathrelease.yml
File metadata and controls
40 lines (37 loc) · 1.13 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
name: Release
# On push to the default branch (a merged PR), tag v<package.json version> and
# publish a GitHub Release with generated notes — unless the tag already exists.
on:
push:
branches: ["master"]
workflow_dispatch: {}
permissions:
contents: read
jobs:
release:
name: Tag and release
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- uses: actions/checkout@v6
with:
fetch-depth: 0
persist-credentials: false
- name: Read version
id: v
run: |
version=$(jq -r .version package.json)
echo "tag=v$version" >> "$GITHUB_OUTPUT"
- name: Release if new
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
TAG: ${{ steps.v.outputs.tag }}
run: |
if gh release view "$TAG" >/dev/null 2>&1 \
|| git ls-remote --tags origin "refs/tags/$TAG" | grep -q .; then
echo "Tag $TAG already exists — skipping."
exit 0
fi
gh release create "$TAG" --target "${{ github.sha }}" --title "$TAG" --generate-notes
echo "Released $TAG ✓"