chore: update #1
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*' | |
| jobs: | |
| release: | |
| name: Create Release | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| - name: Setup Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: '18.x' | |
| cache: 'npm' | |
| - name: Install dependencies | |
| run: npm ci | |
| - name: Run full build | |
| run: npm run build | |
| - name: Extract version from tag | |
| id: version | |
| run: | | |
| VERSION=${GITHUB_REF#refs/tags/v} | |
| echo "version=$VERSION" >> $GITHUB_OUTPUT | |
| echo "Version: $VERSION" | |
| - name: Verify version in package.json | |
| run: | | |
| PACKAGE_VERSION=$(node -p "require('./package.json').version") | |
| TAG_VERSION="${{ steps.version.outputs.version }}" | |
| if [ "$PACKAGE_VERSION" != "$TAG_VERSION" ]; then | |
| echo "Version mismatch: package.json has $PACKAGE_VERSION but tag is $TAG_VERSION" | |
| exit 1 | |
| fi | |
| echo "Version verified: $PACKAGE_VERSION" | |
| - name: Generate changelog for release | |
| id: changelog | |
| run: | | |
| # Extract changelog for this version | |
| if grep -q "## \[${{ steps.version.outputs.version }}\]" CHANGELOG.md; then | |
| # Extract content between this version and the next | |
| awk '/## \[${{ steps.version.outputs.version }}\]/,/## \[/ { | |
| if (/## \[/ && !/## \[${{ steps.version.outputs.version }}\]/) exit; | |
| if (!/## \[${{ steps.version.outputs.version }}\]/) print | |
| }' CHANGELOG.md > release_notes.md | |
| echo "Release notes generated from CHANGELOG.md" | |
| else | |
| echo "No changelog entry found for version ${{ steps.version.outputs.version }}" | |
| echo "## Changes" > release_notes.md | |
| echo "See CHANGELOG.md for details." >> release_notes.md | |
| fi | |
| - name: Create GitHub Release | |
| uses: actions/create-release@v1 | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| with: | |
| tag_name: ${{ github.ref }} | |
| release_name: Release v${{ steps.version.outputs.version }} | |
| body_path: release_notes.md | |
| draft: false | |
| prerelease: ${{ contains(steps.version.outputs.version, '-') }} | |
| docker: | |
| name: Build and Push Docker Image | |
| runs-on: ubuntu-latest | |
| needs: release | |
| if: success() | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Extract version | |
| id: version | |
| run: | | |
| VERSION=${GITHUB_REF#refs/tags/v} | |
| echo "version=$VERSION" >> $GITHUB_OUTPUT | |
| - name: Set up Docker Buildx | |
| uses: docker/setup-buildx-action@v3 | |
| - name: Login to Docker Hub | |
| uses: docker/login-action@v3 | |
| with: | |
| username: ${{ secrets.DOCKER_USERNAME }} | |
| password: ${{ secrets.DOCKER_PASSWORD }} | |
| - name: Build and push Docker image | |
| uses: docker/build-push-action@v5 | |
| with: | |
| context: . | |
| push: true | |
| tags: | | |
| ggcode/compiler:latest | |
| ggcode/compiler:v${{ steps.version.outputs.version }} | |
| platforms: linux/amd64,linux/arm64 | |
| cache-from: type=gha | |
| cache-to: type=gha,mode=max | |
| notify: | |
| name: Notify Release | |
| runs-on: ubuntu-latest | |
| needs: [release, docker] | |
| if: always() | |
| steps: | |
| - name: Extract version | |
| id: version | |
| run: | | |
| VERSION=${GITHUB_REF#refs/tags/v} | |
| echo "version=$VERSION" >> $GITHUB_OUTPUT | |
| - name: Notify success | |
| if: needs.release.result == 'success' && needs.docker.result == 'success' | |
| run: | | |
| echo "🎉 Release v${{ steps.version.outputs.version }} completed successfully!" | |
| echo "- GitHub release created" | |
| echo "- Docker image pushed" | |
| - name: Notify failure | |
| if: needs.release.result == 'failure' || needs.docker.result == 'failure' | |
| run: | | |
| echo "❌ Release v${{ steps.version.outputs.version }} failed!" | |
| echo "- Release status: ${{ needs.release.result }}" | |
| echo "- Docker status: ${{ needs.docker.result }}" | |
| exit 1 |