-
Notifications
You must be signed in to change notification settings - Fork 5
61 lines (50 loc) · 1.91 KB
/
Copy pathrelease.yml
File metadata and controls
61 lines (50 loc) · 1.91 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
name: Release
on:
release:
types: [published]
jobs:
version-and-changelog:
name: Update Version and Changelog
runs-on: ubuntu-latest
# Skip pre-releases and tags with pre-release suffixes (e.g., v3.4.5-pre1, v3.4.5-alpha1)
if: github.event.release.prerelease == false && !contains(github.event.release.tag_name, '-')
permissions:
contents: write
steps:
- name: Checkout
uses: actions/checkout@v6
with:
fetch-depth: 0
ref: main
- name: Setup Bun
uses: oven-sh/setup-bun@v2
- name: Install dependencies
run: bun install --frozen-lockfile
- name: Configure Git
run: |
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
- name: Update version from release tag
run: |
RELEASE_TAG="${{ github.event.release.tag_name }}"
RELEASE_VERSION="${RELEASE_TAG#v}"
echo "Release tag: $RELEASE_TAG"
echo "Release version: $RELEASE_VERSION"
# Update version in package.json
RELEASE_VERSION="$RELEASE_VERSION" node -e "
const fs = require('fs');
const pkg = JSON.parse(fs.readFileSync('package.json', 'utf8'));
pkg.version = process.env.RELEASE_VERSION;
fs.writeFileSync('package.json', JSON.stringify(pkg, null, 4) + '\n');
"
NEW_VERSION=$(node -p "require('./package.json').version")
echo "Updated package.json version to: $NEW_VERSION"
# Check if there are changes to commit
if [[ -n $(git status --porcelain) ]]; then
git add .
git commit -m "chore: version ${{ github.event.release.tag_name }} [skip ci]"
git push origin main
echo "✅ Version updated"
else
echo "ℹ️ Version already up to date"
fi