forked from php/frankenphp
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrelease.sh
More file actions
executable file
·52 lines (44 loc) · 1.66 KB
/
Copy pathrelease.sh
File metadata and controls
executable file
·52 lines (44 loc) · 1.66 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
#!/usr/bin/env bash
# Dispatches the Release workflow, which does the real work
# (PGO refresh, Caddy module bump, commit, tag, push, draft release,
# Homebrew formula bump). See .github/workflows/release.yaml.
set -o nounset
set -o errexit
set -o errtrace # so the ERR trap fires inside functions/subshells too
set -o pipefail
trap 'echo "Aborting on line $LINENO. Exit: $?" >&2' ERR
for cmd in git gh; do
if ! command -v "$cmd" >/dev/null; then
echo "The \"$cmd\" command must be installed." >&2
exit 1
fi
done
if [[ $# -ne 1 ]]; then
echo "Usage: ./release.sh version" >&2
exit 1
fi
# Cheap operator-side guards; release.yaml re-validates the version.
if [[ "$(git branch --show-current 2>/dev/null)" != "main" ]]; then
echo "You must be on the main branch to dispatch a release." >&2
exit 1
fi
if [[ -n "$(git status --porcelain)" ]]; then
echo "Working tree is not clean. Commit or stash your changes first." >&2
exit 1
fi
git fetch --quiet --tags origin main
local_head="$(git rev-parse HEAD)"
remote_head="$(git rev-parse origin/main)"
if [[ "$local_head" != "$remote_head" ]]; then
if git merge-base --is-ancestor HEAD origin/main; then
echo "Local main is behind origin/main. Pull first." >&2
elif git merge-base --is-ancestor origin/main HEAD; then
echo "Local main is ahead of origin/main. Push your commits or reset to origin/main before releasing." >&2
else
echo "Local main has diverged from origin/main. Reconcile with pull/rebase/reset before releasing." >&2
fi
exit 1
fi
gh workflow run release.yaml --ref main -f version="$1"
echo "Release workflow dispatched for v$1."
echo "Watch runs: gh run list --workflow=release.yaml --event=workflow_dispatch"