Skip to content

Commit 918263b

Browse files
committed
chore(cert-tools): Add release instructions
1 parent b07e640 commit 918263b

2 files changed

Lines changed: 98 additions & 0 deletions

File tree

rust/cert-tools/RELEASE.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# Release Process
2+
3+
To release a new version of `cert-tools` the following steps need to be done:
4+
5+
1. Make sure the local `main` branch is up-to-date and in a clean state.
6+
2. Run the `scripts/release_cert-tools.sh` script. This takes care of
7+
- generating the changelog
8+
- updating the `Cargo.toml` version
9+
- raising a PR with the changes
10+
3. Merge the PR.
11+
4. Add the appropriate tag on `main` by running `git tag <TAG> -m <TAG> -s`.
12+
5. Push the tag.

scripts/release_cert-tools.sh

Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
#!/usr/bin/env bash
2+
set -euo pipefail
3+
4+
MESSAGE="# Managed by .scripts\/release_cert-tools.sh"
5+
6+
BUMPED_VERSION=$(git-cliff --config rust/cert-tools/cliff.toml --bumped-version)
7+
CLEANED_BUMPED_VERSION=${BUMPED_VERSION#boil-}
8+
9+
RELEASE_BRANCH="chore/cert-tools-release-$CLEANED_BUMPED_VERSION"
10+
11+
echo "Checking if working directory is clean"
12+
if ! git diff-index --quiet HEAD --; then
13+
echo "Working directory is dirty, aborting" >&2
14+
exit 1
15+
fi
16+
17+
# Prompt the user to confirm their Git identity used to create the commit
18+
GIT_EMAIL=$(git config --includes --get user.email)
19+
GIT_USER=$(git config --includes --get user.name)
20+
21+
echo "The following Git user will be used: $GIT_USER <$GIT_EMAIL>"
22+
echo "Is this correct (Y/n)?"
23+
read -r RESPONSE
24+
25+
if [[ "$RESPONSE" == "y" || "$RESPONSE" == "Y" || -z "$RESPONSE" ]]; then
26+
echo "Proceeding with $GIT_USER <$GIT_EMAIL>"
27+
else
28+
>&2 echo "User not accepted. Exiting."
29+
exit 1
30+
fi
31+
32+
# Check dependencies
33+
gh auth status
34+
git-cliff --version
35+
36+
# Switch to main branch after we validated that the working directory is clean
37+
git switch main
38+
39+
# Make sure we have the latest remote changes locally
40+
git pull
41+
42+
echo "Creating and switching to $RELEASE_BRANCH branch"
43+
git switch -c "$RELEASE_BRANCH"
44+
45+
echo "Generating updated changelog for $BUMPED_VERSION"
46+
git-cliff --config rust/cert-tools/cliff.toml --tag "$BUMPED_VERSION" > rust/cert-tools/CHANGELOG.md
47+
48+
echo "Updating the version to $CLEANED_BUMPED_VERSION in the Cargo.toml file"
49+
sed -E -i "s/^version = .* $MESSAGE$/version = \"$CLEANED_BUMPED_VERSION\" $MESSAGE/" rust/cert-tools/Cargo.toml
50+
cargo check
51+
52+
echo "Committing changes"
53+
# Make sure that there are changes to be committed
54+
if git diff-index --quiet HEAD --; then
55+
echo "No changes to commit"
56+
exit 1
57+
fi
58+
59+
git add rust/cert-tools/CHANGELOG.md rust/cert-tools/Cargo.*
60+
git commit --message "chore(cert-tools): Release $CLEANED_BUMPED_VERSION" --no-verify --gpg-sign
61+
62+
echo "Do you want to proceed with rasing a PR (y/N)?"
63+
read -r RESPONSE
64+
65+
if [[ "$RESPONSE" == "y" || "$RESPONSE" == "Y" ]]; then
66+
echo "Pushing changes and raising PR"
67+
else
68+
>&2 echo "Not pushing. Exiting."
69+
exit 1
70+
fi
71+
72+
CHANGELOG_SUMMARY=$(git-cliff --config rust/cert-tools/cliff.toml --tag "$BUMPED_VERSION" --strip header --unreleased)
73+
PR_BODY=$(mktemp)
74+
echo -e "This PR was raised automatically by a release script. It releases $BUMPED_VERSION:\n$CHANGELOG_SUMMARY" > "$PR_BODY"
75+
76+
git push --set-upstream origin "$RELEASE_BRANCH"
77+
gh pr create --base main \
78+
--title "chore(cert-tools): Release $CLEANED_BUMPED_VERSION" \
79+
--body-file "$PR_BODY" \
80+
--assignee "@me" \
81+
--draft
82+
83+
echo "After merging the PR, make sure to run the following commands to finish up the release:"
84+
echo "git switch main && git pull"
85+
echo "git tag $BUMPED_VERSION -m $BUMPED_VERSION -s"
86+
echo "git push --follow-tags"

0 commit comments

Comments
 (0)