chore: bump version to 1.0.13 #5
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 | ||
| # Skip if commit is from github-actions bot or contains [skip ci] | ||
| 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: | | ||
| # Get the latest tag | ||
| 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" | ||
| # Create backup of current changelog | ||
| cp CHANGELOG.md CHANGELOG.md.backup | ||
| # Generate new changelog | ||
| auto-changelog --template keepachangelog --commit-limit false --unreleased | ||
| # If the changelog wasn't properly updated, manually update it | ||
| if ! grep -q "## \[v$VERSION\]" CHANGELOG.md; then | ||
| echo "Manually updating changelog for v$VERSION" | ||
| # Get current date | ||
| CURRENT_DATE=$(date '+%Y-%m-%d') | ||
| # Create temporary changelog content | ||
| cat > temp_changelog.md << EOF | ||
| # Changelog | ||
| All notable changes to this project will be documented in this file. | ||
| The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/) | ||
| and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). | ||
| Generated by [\`auto-changelog\`](https://github.com/CookPete/auto-changelog). | ||
| ## [Unreleased](https://github.com/chess-labs/core/compare/v$VERSION...HEAD) | ||
| ## [v$VERSION](https://github.com/chess-labs/core/compare/v$PREV_VERSION...v$VERSION) - $CURRENT_DATE | ||
| ### Commits | ||
| EOF | ||
| # Get commits since last version | ||
| 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 | ||
| # Append existing changelog content (excluding header) | ||
| if [ -f CHANGELOG.md.backup ]; then | ||
| tail -n +9 CHANGELOG.md.backup >> temp_changelog.md | ||
| fi | ||
| # Replace changelog | ||
| 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' | ||
| # Add changelog | ||
| git add CHANGELOG.md | ||
| # Check if there are changes to commit | ||
| 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 }}" | ||
| # Create annotated tag | ||
| 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" | ||