Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 36 additions & 2 deletions scripts/create-release.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,17 @@ if [[ "$(git symbolic-ref --short HEAD)" != "main" ]]; then
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
Expand All @@ -28,11 +39,34 @@ if [[ "$unpushed_commits" != "" ]]; then
echo -e "\nThere are unpushed changes, exiting:\n$unpushed_commits" >&2
exit 1
fi
# 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}\"!" Cargo.toml
cargo build
git add Cargo.lock Cargo.toml
git branch -D "release-${version}" || true
git checkout -b "release-${version}"
nix flake check -vL
git commit -m "bump version nix-ld ${version}"
git tag "${version}"
git push origin "release-${version}"
pr_url=$(gh pr create \
--base main \
--head "release-${version}" \
--title "Release ${version}" \
--body "Release ${version} of nix-ld")

echo "now run 'git push --tags origin main'"
# 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 git@github.com:nix-community/nix-ld main
git tag "${version}"
git push --tags origin
gh release create "${version}" --draft --title "${version}" --notes ""
Loading