-
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.
Merge pull request #10 from flexanalytics/feature/stable_branch_githu…
…b_actions add github action to auto-update stable tags on release
- Loading branch information
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: Update Stable Tags | ||
|
||
on: | ||
release: | ||
types: [published] | ||
|
||
permissions: | ||
contents: write # Grants read/write access to the repository content, including pushing tags | ||
|
||
jobs: | ||
update-stable-tags: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v3 | ||
|
||
- name: Set up Git | ||
run: | | ||
git config user.name "github-actions[bot]" | ||
git config user.email "github-actions[bot]@users.noreply.github.com" | ||
- name: Extract Release Version | ||
id: extract_version | ||
run: | | ||
version="${GITHUB_REF##*/}" | ||
major=$(echo $version | cut -d. -f1) | ||
minor=$(echo $version | cut -d. -f2) | ||
patch=$(echo $version | cut -d. -f3) | ||
echo "::set-output name=major::$major" | ||
echo "::set-output name=minor::$minor" | ||
echo "::set-output name=patch::$patch" | ||
- name: Update Major Stable Tag | ||
if: steps.extract_version.outputs.major == '1' | ||
run: | | ||
git tag -f v${{ steps.extract_version.outputs.major }}-stable | ||
git push origin v${{ steps.extract_version.outputs.major }}-stable --force | ||
- name: Update Minor Stable Tag | ||
if: steps.extract_version.outputs.minor != '' | ||
run: | | ||
git tag -f v${{ steps.extract_version.outputs.major }}.${{ steps.extract_version.outputs.minor }}-stable | ||
git push origin v${{ steps.extract_version.outputs.major }}.${{ steps.extract_version.outputs.minor }}-stable --force | ||
- name: Notify Success | ||
if: always() | ||
run: echo "Tags have been updated successfully." | ||
|
||
- name: Error Handling | ||
if: failure() | ||
run: echo "Failed to update tags." |