chore: bump version to 1.0.15 #8
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 Workflow | |
| on: | |
| push: | |
| branches: [main] | |
| paths: | |
| - 'package.json' | |
| workflow_dispatch: | |
| inputs: | |
| version_type: | |
| description: 'Version bump type' | |
| required: true | |
| type: choice | |
| options: | |
| - patch | |
| - minor | |
| - major | |
| default: patch | |
| jobs: | |
| release: | |
| runs-on: ubuntu-latest | |
| if: "!contains(github.event.head_commit.message, '[skip ci]') && github.actor != 'github-actions[bot]'" | |
| permissions: | |
| contents: write | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| token: ${{ secrets.GA_TOKEN }} | |
| - name: Setup Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: '18' | |
| - name: Setup pnpm | |
| uses: pnpm/action-setup@v2 | |
| with: | |
| version: latest | |
| - name: Install dependencies | |
| run: pnpm install | |
| - name: Get current version | |
| id: current-version | |
| run: | | |
| VERSION=$(node -p "require('./package.json').version") | |
| echo "version=$VERSION" >> $GITHUB_OUTPUT | |
| echo "Current version: $VERSION" | |
| - name: Check if tag exists | |
| id: check-tag | |
| run: | | |
| VERSION="${{ steps.current-version.outputs.version }}" | |
| if git rev-parse "v$VERSION" >/dev/null 2>&1; then | |
| echo "exists=true" >> $GITHUB_OUTPUT | |
| echo "Tag v$VERSION already exists" | |
| else | |
| echo "exists=false" >> $GITHUB_OUTPUT | |
| echo "Tag v$VERSION does not exist" | |
| fi | |
| - name: Get previous version | |
| id: previous-version | |
| if: steps.check-tag.outputs.exists == 'false' | |
| run: | | |
| PREV_TAG=$(git describe --tags --abbrev=0 2>/dev/null || echo "") | |
| if [ -n "$PREV_TAG" ]; then | |
| PREV_VERSION=${PREV_TAG#v} | |
| echo "previous=$PREV_VERSION" >> $GITHUB_OUTPUT | |
| echo "Previous version: $PREV_VERSION" | |
| else | |
| echo "previous=" >> $GITHUB_OUTPUT | |
| echo "No previous version found" | |
| fi | |
| - name: Install auto-changelog globally | |
| if: steps.check-tag.outputs.exists == 'false' | |
| run: npm install -g auto-changelog | |
| - name: Update changelog for current version | |
| if: steps.check-tag.outputs.exists == 'false' | |
| run: | | |
| VERSION="${{ steps.current-version.outputs.version }}" | |
| PREV_VERSION="${{ steps.previous-version.outputs.previous }}" | |
| echo "Updating changelog for version v$VERSION" | |
| cp CHANGELOG.md CHANGELOG.md.backup | |
| auto-changelog --template keepachangelog --commit-limit false --unreleased | |
| if ! grep -q "## \\[v$VERSION\\]" CHANGELOG.md; then | |
| echo "Manually updating changelog for v$VERSION" | |
| CURRENT_DATE=$(date '+%Y-%m-%d') | |
| { | |
| echo "# Changelog" | |
| echo "" | |
| echo "All notable changes to this project will be documented in this file." | |
| echo "" | |
| echo "The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)" | |
| echo "and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html)." | |
| echo "" | |
| echo "Generated by [\`auto-changelog\`](https://github.com/CookPete/auto-changelog)." | |
| echo "" | |
| echo "## [Unreleased](https://github.com/chess-labs/core/compare/v$VERSION...HEAD)" | |
| echo "" | |
| echo "## [v$VERSION](https://github.com/chess-labs/core/compare/v$PREV_VERSION...v$VERSION) - $CURRENT_DATE" | |
| echo "" | |
| echo "### Commits" | |
| echo "" | |
| } > temp_changelog.md | |
| if [ -n "$PREV_VERSION" ]; then | |
| git log --oneline --no-merges "v$PREV_VERSION..HEAD" --pretty=format:"- %s [\`%h\`](https://github.com/chess-labs/core/commit/%H)" >> temp_changelog.md | |
| else | |
| git log --oneline --no-merges --pretty=format:"- %s [\`%h\`](https://github.com/chess-labs/core/commit/%H)" >> temp_changelog.md | |
| fi | |
| echo "" >> temp_changelog.md | |
| echo "" >> temp_changelog.md | |
| if [ -f CHANGELOG.md.backup ]; then | |
| tail -n +9 CHANGELOG.md.backup >> temp_changelog.md | |
| fi | |
| mv temp_changelog.md CHANGELOG.md | |
| fi | |
| echo "✅ Changelog updated for v$VERSION" | |
| - name: Commit and push changelog | |
| if: steps.check-tag.outputs.exists == 'false' | |
| run: | | |
| VERSION="${{ steps.current-version.outputs.version }}" | |
| git config --global user.name 'github-actions[bot]' | |
| git config --global user.email 'github-actions[bot]@users.noreply.github.com' | |
| git add CHANGELOG.md | |
| if ! git diff --staged --quiet; then | |
| git commit -m "docs: auto-update changelog for v$VERSION [skip ci]" | |
| git push origin main | |
| echo "✅ Committed and pushed changelog updates" | |
| else | |
| echo "ℹ️ No changelog changes to commit" | |
| fi | |
| - name: Create and push tag | |
| if: steps.check-tag.outputs.exists == 'false' | |
| run: | | |
| VERSION="${{ steps.current-version.outputs.version }}" | |
| git tag -a "v$VERSION" -m "Release v$VERSION" | |
| git push origin "v$VERSION" | |
| echo "✅ Created and pushed tag v$VERSION" | |
| - name: Create GitHub Release | |
| if: steps.check-tag.outputs.exists == 'false' | |
| uses: actions/create-release@v1 | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GA_TOKEN }} | |
| with: | |
| tag_name: v${{ steps.current-version.outputs.version }} | |
| release_name: Release v${{ steps.current-version.outputs.version }} | |
| body: | | |
| 🚀 **Release v${{ steps.current-version.outputs.version }}** | |
| ## What's Changed | |
| Check the [CHANGELOG.md](https://github.com/chess-labs/core/blob/main/CHANGELOG.md) for detailed changes. | |
| **Full Changelog**: https://github.com/chess-labs/core/compare/v${{ steps.current-version.outputs.version }}...HEAD | |
| draft: false | |
| prerelease: false | |
| - name: Skip message | |
| if: steps.check-tag.outputs.exists == 'true' | |
| run: | | |
| echo "⏭️ Tag v${{ steps.current-version.outputs.version }} already exists, skipping release" |