Skip to content

Commit

Permalink
use better method to determine branch [citest skip] (linux-system-rol…
Browse files Browse the repository at this point in the history
…es#293)

* use better method to determine branch [citest skip]

* fix quoting
  • Loading branch information
richm authored Jul 27, 2022
1 parent 3d8fdf9 commit 1b7e58b
Showing 1 changed file with 26 additions and 16 deletions.
42 changes: 26 additions & 16 deletions .github/workflows/changelog_to_tag.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# yamllint disable rule:line-length
name: Pushing CHANGELOG.md triggers tagging
name: Pushing CHANGELOG.md triggers tag, release, and Galaxy publish
on: # yamllint disable-line rule:truthy
push:
branches:
Expand All @@ -10,7 +10,7 @@ on: # yamllint disable-line rule:truthy
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # This token is provided by Actions, you do not need to create your own token
jobs:
tagging:
tag_release_publish:
runs-on: ubuntu-latest
steps:
- name: checkout PR
Expand All @@ -19,30 +19,40 @@ jobs:
id: tag
run: |
set -euxo pipefail
pat='\[[0-9]*\.[0-9]*\.[0-9]*\] - [0-9\-]*'
echo GITHUB_REF = "${GITHUB_REF:-none}"
echo GITHUB_REF_NAME = "${GITHUB_REF_NAME:-none}"
print=false
cat CHANGELOG.md | while read -r line; do
if [[ "$line" =~ $pat ]] && [[ "$print" == false ]]; then
echo "$line"
print=true
elif [[ "$line" =~ $pat ]] && [[ "$print" == true ]]; then
break
elif [[ "$print" == true ]]; then
while read -r line; do
if [[ "$line" =~ ^\[([0-9]+\.[0-9]+\.[0-9]+)\]\ -\ [0-9-]+ ]]; then
if [ "$print" = false ]; then
_tagname="${BASH_REMATCH[1]}"
echo "$line"
print=true
else
break
fi
elif [ "$print" = true ]; then
echo "$line"
fi
done > ./.tagmsg.txt
_tagname=$( grep -m 1 "[0-9]*\.[0-9]*\.[0-9]*" CHANGELOG.md | \
sed -e "s/^.*\[\([0-9]*\.[0-9]*\.[0-9]*\)\].*/\1/" )
done < CHANGELOG.md > ./.tagmsg.txt
git fetch --all --tags
for t in $( git tag -l ); do
if [[ $t == "$_tagname" ]]; then
echo INFO: tag $t already exists
if [ "$t" = "$_tagname" ]; then
echo INFO: tag "$t" already exists
exit 1
fi
done
# Get the main branch name, "master" or "main".
# Get the main branch name
_branch=$( git branch -r | grep -o 'origin/HEAD -> origin/.*$' | \
awk -F'/' '{print $3}' )
if [ -z "$_branch" ]; then
_branch=$( git branch --points-at HEAD --no-color --format='%(refname:short)' )
fi
if [ -z "$_branch" ]; then
echo ERROR: unable to determine main branch
git branch -a
exit 1
fi
echo ::set-output name=tagname::"$_tagname"
echo ::set-output name=branch::"$_branch"
- name: Create tag
Expand Down

0 comments on commit 1b7e58b

Please sign in to comment.