feat(release): simplify dev versioning with stable base

- Remove dev branch from semantic-release (main only)
- Add dev-release.yml: simple X.Y.Z-dev.N bump workflow
- Update sync workflow: handle merge conflicts for version files
- Update release.yml: trigger only on main branch

Dev versions now stay at {stable}-dev.N until merged to main.
PR merge commit type (feat/fix) determines actual version bump.
This commit is contained in:
kaitranntt
2025-12-04 01:23:46 -05:00
parent 88fc1b3a2e
commit 942b4b92cf
4 changed files with 107 additions and 8 deletions
+88
View File
@@ -0,0 +1,88 @@
name: Dev Release
on:
push:
branches: [dev]
jobs:
release:
# Skip if commit message contains [skip ci] or is a release commit
if: "!contains(github.event.head_commit.message, '[skip ci]')"
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
token: ${{ secrets.PAT_TOKEN }}
- name: Setup Bun
uses: oven-sh/setup-bun@v2
with:
bun-version: latest
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '22'
registry-url: 'https://registry.npmjs.org'
- name: Install dependencies
run: bun install --frozen-lockfile
- name: Build and validate
run: |
bun run build
bun run validate
- name: Bump dev version
id: bump
run: |
CURRENT=$(cat VERSION)
# Extract base version and dev number
if [[ "$CURRENT" =~ ^([0-9]+\.[0-9]+\.[0-9]+)(-dev\.([0-9]+))?$ ]]; then
BASE="${BASH_REMATCH[1]}"
DEV_NUM="${BASH_REMATCH[3]:-0}"
NEW_DEV=$((DEV_NUM + 1))
NEW_VERSION="${BASE}-dev.${NEW_DEV}"
else
echo "Invalid version format: $CURRENT"
exit 1
fi
echo "current=$CURRENT" >> $GITHUB_OUTPUT
echo "new=$NEW_VERSION" >> $GITHUB_OUTPUT
echo "Bumping: $CURRENT -> $NEW_VERSION"
- name: Update version files
run: |
NEW_VERSION="${{ steps.bump.outputs.new }}"
# Update VERSION file
echo "$NEW_VERSION" > VERSION
# Update package.json
jq --arg v "$NEW_VERSION" '.version = $v' package.json > package.json.tmp
mv package.json.tmp package.json
# Update installers
sed -i "s/^VERSION=.*/VERSION=\"$NEW_VERSION\"/" installers/install.sh
sed -i "s/^\$Version = .*/\$Version = \"$NEW_VERSION\"/" installers/install.ps1
- name: Publish to npm
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
run: npm publish --tag dev
- 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 VERSION package.json installers/install.sh installers/install.ps1
git commit -m "chore(release): ${{ steps.bump.outputs.new }} [skip ci]"
git push origin dev
+1 -3
View File
@@ -2,9 +2,7 @@ name: Release
on:
push:
branches:
- main
- dev
branches: [main]
workflow_dispatch:
jobs:
+17 -1
View File
@@ -31,5 +31,21 @@ jobs:
run: |
git fetch origin main dev
git checkout dev
git merge origin/main --no-edit -m "chore(sync): merge main into dev after release [skip ci]"
# Attempt merge, handle version conflicts by taking main's versions
if ! git merge origin/main --no-edit -m "chore(sync): merge main into dev after release [skip ci]"; then
echo "Merge conflicts detected, resolving version files..."
# For version files, take main's version (new stable base)
for file in VERSION package.json installers/install.sh installers/install.ps1 CHANGELOG.md; do
if git diff --name-only --diff-filter=U | grep -q "^${file}$"; then
git checkout --theirs "$file"
git add "$file"
fi
done
# Complete the merge
git commit --no-edit
fi
git push origin dev
+1 -4
View File
@@ -1,8 +1,5 @@
{
"branches": [
"main",
{ "name": "dev", "prerelease": true }
],
"branches": ["main"],
"plugins": [
"@semantic-release/commit-analyzer",
"@semantic-release/release-notes-generator",