Skip to content

Commit d479daa

Browse files
authored
Merge branch 'main' into main
2 parents a568421 + 78cd04a commit d479daa

File tree

9 files changed

+1043
-217
lines changed

9 files changed

+1043
-217
lines changed

.github/workflows/commit.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ permissions:
1010

1111
jobs:
1212
update-commit:
13+
if: contains(github.event.head_commit.message, '#release') != true
1314
runs-on: ubuntu-latest
1415

1516
steps:
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
name: PR Validation
2+
3+
on:
4+
pull_request:
5+
types: [opened, synchronize, reopened, labeled, unlabeled]
6+
branches:
7+
- main
8+
9+
jobs:
10+
validate:
11+
runs-on: ubuntu-latest
12+
13+
steps:
14+
- uses: actions/checkout@v4
15+
16+
- name: Validate PR Labels
17+
run: |
18+
if [[ "${{ contains(github.event.pull_request.labels.*.name, 'stable-release') }}" == "true" ]]; then
19+
echo "✓ PR has stable-release label"
20+
21+
# Check version bump labels
22+
if [[ "${{ contains(github.event.pull_request.labels.*.name, 'major') }}" == "true" ]]; then
23+
echo "✓ Major version bump requested"
24+
elif [[ "${{ contains(github.event.pull_request.labels.*.name, 'minor') }}" == "true" ]]; then
25+
echo "✓ Minor version bump requested"
26+
else
27+
echo "✓ Patch version bump will be applied"
28+
fi
29+
else
30+
echo "This PR doesn't have the stable-release label. No release will be created."
31+
fi

.github/workflows/update-stable.yml

Lines changed: 59 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,45 @@
11
name: Update Stable Branch
22

33
on:
4-
pull_request:
5-
types: [closed]
4+
push:
65
branches:
76
- main
7+
88
permissions:
99
contents: write
1010

1111
jobs:
12-
update-stable:
13-
if: github.event.pull_request.merged == true && contains(github.event.pull_request.labels.*.name, 'stable-release')
12+
update-commit:
13+
if: contains(github.event.head_commit.message, '#release')
14+
runs-on: ubuntu-latest
15+
16+
steps:
17+
- name: Checkout the code
18+
uses: actions/checkout@v3
19+
20+
- name: Get the latest commit hash
21+
run: echo "COMMIT_HASH=$(git rev-parse HEAD)" >> $GITHUB_ENV
22+
23+
- name: Update commit file
24+
run: |
25+
echo "{ \"commit\": \"$COMMIT_HASH\" }" > app/commit.json
26+
27+
- name: Commit and push the update
28+
run: |
29+
git config --global user.name "github-actions[bot]"
30+
git config --global user.email "github-actions[bot]@users.noreply.github.com"
31+
git add app/commit.json
32+
git commit -m "chore: update commit hash to $COMMIT_HASH"
33+
git push
34+
prepare-release:
35+
needs: update-commit
36+
if: contains(github.event.head_commit.message, '#release')
1437
runs-on: ubuntu-latest
15-
permissions:
16-
contents: write
17-
pull-requests: read
1838

1939
steps:
20-
- uses: actions/checkout@v3
40+
- uses: actions/checkout@v4
41+
with:
42+
fetch-depth: 0
2143

2244
- name: Configure Git
2345
run: |
@@ -49,17 +71,6 @@ jobs:
4971
restore-keys: |
5072
${{ runner.os }}-pnpm-store-
5173
52-
- name: Determine Version Bump
53-
id: version_bump
54-
run: |
55-
if [[ "${{ contains(github.event.pull_request.labels.*.name, 'major') }}" == "true" ]]; then
56-
echo "bump=major" >> $GITHUB_OUTPUT
57-
elif [[ "${{ contains(github.event.pull_request.labels.*.name, 'minor') }}" == "true" ]]; then
58-
echo "bump=minor" >> $GITHUB_OUTPUT
59-
else
60-
echo "bump=patch" >> $GITHUB_OUTPUT
61-
fi
62-
6374
- name: Get Current Version
6475
id: current_version
6576
run: |
@@ -69,6 +80,18 @@ jobs:
6980
- name: Install semver
7081
run: pnpm add -g semver
7182

83+
- name: Determine Version Bump
84+
id: version_bump
85+
run: |
86+
COMMIT_MSG="${{ github.event.head_commit.message }}"
87+
if [[ $COMMIT_MSG =~ "#release:major" ]]; then
88+
echo "bump=major" >> $GITHUB_OUTPUT
89+
elif [[ $COMMIT_MSG =~ "#release:minor" ]]; then
90+
echo "bump=minor" >> $GITHUB_OUTPUT
91+
else
92+
echo "bump=patch" >> $GITHUB_OUTPUT
93+
fi
94+
7295
- name: Bump Version
7396
id: bump_version
7497
run: |
@@ -158,32 +181,30 @@ jobs:
158181
echo "$CHANGELOG_CONTENT" >> $GITHUB_OUTPUT
159182
echo "EOF" >> $GITHUB_OUTPUT
160183
161-
- name: Commit Version Update
184+
- name: Commit and Tag Release
162185
run: |
163186
git pull
164187
git add package.json pnpm-lock.yaml changelog.md
165-
git commit -m "chore: bump version to ${{ steps.bump_version.outputs.new_version }}"
188+
git commit -m "chore: release version ${{ steps.bump_version.outputs.new_version }}"
189+
git tag "v${{ steps.bump_version.outputs.new_version }}"
166190
git push
191+
git push --tags
167192
168193
- name: Update Stable Branch
169194
run: |
170-
# Ensure stable branch exists
171-
git checkout stable 2>/dev/null || git checkout -b stable
172-
git merge main --no-ff -m "chore: merge main into stable for version ${{ steps.bump_version.outputs.new_version }}"
173-
git push --set-upstream origin stable
195+
if ! git checkout stable 2>/dev/null; then
196+
echo "Creating new stable branch..."
197+
git checkout -b stable
198+
fi
199+
git merge main --no-ff -m "chore: release version ${{ steps.bump_version.outputs.new_version }}"
200+
git push --set-upstream origin stable --force
174201
175-
- name: Create and Push Tag
202+
- name: Create GitHub Release
203+
env:
204+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
176205
run: |
177206
VERSION="v${{ steps.bump_version.outputs.new_version }}"
178-
git tag -a "$VERSION" -m "Release $VERSION"
179-
git push origin "$VERSION"
180-
181-
# - name: Create GitHub Release
182-
# env:
183-
# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
184-
# run: |
185-
# VERSION="v${{ steps.bump_version.outputs.new_version }}"
186-
# gh release create "$VERSION" \
187-
# --title "Release $VERSION" \
188-
# --notes "${{ steps.changelog.outputs.content }}" \
189-
# --target stable
207+
gh release create "$VERSION" \
208+
--title "Release $VERSION" \
209+
--notes "${{ steps.changelog.outputs.content }}" \
210+
--target stable

0 commit comments

Comments
 (0)