Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

scripts: Add publish_release.sh #461

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
60 changes: 60 additions & 0 deletions scripts/publish_release.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
#!/bin/bash

set -e

if [[ $# -lt 4 ]]; then
echo "Usage: $0 <version> <commit> <remote> <release zip file>"
echo "Example: $0 0.1.0 123456 origin release.zip"
echo "run inside the zcbor repository"
exit 1
fi

version=$1
commit=$2
remote=$3
release_zip=$4

if [[ "$(git show $commit:zcbor/VERSION)" != "$version" ]]; then
echo "Version in VERSION file does not match the version provided"
exit 2
fi

if [[ ! "$release_zip" =~ "$version" ]]; then
echo "Release zip file name should contain the version"
exit 3
fi

if [[ ! -f $release_zip ]]; then
echo "Release zip file not found"
exit 4
fi

if [[ -d zcbor-release-files-$version ]]; then
echo "Release files directory (zcbor-release-files-$version) already exists"
exit 5
fi

if ! git merge-base --is-ancestor $remote/main $commit; then
echo "Release commit is not based on upstream main branch"
exit 6
fi

# Create tag
git tag $version $commit
# Push tag
git push $remote $version
# Push commit to main branch
git push $remote $commit:main
# Unzip release files
mkdir zcbor-release-files-$version
unzip $release_zip -d zcbor-release-files-$version
# Create release on GitHub
gh release create $version zcbor-release-files-$version/* --repo $(git remote get-url $remote) --title "zcbor v. $version" --notes "Release notes: [RELEASE_NOTES.md](https://github.com/NordicSemiconductor/zcbor/blob/$version/RELEASE_NOTES.md)

Migration guide: [MIGRATION_GUIDE.md](https://github.com/NordicSemiconductor/zcbor/blob/$version/MIGRATION_GUIDE.md)

Pypi: https://pypi.org/project/zcbor/$version/"
# Create release on Pypi
twine upload --verbose zcbor-release-files-$version/*
# Clean up
rm -rf zcbor-release-files-$version