Skip to content

Commit

Permalink
Create tag-release.sh script to tag a release and update README.md.
Browse files Browse the repository at this point in the history
The README.md needs updating so that the labels it refers to exist
in the GitHub Releases. The `tag-release.sh` script should do that.
  • Loading branch information
gerph committed Aug 6, 2023
1 parent ad07688 commit fe778a3
Showing 1 changed file with 48 additions and 0 deletions.
48 changes: 48 additions & 0 deletions crosscompile/tag-release.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
#!/bin/bash
##
# Tag and update a release's links.
#
# We will update the release files to contain the tag for the new
# release, as it will appear. Primarily this means updating the
# README.md to have links to where the release will appear once
# release has been made.
# Then commiting the change, and finally tagging it.
#

set -eo pipefail

tagscriptdir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd -P)"
tagrootdir="$(cd "$tagscriptdir/.." && pwd -P)"

sed_inline_args=(-E -i)
if [[ "$(uname -s)" = 'Darwin' ]] ; then
# On macOS we need to specify the backup filename to sed.
sed_inline_args+=('')
fi

cd "$tagrootdir"

eval $("${tagscriptdir}"/ci-vars --repo .)

if [[ "$CI_BRANCH_VERSION" =~ /-dirty$/ ]] ; then
echo "Branch is dirty. Refusing to continue."
exit 1
fi

sed "${sed_inline_args[@]}" 's!(https://github.com/gerph/riscos-prminxml-tool/releases/download)/[^/]*/(POSIX-PRMinXML|RISCOS-PRMinXML|Example-Output)-.*(\.zip|\.tar\.gz)!\1/GITTAG/\2-GITTAG\3!g' "README.md"
git commit -m "Update README.md links for release" README.md


eval $("${tagscriptdir}"/ci-vars --repo .)

TAG="v$CI_BRANCH_VERSION"
echo "New tag will be: $TAG"

sed "${sed_inline_args[@]}" "s!GITTAG!$TAG!g" README.md
git commit -m "Update README.md links for release $TAG" --amend README.md
git tag -f "$TAG"

echo "---- Update complete ----"
echo "Now you must push the changes:"
echo " git push origin $CI_BRANCH"
echo " git push origin $TAG"

0 comments on commit fe778a3

Please sign in to comment.