From 1106e6c413308295c28bcb68c91e7dea14c7de4b Mon Sep 17 00:00:00 2001 From: Akshay Kumar Date: Fri, 20 Feb 2026 01:24:40 +0530 Subject: [PATCH] test approvals --- .github/workflows/release.yml | 71 +++++++++++++++++++++++++++++++++++ 1 file changed, 71 insertions(+) create mode 100644 .github/workflows/release.yml diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 000000000..5d1799fd5 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,71 @@ +name: Release + +on: + workflow_dispatch: + inputs: + tag: + description: 'Tag to release or revert to (e.g., v3.2.1)' + required: true + type: string + revert: + description: 'Revert releases/vX to this existing tag?' + required: false + type: boolean + default: false + +jobs: + release: + runs-on: ubuntu-latest + permissions: + contents: write + + steps: + - name: Validate tag format + run: | + TAG="${{ inputs.tag }}" + if [[ ! "$TAG" =~ ^v[0-9]+\.[0-9]+\.[0-9]+$ ]]; then + echo "❌ Invalid tag format: $TAG. Expected: v.." + exit 1 + fi + + - name: Parse version + id: version + run: | + TAG="${{ inputs.tag }}" + MAJOR=$(echo "$TAG" | cut -d. -f1) + echo "major=${MAJOR}" >> $GITHUB_OUTPUT + echo "branch=releases/${MAJOR}" >> $GITHUB_OUTPUT + + - name: Checkout + uses: actions/checkout@v4 + with: + ref: ${{ inputs.revert == true && inputs.tag || steps.version.outputs.branch }} + fetch-depth: 0 + + - name: Configure Git + run: | + git config user.name "github-actions[bot]" + git config user.email "github-actions[bot]@users.noreply.github.com" + + - name: Release new tag + if: ${{ inputs.revert == false }} + run: | + MAJOR="${{ steps.version.outputs.major }}" + + # Update the major tag (e.g., v3) to point to same commit as inputs.tag + git tag -fa ${MAJOR} -m "Release ${{ inputs.tag }}" + git push origin ${MAJOR} --force + + + echo "## ✅ Release ${{ inputs.tag }}" >> $GITHUB_STEP_SUMMARY + echo "- Tag: \`${{ inputs.tag }}\`" >> $GITHUB_STEP_SUMMARY + echo "- Branch: \`${{ steps.version.outputs.branch }}\`" >> $GITHUB_STEP_SUMMARY + + - name: Revert to existing tag + if: ${{ inputs.revert == true }} + run: | + BRANCH="${{ steps.version.outputs.branch }}" + git push origin ${{ inputs.tag }}:refs/heads/${BRANCH} --force + + echo "## ⏪ Reverted ${BRANCH} to ${{ inputs.tag }}" >> $GITHUB_STEP_SUMMARY + echo "- \`${BRANCH}\` now points to \`${{ inputs.tag }}\`" >> $GITHUB_STEP_SUMMARY \ No newline at end of file