Skip to content

Commit 4c4ed62

Browse files
authored
Merge pull request #426 from ExaWorks/update_release_process
This updates the release script to ensure some sanity in the environm…
2 parents d1ba84c + a30098b commit 4c4ed62

File tree

4 files changed

+93
-69
lines changed

4 files changed

+93
-69
lines changed

.github/workflows/build-website.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ name: build-website
22

33
on:
44
push:
5-
branches: [ main, web_site ]
5+
branches: [ main, web_site, 'releases/**' ]
66

77
jobs:
88
publish:

Makefile

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -79,10 +79,3 @@ install:
7979
.PHONY: develop
8080
develop:
8181
$(PYTHON) setup.py develop
82-
83-
84-
.PHONY: tag-and-release
85-
tag-and-release: ## create a tag in git. to run, do a 'make VERSION="version string" tag-and-release
86-
./tag_and_release.sh create_tag $(VERSION)
87-
./tag_and_release.sh package
88-
./tag_and_release.sh release

release.sh

Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
#!/bin/bash
2+
3+
# This script does the following:
4+
# - does some sanity checks
5+
# - updates RELEASE and src/psij/version.py
6+
# - commits and pushes the version files
7+
# - creates a release tag
8+
# - builds packages
9+
# - pushes said packages to PyPi
10+
# - triggers github workflows to rebuild the web page (including documentation)
11+
12+
set -e
13+
14+
error() {
15+
echo $@
16+
exit 1
17+
}
18+
19+
if [ "$1" == "" ]; then
20+
error "Missing required version argument"
21+
else
22+
TARGET_VERSION="$1"
23+
fi
24+
25+
# Ensure that we are on the main branch
26+
CRT_BRANCH=`git rev-parse --abbrev-ref HEAD`
27+
28+
if [ "$CRT_BRANCH" != "main" ]; then
29+
error "Must be on the main branch to make a release."
30+
fi
31+
32+
STATUS=`git status --untracked-files=no --porcelain`
33+
34+
# Ensure current dir is clean
35+
if [ ! -z "$STATUS" ]; then
36+
error "Working directory is not clean. Please run this script on a clean checkout."
37+
echo
38+
fi
39+
40+
# Make sure version in newer than other releases
41+
TAGS=`git tag`
42+
if echo "$TAGS" | grep "$TARGET_VERSION" 2>&1 >/dev/null; then
43+
error "Version $TARGET_VERSION is already tagged."
44+
fi
45+
46+
LAST=`echo -e "$TAGS\n$TARGET_VERSION" | sed '/^\s*$/d' | sort -V | tail -n 1`
47+
if [ "$LAST" != "$TARGET_VERSION" ]; then
48+
error "Version $TARGET_VERSION is lower than the latest tagged version ($LAST)."
49+
fi
50+
51+
echo "This will tag and release psij-python to version $TARGET_VERSION."
52+
echo -n "Type 'yes' if you want to continue: "
53+
read REPLY
54+
55+
if [ "$REPLY" != "yes" ]; then
56+
error "Release canceled."
57+
fi
58+
59+
# There are mutable operations from here on
60+
61+
echo "Creating release branch"
62+
git checkout -b "releases/$TARGET_VERSION"
63+
64+
# Update the two version files and push them
65+
echo "Updating version and tagging..."
66+
67+
echo -n "$TARGET_VERSION" > RELEASE
68+
cat <<EOF >src/psij/version.py
69+
"""This module stores the current version of this library."""
70+
71+
# Do not change this file manually. It is updated automatically by the release script.
72+
VERSION = '$TARGET_VERSION'
73+
EOF
74+
75+
git commit -m "Updated version files to $TARGET_VERSION." RELEASE src/psij/version.py
76+
git push --set-upstream origin releases/$TARGET_VERSION
77+
78+
git tag -a "$TARGET_VERSION" -m "Tagging $TARGET_VERSION"
79+
git push origin --tags
80+
81+
echo "Building packages..."
82+
python3 setup.py sdist
83+
python3 setup.py bdist_wheel
84+
85+
echo "Releasing PyPi package..."
86+
#twine upload dist/*
87+
88+
echo "Triggering web docs build..."
89+
git commit --allow-empty -m "Trigger web build for $TARGET_VERSION"
90+
git push
91+
92+
echo "All done!"

tag_and_release.sh

Lines changed: 0 additions & 61 deletions
This file was deleted.

0 commit comments

Comments
 (0)