From f480004dda34d0bf8945684c2e7c6380d023c4c4 Mon Sep 17 00:00:00 2001 From: Yoni Melki Date: Tue, 23 Jun 2026 21:59:54 +0300 Subject: [PATCH] [minor] Add tag/release mechanism and drift-prevention check (AX-1735) Co-Authored-By: Claude Sonnet 4.6 --- .github/workflows/release.yml | 83 ++++++++++++++++++++++++++ .github/workflows/validate-version.yml | 31 ++++++++++ VERSION | 1 + 3 files changed, 115 insertions(+) create mode 100644 .github/workflows/release.yml create mode 100644 .github/workflows/validate-version.yml create mode 100644 VERSION diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..38e3654 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,83 @@ +name: Release + +on: + push: + branches: [main] + +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: false + +permissions: + contents: write + +jobs: + release: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: 0 + token: ${{ secrets.GITHUB_TOKEN }} + + - name: Detect release tag in commit message + id: detect + run: | + MSG="${{ github.event.head_commit.message }}" + if echo "$MSG" | grep -qE '\[(major|minor|patch)\]'; then + TAG=$(echo "$MSG" | grep -oE '\[(major|minor|patch)\]' | head -1 | tr -d '[]') + echo "tag=$TAG" >> "$GITHUB_OUTPUT" + echo "triggered=true" >> "$GITHUB_OUTPUT" + else + echo "triggered=false" >> "$GITHUB_OUTPUT" + fi + + - name: Compute next version + if: steps.detect.outputs.triggered == 'true' + id: version + run: | + VERSION=$(cat VERSION) + MAJOR=$(echo "$VERSION" | cut -d. -f1) + MINOR=$(echo "$VERSION" | cut -d. -f2) + PATCH=$(echo "$VERSION" | cut -d. -f3) + case "${{ steps.detect.outputs.tag }}" in + major) NEXT="$((MAJOR + 1)).0.0" ;; + minor) NEXT="${MAJOR}.$((MINOR + 1)).0" ;; + patch) NEXT="${MAJOR}.${MINOR}.$((PATCH + 1))" ;; + esac + echo "version=$NEXT" >> "$GITHUB_OUTPUT" + + - name: Update VERSION and JSON files + if: steps.detect.outputs.triggered == 'true' + run: | + VERSION="${{ steps.version.outputs.version }}" + echo "$VERSION" > VERSION + jq --arg v "$VERSION" '.version = $v' plugins/jfrog/.cursor-plugin/plugin.json > /tmp/plugin.json + mv /tmp/plugin.json plugins/jfrog/.cursor-plugin/plugin.json + jq --arg v "$VERSION" '.metadata.version = $v' .cursor-plugin/marketplace.json > /tmp/marketplace.json + mv /tmp/marketplace.json .cursor-plugin/marketplace.json + + - name: Commit, tag, and push + if: steps.detect.outputs.triggered == 'true' + run: | + git config user.name "github-actions[bot]" + git config user.email "github-actions[bot]@users.noreply.github.com" + git add VERSION plugins/jfrog/.cursor-plugin/plugin.json .cursor-plugin/marketplace.json + git commit -m "Release v${{ steps.version.outputs.version }}" + git push origin main + git tag "v${{ steps.version.outputs.version }}" + git push origin "v${{ steps.version.outputs.version }}" + + - name: Package release artifact + if: steps.detect.outputs.triggered == 'true' + run: zip -r release.zip . --exclude ".git/*" --exclude ".github/*" + + - name: Create GitHub Release + if: steps.detect.outputs.triggered == 'true' + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: | + gh release create "v${{ steps.version.outputs.version }}" \ + release.zip \ + --title "Release v${{ steps.version.outputs.version }}" \ + --generate-notes diff --git a/.github/workflows/validate-version.yml b/.github/workflows/validate-version.yml new file mode 100644 index 0000000..883e037 --- /dev/null +++ b/.github/workflows/validate-version.yml @@ -0,0 +1,31 @@ +name: Validate version + +on: + pull_request: + branches: [main] + +jobs: + validate: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + + - name: Check version consistency + run: | + VERSION=$(cat VERSION) + FAILED=0 + + PLUGIN_VERSION=$(jq -r '.version' plugins/jfrog/.cursor-plugin/plugin.json) + if [ "$VERSION" != "$PLUGIN_VERSION" ]; then + echo "::error::Version mismatch: VERSION=$VERSION but plugins/jfrog/.cursor-plugin/plugin.json.version=$PLUGIN_VERSION" + FAILED=1 + fi + + MARKET_VERSION=$(jq -r '.metadata.version' .cursor-plugin/marketplace.json) + if [ "$VERSION" != "$MARKET_VERSION" ]; then + echo "::error::Version mismatch: VERSION=$VERSION but .cursor-plugin/marketplace.json.metadata.version=$MARKET_VERSION" + FAILED=1 + fi + + [ "$FAILED" -eq 0 ] && echo "All versions consistent: $VERSION" + exit $FAILED diff --git a/VERSION b/VERSION new file mode 100644 index 0000000..7d85683 --- /dev/null +++ b/VERSION @@ -0,0 +1 @@ +0.5.4