-
Notifications
You must be signed in to change notification settings - Fork 0
70 lines (58 loc) · 2.02 KB
/
release.yml
File metadata and controls
70 lines (58 loc) · 2.02 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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
name: Release
on:
push:
branches: [main]
workflow_dispatch: {}
permissions:
contents: write
concurrency:
group: release
cancel-in-progress: false
jobs:
tag-and-release:
name: Tag and release
runs-on: ubuntu-latest
if: "!contains(github.event.head_commit.message, '[skip ci]')"
steps:
- uses: actions/checkout@v6
with:
fetch-depth: 0
token: ${{ secrets.GITHUB_TOKEN }}
- name: Read version from package.json
id: ver
run: |
version=$(python3 -c "import json; print(json.load(open('package.json'))['version'])")
echo "version=$version" >> "$GITHUB_OUTPUT"
echo "Version from package.json: $version"
- name: Check if tag already exists
id: check
run: |
version="${{ steps.ver.outputs.version }}"
if git rev-parse "v$version" >/dev/null 2>&1; then
echo "skip=true" >> "$GITHUB_OUTPUT"
echo "Tag v$version already exists, skipping release"
else
echo "skip=false" >> "$GITHUB_OUTPUT"
echo "Tag v$version does not exist, proceeding"
fi
- name: Create and push tags
if: steps.check.outputs.skip == 'false'
run: |
version="${{ steps.ver.outputs.version }}"
IFS='.' read -r major minor _patch <<< "$version"
git config user.name "github-actions[bot]"
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
git tag "v$version"
git tag -f "v$major"
git tag -f "v$major.$minor"
git push origin "v$version"
git push origin "v$major" --force
git push origin "v$major.$minor" --force
- name: Create GitHub Release
if: steps.check.outputs.skip == 'false'
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
gh release create "v${{ steps.ver.outputs.version }}" \
--title "v${{ steps.ver.outputs.version }}" \
--generate-notes