diff --git a/.github/workflows/gradle-release.yml b/.github/workflows/gradle-release.yml index e0667048fec..a07282bb415 100644 --- a/.github/workflows/gradle-release.yml +++ b/.github/workflows/gradle-release.yml @@ -1,4 +1,4 @@ -name: Create Release +name: Create Release with Manual Tag on: push: @@ -7,7 +7,7 @@ on: workflow_dispatch: inputs: tag_name: - description: 'Tag name for the release (e.g., v6.09.08 for production, v6.09.08-SNAPSHOT for nightly, v6.09.08.RC1 for release candidate). Must already exist.' + description: 'Tag name for the release (e.g., v6.09.08 for production, v6.09.08-SNAPSHOT for nightly, v6.09.08.RC1 for release candidate). The tag will be created on the selected branch.' required: true type: string prerelease: @@ -26,7 +26,33 @@ jobs: steps: - uses: actions/checkout@v4 with: - ref: ${{ inputs.tag_name || github.ref }} + ref: ${{ github.ref }} + + - name: Create and push tag + if: ${{ github.event_name == 'workflow_dispatch' }} + env: + TAG_NAME: ${{ inputs.tag_name }} + run: | + if git ls-remote --exit-code --tags origin "refs/tags/${TAG_NAME}" > /dev/null 2>&1; then + echo "::error::Tag '${TAG_NAME}' already exists on the remote." + echo "" + echo "=========================================" + echo " HOW TO FIX" + echo "=========================================" + echo "" + echo "If you want to re-release this tag, delete it first:" + echo " git tag -d ${TAG_NAME}" + echo " git push origin :refs/tags/${TAG_NAME}" + echo "" + echo "Then re-run this workflow." + echo "=========================================" + exit 1 + fi + git config user.name "github-actions[bot]" + git config user.email "41898282+github-actions[bot]@users.noreply.github.com" + git tag "${TAG_NAME}" + git push origin "${TAG_NAME}" + echo "✅ Tag '${TAG_NAME}' created and pushed from $(git rev-parse --short HEAD) on branch ${GITHUB_REF_NAME}." - name: Validate tag matches gradle.properties version run: |