-
Notifications
You must be signed in to change notification settings - Fork 16
Expand file tree
/
Copy pathcreate-release.sh
More file actions
executable file
·60 lines (52 loc) · 1.57 KB
/
Copy pathcreate-release.sh
File metadata and controls
executable file
·60 lines (52 loc) · 1.57 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
53
54
55
56
57
58
59
60
#!/usr/bin/env bash
set -eu -o pipefail
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" >/dev/null && pwd)"
cd "$SCRIPT_DIR/.."
version=${1:-}
if [[ -z "$version" ]]; then
echo "USAGE: $0 version" >&2
exit 1
fi
waitForPr() {
local pr=$1
while true; do
if gh pr view "$pr" | grep -q 'MERGED'; then
break
fi
echo "Waiting for PR to be merged..."
sleep 5
done
}
# ensure we are up-to-date
uncommitted_changes=$(git diff --compact-summary)
if [[ -n "$uncommitted_changes" ]]; then
echo -e "There are uncommitted changes, exiting:\n${uncommitted_changes}" >&2
exit 1
fi
git pull --rebase git@github.com:Mic92/ssh-to-age main
# make sure tag does not exist
if git tag -l | grep -q "^${version}\$"; then
echo "Tag ${version} already exists, exiting" >&2
exit 1
fi
sed -i -e "s!version = \".*\"!version = \"${version}\"!" default.nix
git add default.nix
nix build
git branch -D "release-${version}" || true
git checkout -b "release-${version}"
git commit -m "bump version ${version}"
git push origin "release-${version}"
pr_url=$(gh pr create \
--base main \
--head "release-${version}" \
--title "Release ${version}" \
--body "Release ${version} of ssh-to-age")
# Extract PR number from URL
pr_number=$(echo "$pr_url" | grep -oE '[0-9]+$')
# Enable auto-merge with specific merge method and delete branch
gh pr merge "$pr_number" --auto --merge --delete-branch
git checkout main
waitForPr "release-${version}"
git pull --rebase git@github.com:Mic92/ssh-to-age main
git tag -a "${version}" -m "Release ${version}"
git push origin "refs/tags/${version}"