feat: enhance release workflow to commit built files to release branc… #4
Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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@v4 | |
| - name: Setup Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: 20 | |
| - name: Setup pnpm | |
| uses: pnpm/action-setup@v4 | |
| with: | |
| version: 10 | |
| - 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 github-actions@github.com | |
| # 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 | |
| - 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') }} |