Release Management #2
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 Management | |
| on: | |
| workflow_dispatch: | |
| inputs: | |
| version_type: | |
| description: 'Version bump type' | |
| required: true | |
| default: 'patch' | |
| type: choice | |
| options: | |
| - patch | |
| - minor | |
| - major | |
| release_notes: | |
| description: 'Release notes' | |
| required: false | |
| type: string | |
| env: | |
| # Public environment variables for SvelteKit | |
| PUBLIC_GATEWAY_URL: ${{ secrets.PUBLIC_GATEWAY_URL }} | |
| PUBLIC_PINATA_JWT: ${{ secrets.PUBLIC_PINATA_JWT }} | |
| PUBLIC_HELIUS_API_KEY: ${{ secrets.PUBLIC_HELIUS_API_KEY }} | |
| PUBLIC_PEAQ_MAINNET_RPC_URL: ${{ secrets.PUBLIC_PEAQ_MAINNET_RPC_URL }} | |
| PUBLIC_PEAQ_TESTNET_RPC_URL: ${{ secrets.PUBLIC_PEAQ_TESTNET_RPC_URL }} | |
| PUBLIC_NFT_STORAGE_API_KEY: ${{ secrets.PUBLIC_NFT_STORAGE_API_KEY }} | |
| jobs: | |
| create-release: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| with: | |
| token: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Setup Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: '20' | |
| cache: 'npm' | |
| - name: Install dependencies | |
| run: npm ci | |
| - name: Configure Git | |
| run: | | |
| git config --local user.email "action@github.com" | |
| git config --local user.name "GitHub Action" | |
| - name: Get current version | |
| id: current_version | |
| run: | | |
| CURRENT_VERSION=$(node -p "require('./static/manifest.json').version") | |
| echo "version=$CURRENT_VERSION" >> $GITHUB_OUTPUT | |
| echo "Current version: $CURRENT_VERSION" | |
| - name: Calculate new version | |
| id: new_version | |
| run: | | |
| CURRENT_VERSION="${{ steps.current_version.outputs.version }}" | |
| VERSION_TYPE="${{ github.event.inputs.version_type }}" | |
| IFS='.' read -ra VERSION_PARTS <<< "$CURRENT_VERSION" | |
| MAJOR=${VERSION_PARTS[0]} | |
| MINOR=${VERSION_PARTS[1]} | |
| PATCH=${VERSION_PARTS[2]} | |
| case $VERSION_TYPE in | |
| "major") | |
| MAJOR=$((MAJOR + 1)) | |
| MINOR=0 | |
| PATCH=0 | |
| ;; | |
| "minor") | |
| MINOR=$((MINOR + 1)) | |
| PATCH=0 | |
| ;; | |
| "patch") | |
| PATCH=$((PATCH + 1)) | |
| ;; | |
| esac | |
| NEW_VERSION="$MAJOR.$MINOR.$PATCH" | |
| echo "version=$NEW_VERSION" >> $GITHUB_OUTPUT | |
| echo "New version: $NEW_VERSION" | |
| - name: Update manifest version | |
| run: | | |
| NEW_VERSION="${{ steps.new_version.outputs.version }}" | |
| node -e " | |
| const fs = require('fs'); | |
| const manifest = JSON.parse(fs.readFileSync('./static/manifest.json', 'utf8')); | |
| manifest.version = '$NEW_VERSION'; | |
| fs.writeFileSync('./static/manifest.json', JSON.stringify(manifest, null, 2)); | |
| console.log('Updated manifest.json to version $NEW_VERSION'); | |
| " | |
| - name: Update package.json version | |
| run: | | |
| NEW_VERSION="${{ steps.new_version.outputs.version }}" | |
| node -e " | |
| const fs = require('fs'); | |
| const pkg = JSON.parse(fs.readFileSync('./package.json', 'utf8')); | |
| pkg.version = '$NEW_VERSION'; | |
| fs.writeFileSync('./package.json', JSON.stringify(pkg, null, 2)); | |
| console.log('Updated package.json to version $NEW_VERSION'); | |
| " | |
| - name: Create changelog entry | |
| run: | | |
| NEW_VERSION="${{ steps.new_version.outputs.version }}" | |
| RELEASE_NOTES="${{ github.event.inputs.release_notes }}" | |
| DATE=$(date +"%Y-%m-%d") | |
| if [ ! -f "CHANGELOG.md" ]; then | |
| echo "# Changelog" > CHANGELOG.md | |
| echo "" >> CHANGELOG.md | |
| fi | |
| # Create temporary file with new entry | |
| { | |
| echo "# Changelog" | |
| echo "" | |
| echo "## [v$NEW_VERSION] - $DATE" | |
| echo "" | |
| if [ ! -z "$RELEASE_NOTES" ]; then | |
| echo "$RELEASE_NOTES" | |
| else | |
| echo "- Version bump to $NEW_VERSION" | |
| fi | |
| echo "" | |
| tail -n +3 CHANGELOG.md | |
| } > CHANGELOG.tmp | |
| mv CHANGELOG.tmp CHANGELOG.md | |
| - name: Commit changes | |
| run: | | |
| NEW_VERSION="${{ steps.new_version.outputs.version }}" | |
| git add static/manifest.json package.json CHANGELOG.md | |
| git commit -m "chore: bump version to v$NEW_VERSION" | |
| git push origin main | |
| - name: Create and push tag | |
| run: | | |
| NEW_VERSION="${{ steps.new_version.outputs.version }}" | |
| git tag -a "v$NEW_VERSION" -m "Release v$NEW_VERSION" | |
| git push origin "v$NEW_VERSION" | |
| - name: Create GitHub Release | |
| uses: softprops/action-gh-release@v1 | |
| with: | |
| tag_name: 'v${{ steps.new_version.outputs.version }}' | |
| name: 'Release v${{ steps.new_version.outputs.version }}' | |
| body: ${{ github.event.inputs.release_notes || format('Release version {0}', steps.new_version.outputs.version) }} | |
| draft: false | |
| prerelease: false | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Output summary | |
| run: | | |
| echo "🎉 Release v${{ steps.new_version.outputs.version }} created successfully!" | |
| echo "The deployment workflow will automatically trigger and deploy to Chrome Web Store." |