diff --git a/.github/workflows/dev-release.yml b/.github/workflows/dev-release.yml new file mode 100644 index 00000000..e0f08d78 --- /dev/null +++ b/.github/workflows/dev-release.yml @@ -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 diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 06da872f..8dc0e40f 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -2,9 +2,7 @@ name: Release on: push: - branches: - - main - - dev + branches: [main] workflow_dispatch: jobs: diff --git a/.github/workflows/sync-dev-after-release.yml b/.github/workflows/sync-dev-after-release.yml index 1e1fdbc2..48495fe6 100644 --- a/.github/workflows/sync-dev-after-release.yml +++ b/.github/workflows/sync-dev-after-release.yml @@ -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 diff --git a/.releaserc.json b/.releaserc.json index 8bde2f39..1809e16b 100644 --- a/.releaserc.json +++ b/.releaserc.json @@ -1,8 +1,5 @@ { - "branches": [ - "main", - { "name": "dev", "prerelease": true } - ], + "branches": ["main"], "plugins": [ "@semantic-release/commit-analyzer", "@semantic-release/release-notes-generator",