-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add GH action to tag the release branch
- Loading branch information
1 parent
45f5133
commit 692cf7e
Showing
1 changed file
with
52 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
name: Tag and Release | ||
|
||
on: | ||
workflow_dispatch: | ||
inputs: | ||
version: | ||
description: 'Version tag (e.g., v1.0.0)' | ||
required: true | ||
target_branch: | ||
description: 'Branch to tag (e.g., release)' | ||
default: release | ||
required: true | ||
|
||
jobs: | ||
tag_and_release: | ||
name: Tag and Release | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Checkout repository | ||
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 | ||
|
||
- name: Check if tag already exists | ||
id: check_tag | ||
run: | | ||
if git rev-parse "refs/tags/${{ github.event.inputs.version }}" >/dev/null 2>&1; then | ||
echo "Tag already exists" | ||
echo "tag_exists=true" >> "$GITHUB_OUTPUT" | ||
fi | ||
- name: Abort if tag exists | ||
if: steps.check_tag.outputs.tag_exists == 'true' | ||
run: exit 1 | ||
|
||
- name: Create and push tag | ||
run: | | ||
git config user.name "github-actions[bot]" | ||
git config user.email "github-actions[bot]@users.noreply.github.com" | ||
git fetch origin ${{ github.event.inputs.target_branch }} | ||
git checkout ${{ github.event.inputs.target_branch }} | ||
git tag ${{ github.event.inputs.version }} | ||
git push origin ${{ github.event.inputs.version }} | ||
- name: Create GitHub Release | ||
uses: ncipollo/release-action@cdcc88a9acf3ca41c16c37bb7d21b9ad48560d87 # v1.15.0 | ||
with: | ||
tag: ${{ github.event.inputs.version }} | ||
name: Release ${{ github.event.inputs.version }} | ||
body: "Automated release of version ${{ github.event.inputs.version }}" | ||
draft: false | ||
prerelease: false | ||
token: ${{ secrets.GITHUB_TOKEN }} |