-
Notifications
You must be signed in to change notification settings - Fork 0
89 lines (70 loc) · 2.39 KB
/
release.yml
File metadata and controls
89 lines (70 loc) · 2.39 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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
name: Release
on:
push:
tags:
- 'v*'
permissions:
contents: write
jobs:
release:
name: Build and Release
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v5
- name: Setup pnpm
uses: pnpm/action-setup@v4
with:
version: 10
- name: Setup Node.js
id: setup-node
uses: actions/setup-node@v6
with:
node-version-file: .node-version
cache: pnpm
- name: Install Dependencies
run: pnpm install --frozen-lockfile
- name: Build dist/
run: pnpm run package
- name: Commit dist/ to release branch
run: |
# Extract version tag
TAG=${GITHUB_REF#refs/tags/}
MAJOR_VERSION=$(echo $TAG | cut -d. -f1)
# Configure git
git config user.name github-actions
git config user.email [email protected]
# Create/checkout release branch
git checkout -b releases/$MAJOR_VERSION
# Remove dist/ from gitignore for this branch
sed -i '/^dist\//d' .gitignore
# Add and commit dist/
git add -f dist/
git add .gitignore
git commit -m "Build for $TAG"
# Push the release branch
git push origin releases/$MAJOR_VERSION --force
# Delete the old tag from remote (it points to main branch)
git push origin :refs/tags/$TAG || true
# Re-create the tag pointing to this release branch commit
git tag -fa $TAG -m "Release $TAG"
git push origin $TAG
- name: Update Major Version Tag
if:
${{ !contains(github.ref, 'alpha') && !contains(github.ref, 'beta') &&
!contains(github.ref, 'rc') }}
run: |
# Extract major version (e.g., v1 from v1.2.3)
TAG=${GITHUB_REF#refs/tags/}
MAJOR_VERSION=$(echo $TAG | cut -d. -f1)
# Update the major version tag to point to the release branch
git tag -fa $MAJOR_VERSION -m "Update $MAJOR_VERSION tag"
git push origin $MAJOR_VERSION --force
- name: Create Release
uses: softprops/action-gh-release@v2
with:
generate_release_notes: true
draft: false
prerelease:
${{ contains(github.ref, 'alpha') || contains(github.ref, 'beta') ||
contains(github.ref, 'rc') }}