chore: tag version v0.0.2 #6
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 Cursor Rules | |
| on: | |
| push: | |
| tags: | |
| - 'v[0-9]+.[0-9]+.[0-9]+' | |
| permissions: | |
| contents: write | |
| jobs: | |
| release: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| - name: Setup Deno | |
| uses: denoland/setup-deno@v2 | |
| with: | |
| deno-version: v2.x | |
| - name: Cache Deno dependencies | |
| uses: actions/cache@v3 | |
| with: | |
| path: ~/.cache/deno | |
| key: ${{ runner.os }}-deno-${{ hashFiles('deno.lock') }} | |
| restore-keys: ${{ runner.os }}-deno- | |
| - name: Validate tag format | |
| run: | | |
| if [[ ! "${{ github.ref_name }}" =~ ^v[0-9]+\.[0-9]+\.[0-9]+$ ]]; then | |
| echo "::error::Invalid tag format: ${{ github.ref_name }}. Expected format: vX.Y.Z" | |
| exit 1 | |
| fi | |
| echo "Tag format is valid: ${{ github.ref_name }}" | |
| - name: Check for existing release | |
| id: check_release | |
| run: | | |
| TAG="${{ github.ref_name }}" | |
| echo "Checking for existing release with tag $TAG" | |
| RELEASE_ID=$(curl -s -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \ | |
| "https://api.github.com/repos/${{ github.repository }}/releases/tags/$TAG" | \ | |
| jq -r '.id // "null"') | |
| if [ "$RELEASE_ID" != "null" ]; then | |
| echo "Existing release found with ID: $RELEASE_ID" | |
| echo "release_exists=true" >> $GITHUB_OUTPUT | |
| echo "release_id=$RELEASE_ID" >> $GITHUB_OUTPUT | |
| else | |
| echo "No existing release found for tag $TAG" | |
| echo "release_exists=false" >> $GITHUB_OUTPUT | |
| fi | |
| - name: Delete existing release | |
| if: steps.check_release.outputs.release_exists == 'true' | |
| run: | | |
| echo "Deleting existing release with ID: ${{ steps.check_release.outputs.release_id }}" | |
| curl -s -X DELETE -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \ | |
| "https://api.github.com/repos/${{ github.repository }}/releases/${{ steps.check_release.outputs.release_id }}" | |
| echo "Existing release deleted successfully" | |
| - name: Build rules | |
| id: build | |
| run: | | |
| echo "::group::Building rules" | |
| deno run -A scripts/build.ts | |
| echo "::endgroup::" | |
| # Verify output files exist | |
| if [ ! -f "bin/rules.json" ] || [ ! -f "bin/rules.jsonc" ]; then | |
| echo "::error::Build failed: Required output files missing" | |
| ls -la bin/ | |
| exit 1 | |
| fi | |
| echo "Build completed successfully" | |
| - name: Create release package | |
| id: release_package | |
| run: | | |
| echo "::group::Creating release package" | |
| deno run --allow-read --allow-write --allow-env scripts/release.ts | |
| echo "::endgroup::" | |
| # Verify zip file exists | |
| if [ ! -f "bin/rules.zip" ]; then | |
| echo "::error::Release package creation failed: rules.zip not found" | |
| ls -la bin/ | |
| exit 1 | |
| fi | |
| echo "Release package created successfully" | |
| - name: Debug release contents | |
| run: | | |
| echo "::group::Release package contents" | |
| mkdir -p /tmp/rules-debug | |
| unzip -l bin/rules.zip | |
| unzip -q bin/rules.zip -d /tmp/rules-debug | |
| ls -la /tmp/rules-debug/ | |
| echo "::endgroup::" | |
| - name: Get tag message | |
| id: tag_message | |
| run: | | |
| TAG_MESSAGE=$(git tag -l --format='%(contents)' ${{ github.ref_name }}) | |
| if [ -z "$TAG_MESSAGE" ]; then | |
| echo "No tag message found. Using default release notes." | |
| TAG_MESSAGE="Release ${{ github.ref_name }}" | |
| fi | |
| echo "message<<EOF" >> $GITHUB_OUTPUT | |
| echo "$TAG_MESSAGE" >> $GITHUB_OUTPUT | |
| echo "EOF" >> $GITHUB_OUTPUT | |
| - name: Create GitHub Release | |
| uses: softprops/action-gh-release@v2 | |
| with: | |
| files: bin/rules.zip | |
| body: ${{ steps.tag_message.outputs.message }} | |
| token: ${{ secrets.GITHUB_TOKEN }} | |
| name: "Cursor Rules ${{ github.ref_name }}" | |
| fail_on_unmatched_files: true | |
| draft: false | |
| prerelease: false | |
| generate_release_notes: false |