-
Notifications
You must be signed in to change notification settings - Fork 1
54 lines (45 loc) · 1.59 KB
/
auto-release.yaml
File metadata and controls
54 lines (45 loc) · 1.59 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
name: Auto release
on:
push:
branches:
- main
jobs:
release:
name: Bump version and tag
runs-on: ubuntu-22.04
if: "!startsWith(github.event.head_commit.message, 'chore: release v')"
permissions:
contents: write
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
token: ${{ secrets.RELEASE_PAT }}
- name: Determine next version
id: next
run: |
current=$(node -p "require('./package.json').version")
IFS='.' read -r major minor patch <<< "$current"
next_patch=$((patch + 1))
# Skip past any tags that already exist
while git tag -l "v${major}.${minor}.${next_patch}" | grep -q .; do
next_patch=$((next_patch + 1))
done
echo "version=${major}.${minor}.${next_patch}" >> "$GITHUB_OUTPUT"
- name: Update package.json version
run: npm version ${{ steps.next.outputs.version }} --no-git-tag-version
- name: Commit version bump
run: |
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
git add package.json
git commit -m "chore: release v${{ steps.next.outputs.version }}"
git push origin main
- name: Create GitHub release (creates the tag)
env:
GH_TOKEN: ${{ secrets.RELEASE_PAT }}
run: |
gh release create "v${{ steps.next.outputs.version }}" \
--target main \
--title "v${{ steps.next.outputs.version }}" \
--generate-notes