-
Notifications
You must be signed in to change notification settings - Fork 79
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactor 'set IS_VERSION_TAG' into determine-tags-action composite action
- Loading branch information
Robert Schardt
authored and
Robert Schardt
committed
Sep 20, 2024
1 parent
1bc955d
commit 54f3e18
Showing
2 changed files
with
52 additions
and
29 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,30 @@ | ||
name: 'determine-tags-action' | ||
description: 'Determine version and latest tags' | ||
runs: | ||
using: "composite" | ||
steps: | ||
- name: "set IS_VERSION_TAG" | ||
run: | | ||
echo "IS_VERSION_TAG=${{ github.ref_type == 'tag' && startsWith(github.ref_name, 'v') }}" >> $GITHUB_ENV | ||
# set defaults | ||
echo "IS_LATEST_TAG=false" >> $GITHUB_ENV | ||
- name: "set IS_LATEST_TAG" | ||
if: ( env.IS_VERSION_TAG ) | ||
run: | | ||
# find the latest version that is not ourself | ||
export LATEST_VERSION=$(git tag -l | grep -v '${{ github.ref_name }}' | sort -r --version-sort) | ||
# get major minor patch versions | ||
IFS='.' read -r latest_major latest_minor latest_patch << EOF | ||
$LATEST_VERSION | ||
EOF | ||
IFS='.' read -r tag_major tag_minor tag_patch << EOF | ||
${{ github.ref_name }} | ||
EOF | ||
# remove leading v | ||
latest_major=$(echo $latest_major | cut -c2-) | ||
tag_major=$(echo $tag_major | cut -c2-) | ||
echo "$tag_major >= $latest_major" | ||
if [[ $tag_major -ge $latest_major && ($tag_minor -ne 0 || $tag_patch -ne 0) ]]; then | ||
# set this tag to latest and stable | ||
echo "IS_LATEST_TAG=true" >> $GITHUB_ENV | ||
fi |
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