-
Notifications
You must be signed in to change notification settings - Fork 97
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
207 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,97 @@ | ||
#!/bin/sh | ||
|
||
set -e | ||
|
||
DOCKER_IMAGE=swiftnav/libsbp-build:2023-12-19 | ||
RUN_DOCKER="docker run -it --rm -v $PWD:/mnt/workspace -t ${DOCKER_IMAGE}" | ||
VERSION=$(./scripts/get_release_version.py $(git describe --match 'v*' --always --tags)) | ||
|
||
if [ $# -ne 0 ]; then | ||
VERSION=$1 | ||
shift | ||
fi | ||
|
||
if [ -z "${CHANGELOG_GITHUB_TOKEN}" ]; then | ||
echo "You must set CHANGELOG_GITHUB_TOKEN in your environment before running this command" | ||
exit 1 | ||
fi | ||
|
||
git diff --exit-code >/dev/null 2>&1 | ||
if [ $? -ne 0 ]; then | ||
echo "Working directory is not clean. Remove any and all changes before running this command" | ||
exit 1 | ||
fi | ||
|
||
echo "Releasing libsbp version ${VERSION}" | ||
|
||
echo "Creating initial commit and tag" | ||
git commit --allow-empty -m "Release ${VERSION}" | ||
git tag -a ${VERSION} -m "Version ${VERSION} of libsbp." | ||
|
||
echo "Building python" | ||
${RUN_DOCKER} make gen-python | ||
|
||
echo "Updating tag" | ||
git add . | ||
git commit --amend -a -m "Release ${VERSION}" | ||
git tag -f -a ${VERSION} -m "Version ${VERSION} of libsbp." | ||
|
||
echo "Building language bindings" | ||
${RUN_DOCKER} make gen-java gen-javascript gen-protobuf | ||
${RUN_DOCKER} make gen-c gen-haskell gen-javascript gen-rust | ||
|
||
echo "Updating tag" | ||
git add . | ||
git commit --amend -a -m "Release ${VERSION}" | ||
git tag -f -a ${VERSION} -m "Version ${VERSION} of libsbp." | ||
|
||
echo "Rebuilding javascript" | ||
${RUN_DOCKER} make gen-javascript | ||
${RUN_DOCKER} make gen-javascript | ||
|
||
echo "Updating tag" | ||
git add . | ||
git commit --amend -a -m "Release ${VERSION}" | ||
git tag -f -a ${VERSION} -m "Version ${VERSION} of libsbp." | ||
|
||
echo "Buliding kaitai" | ||
${RUN_DOCKER} make gen-kaitai | ||
|
||
echo "Updating tag" | ||
git add . | ||
git commit --amend -a -m "Release ${VERSION}" | ||
git tag -f -a ${VERSION} -m "Version ${VERSION} of libsbp." | ||
|
||
echo "Building documentation" | ||
${RUN_DOCKER} make docs | ||
|
||
echo "Updating tag" | ||
git add . | ||
git commit --amend -a -m "Release ${VERSION}" | ||
git tag -f -a ${VERSION} -m "Version ${VERSION} of libsbp." | ||
|
||
echo "Generating changelog" | ||
make release | ||
./scripts/merge_changelogs.py ${VERSION} | ||
rm -f DRAFT_CHANGELOG.md | ||
|
||
echo "Updating tag" | ||
git add . | ||
git commit --amend -a -m "Release ${VERSION}" | ||
git tag -f -a ${VERSION} -m "Version ${VERSION} of libsbp." | ||
|
||
git diff HEAD~1 | ||
|
||
cat <<EOF | ||
A new commit and tag has been created. Look at the above diff and verify the contents. If everything looks good you can push to master straight away. | ||
If there are any mistakes now is the time to correct them. Make any changes which are required then update the tag by running: | ||
git add <files> | ||
git commit --amend -a -m "Release ${VERSION}" | ||
git tag -f -a ${VERSION} -m "Version ${VERSION} of libsbp." | ||
Once you have fixed everything you can push to master | ||
Once pushed prepare for the next release by running ./scripts/prep_for_next_release.sh | ||
EOF |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
#!/usr/bin/env python | ||
import sys | ||
|
||
major, minor, patch = sys.argv[1].split(".")[:3] | ||
if "-" in patch: | ||
patch = patch.split("-")[0] | ||
print(f"{major}.{minor}.{int(patch) + 1}") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
#!/usr/bin/env python | ||
import re | ||
import sys | ||
from datetime import datetime | ||
|
||
with open("DRAFT_CHANGELOG.md", "r") as f: | ||
draft = f.readlines() | ||
|
||
# The first 4 lines are just the title and "unreleased" headers which we will recreate later | ||
draft = draft[4:] | ||
|
||
# The first line should now be the first real line of the "unreleased" section which is always a link to the full changelog. Find the next heading and discard everything afterwards | ||
assert draft[0].startswith("[Full Changelog]") | ||
|
||
for i in range(1, len(draft)): | ||
if draft[i].startswith("## [v"): | ||
draft = draft[: i - 1] | ||
break | ||
|
||
proposed = [ | ||
f"## [{sys.argv[1]}](https://github.com/swift-nav/libsbp/tree/{sys.argv[1]}) ({datetime.today().strftime('%Y-%m-%d')})\n", | ||
"\n", | ||
] | ||
|
||
# Strip out anything which looks like a Jira ticket number | ||
for i in range(len(draft)): | ||
proposed.append(re.sub(r"\\\[[A-Z]*-[0-9]*\\\](?=[^(])", r"", draft[i])) | ||
proposed.append("\n") | ||
|
||
print("Proposed new changelog section") | ||
print("\n".join(proposed)) | ||
|
||
with open("CHANGELOG.md", "r") as f: | ||
changelog = f.readlines() | ||
|
||
with open("CHANGELOG.md", "w") as f: | ||
# Keep the first 2 lines from the original changelog | ||
f.writelines(changelog[0:2]) | ||
|
||
# Then the new section | ||
f.writelines(proposed) | ||
|
||
# Then the rest of the original | ||
f.writelines(changelog[2:]) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
#!/bin/sh | ||
|
||
set -e | ||
|
||
DOCKER_IMAGE=swiftnav/libsbp-build:2023-12-19 | ||
RUN_DOCKER="docker run -it --rm -v $PWD:/mnt/workspace -t ${DOCKER_IMAGE}" | ||
VERSION=$(./scripts/get_release_version.py $(git describe --match 'v*' --always --tags)) | ||
|
||
git diff --exit-code >/dev/null 2>&1 | ||
if [ $? -ne 0 ]; then | ||
echo "Working directory is not clean. Remove any and all changes before running this command" | ||
exit 1 | ||
fi | ||
|
||
echo "Creating initial commit" | ||
git commit --allow-empty -m "prep for next release #no_auto_pr" | ||
|
||
echo "Building python" | ||
${RUN_DOCKER} make gen-python | ||
|
||
echo "Updating commit" | ||
git add . | ||
git commit --amend -a -m "prep for next release #no_auto_pr" | ||
|
||
echo "Building language bindings" | ||
${RUN_DOCKER} make gen-java gen-javascript gen-protobuf | ||
${RUN_DOCKER} make gen-c gen-haskell gen-javascript gen-rust | ||
|
||
echo "Updating commit" | ||
git add . | ||
git commit --amend -a -m "prep for next release #no_auto_pr" | ||
|
||
echo "Rebuilding javascript" | ||
${RUN_DOCKER} make gen-javascript | ||
${RUN_DOCKER} make gen-javascript | ||
|
||
echo "Updating commit" | ||
git add . | ||
git commit --amend -a -m "prep for next release #no_auto_pr" | ||
|
||
echo "Buliding kaitai" | ||
${RUN_DOCKER} make gen-kaitai | ||
|
||
echo "Updating commit" | ||
git add . | ||
git commit --amend -a -m "prep for next release #no_auto_pr" | ||
|
||
git diff HEAD~1 | ||
|
||
cat <<EOF | ||
A new commit and tag has been created. Look at the above diff and verify the contents. If everything looks good you can push to master straight away. | ||
If there are any mistakes now is the time to correct them. Make any changes which are required then update the tag by running: | ||
git add <files> | ||
git commit --amend -a -m "prep for next release #no_auto_pr" | ||
Once you have fixed everything you can push to master | ||
EOF |