Skip to content

Commit

Permalink
add check that latest tag is truly a later version
Browse files Browse the repository at this point in the history
  • Loading branch information
eschutho committed Oct 10, 2020
1 parent e8d93bf commit ceb8e43
Show file tree
Hide file tree
Showing 2 changed files with 77 additions and 3 deletions.
76 changes: 75 additions & 1 deletion .github/workflows/latest-release-tag.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,90 @@ on:
types: [published] # This makes it run only when a new released is published

jobs:
run:
latest-release:
name: Add/update tag to new release
runs-on: ubuntu-latest

steps:
- name: Checkout repository
uses: actions/checkout@v2

- name: Check for latest tag
id: latest-tag
run: |
LATEST_TAG=$(git show-ref --tags -d | grep latest^{} | sed 's/refs\/tags\/latest^{}//') || echo 'not found'
# if 'latest' tag doesn't exist, then set this commit to latest
if [[ -z "$LATEST_TAG" ]]
then
# move on to next task
echo "there are no latest tags yet, so I'm going to start by tagging this sha as the latest"
exit 0
fi
TAGS=$(git show-ref --tags -d | grep $LATEST_TAG)
## get all tags that use the same sha as the latest tag
IFS=$'\n'
LATEST_TAGS=($TAGS)
## loop over those tags and only take action on the one that isn't tagged 'latest'
## that one will have the version number tag
for (( i=0; i<${#LATEST_TAGS[@]}; i++ ))
do
if [[ ${LATEST_TAGS[$i]} != *"latest"* ]]
then
## extract just the version from this tag
LATEST_RC_TAG=$(echo "${LATEST_TAGS[$i]}" | sed -e 's,.* refs/tags/,,' -e 's/rc//')
echo "The current release with the latest tag is version ${LATEST_RC_TAG}"
## remove the sha from the latest tag and split into an array- split at the dot
IFS=$'.'
LATEST_RC_TAG_SPLIT=(${LATEST_RC_TAG})
## remove the 'rc' from the current tag if it exists and split into an array at the dot
THIS_TAG=($(echo ${{ github.event.release.tag_name }} | sed 's/rc//')) || echo 'not found'
# no tag name exists, then exit and don't move on
if [[ -z "$THIS_TAG" ]]
then
echo "no tag was passed in with this action. Not tagging anything"
echo "::set-env name=skip_tag::true"
exit 0
fi
## at this point the array should have length of three. If it doesn't, don't tag it, as it's clearly not a version tag.
if [[ ${#THIS_TAG[@]} != 3 ]]
then
echo "This tag does not contain a semantic version number. Skipping."
echo "::set-env name=skip_tag::true"
exit 0
fi
for (( j=0; j<${#THIS_TAG[@]}; j++ ))
do
## if this value is greater than the latest release, then tag it, if it's lower, then stop, if it's
## the same then move on to the next index
if [[ ${THIS_TAG[$j]} -gt ${LATEST_RC_TAG_SPLIT[$j]} ]]
then
echo "This release tag ${{ github.event.release.tag_name }} is the latest. Tagging it"
# move on to next task
exit 0
elif [[ ${THIS_TAG[$j]} -lt ${LATEST_RC_TAG_SPLIT[$j]} ]]
then
break
fi
done
fi
done
echo "This release tag ${{ github.event.release.tag_name }} is not the latest. Not tagging."
# if you've gotten this far, then we don't want to run any tags in the next step
echo "::set-env name=skip_tag::true"
- name: Run latest-tag
uses: EndBug/latest-tag@latest
if: (! env.skip_tag )
with:
description: Superset latest release
tag-name: latest
Expand Down
4 changes: 2 additions & 2 deletions RELEASING/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -135,8 +135,6 @@ Commit the change with the version number, then git tag the version with the rel
git push upstream ${SUPERSET_VERSION_RC}
```

At this point, a git action will run that will automatically tag this release as `latest` so that the most recent release can be referenced simply by this tag instead of looking up the version number.

## Preparing the release candidate

The first step of preparing an Apache Release is packaging a release candidate
Expand Down Expand Up @@ -323,6 +321,8 @@ tag corresponding with the new version. Go to https://github.com/apache/incubato
click the 3-dot icon and select `Create Release`, paste the content of the ANNOUNCE thread in the
release notes, and publish the new release.

At this point, a GitHub action will run that will check whether this release's version number is higher than the current 'latest' release. If that condition is true, this release sha will automatically be tagged as `latest` so that the most recent release can be referenced simply by using the 'latest' tag instead of looking up the version number. The existing version number tag will still exist, and can also be used for reference.

## Post release

#### Refresh documentation website
Expand Down

0 comments on commit ceb8e43

Please sign in to comment.