frankenphp/release.sh

50 lines
1.3 KiB
Bash
Raw Normal View History

#!/usr/bin/env bash
# Creates the tags for the library and the Caddy module.
set -o nounset
set -o errexit
trap 'echo "Aborting due to errexit on line $LINENO. Exit code: $?" >&2' ERR
set -o errtrace
set -o pipefail
set -o xtrace
2024-08-04 12:05:54 +00:00
if ! type "git" >/dev/null; then
echo "The \"git\" command must be installed."
exit 1
fi
2024-08-04 12:05:54 +00:00
if ! type "gh" >/dev/null; then
echo "The \"gh\" command must be installed."
exit 1
2023-12-18 23:14:11 +00:00
fi
if [[ $# -ne 1 ]]; then
2024-08-04 12:05:54 +00:00
echo "Usage: ./release.sh version" >&2
exit 1
fi
# Adapted from https://semver.org/#is-there-a-suggested-regular-expression-regex-to-check-a-semver-string
if [[ ! $1 =~ ^(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)(-((0|[1-9][0-9]*|[0-9]*[a-zA-Z-][0-9a-zA-Z-]*)(\.(0|[1-9][0-9]*|[0-9]*[a-zA-Z-][0-9a-zA-Z-]*))*))?(\+([0-9a-zA-Z-]+(\.[0-9a-zA-Z-]+)*))?$ ]]; then
2024-08-04 12:05:54 +00:00
echo "Invalid version number: $1" >&2
exit 1
fi
git checkout main
git pull
cd caddy/
go get "github.com/dunglas/frankenphp@v$1"
cd -
2023-09-20 13:26:15 +00:00
git commit -S -a -m "chore: prepare release $1" || echo "skip"
git tag -s -m "Version $1" "v$1"
git tag -s -m "Version $1" "caddy/v$1"
git push --follow-tags
2023-12-18 23:14:11 +00:00
tags=$(git tag --list --sort=-version:refname 'v*')
2024-08-04 12:05:54 +00:00
previous_tag=$(awk 'NR==2 {print;exit}' <<<"${tags}")
2023-12-18 23:14:11 +00:00
gh release create --draft --generate-notes --latest --notes-start-tag "${previous_tag}" --verify-tag "v$1"