Skip to content

Commit bf06155

Browse files
authored
Update instructions to use YYYY.WW.REV for release versions. (#100)
* Update instructions to use YYYY.WW.REV for release versions. * Add stamp.sh file to more sanely advance the version number. * Update README and add --release flag
1 parent 48b017d commit bf06155

File tree

3 files changed

+69
-20
lines changed

3 files changed

+69
-20
lines changed

README.md

Lines changed: 6 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -89,27 +89,14 @@ There are two stages, testing and deployment.
8989

9090
1. **Update the -tools version**: Once the tests pass, update the `setup.py` version and create a tag in the -tools repository at the same SHA you identified earlier.
9191

92-
- Determine the next [semver](https://packaging.python.org/en/latest/specifications/version-specifiers/#version-specifiers) number as appropriate for the changes in this release. e.g. `1.1.4`
93-
- Create a local version identifier, with the format `YYYY-MM-DD-A`, where `YYYY-MM-DD` represents release date, and `-A` is used for the first release of the day (followed by `-B`, `-C`, etc., for subsequent same-day releases). e.g. `2024-08-24-A`
92+
- Run `stamp.sh` to determine the next version and update `setup.py`. Use `--release` to additionally create a tag and push to main.
93+
- Determine the next [stamp](https://blog.aspect.build/versioning-releases-from-a-monorepo) (which is valid [semver](https://packaging.python.org/en/latest/specifications/version-specifiers/#version-specifiers)) number as appropriate for the changes in this release. e.g. `2024.40.2`.
9494

95-
- Here is a command line script to generate the local identifier, tested on Mac:
96-
97-
```
98-
TAG_NAME=$(date +%Y-%m-%d)-A && \
99-
SHA=$(git rev-parse HEAD) && \
100-
git tag -a "$TAG_NAME" "$SHA" -m "Release $TAG_NAME" && \
101-
git push origin "$TAG_NAME"
102-
```
103-
104-
- The new version will be `{NEXT_SEMVER}+{LOCAL_VERSION}`, e.g. `1.1.4+2024-08-24-A`
105-
- **Update `setup.py` with this version.**
106-
- Create a tag at the SHA from the testing phase, using the local version identifier.
107-
108-
2. **Update your testing PR branch**: Remove SHA and add tag to [validate-doc-metadata.yml](https://github.com/awsdocs/aws-doc-sdk-examples/blob/main/.github/workflows/validate-doc-metadata.yml)
95+
1. **Update your testing PR branch**: Remove SHA and add tag to [validate-doc-metadata.yml](https://github.com/awsdocs/aws-doc-sdk-examples/blob/main/.github/workflows/validate-doc-metadata.yml)
10996
- NOTE: Remove the SHA from [.doc_gen/validation.yaml](https://github.com/awsdocs/aws-doc-sdk-examples/blob/main/.doc_gen/validation.yaml)
110-
- This is easily accomplished in the UI.
111-
3. **Create a release**: Use the automated ["Create release from tag" button](https://github.com/awsdocs/aws-doc-sdk-examples-tools/releases/new) to create a new release with the new tag.
112-
4. **Perform internal update process**.
97+
- This is easily accomplished in the Github UI.
98+
2. **Create a release**: Use the automated ["Create release from tag" button](https://github.com/awsdocs/aws-doc-sdk-examples-tools/releases/new) to create a new release with the new tag.
99+
3. **Perform internal update process**.
113100

114101
## Security
115102

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
setup(
77
name="aws_doc_sdk_examples_tools",
8-
version="1.0.4+2024-09-20-A",
8+
version="2024.40.0",
99
packages=["aws_doc_sdk_examples_tools"],
1010
package_data={"aws_doc_sdk_examples_tools": ["config/*.yaml"]},
1111
entry_points={

stamp.sh

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
#!/bin/sh
2+
3+
set -e # Exit on errors
4+
# set -x # Shell debugging
5+
6+
# First, check that we're on the main branch.
7+
BRANCH=$(git rev-parse --abbrev-rev HEAD)
8+
if [ "$BRANCH" != "main" ] ; then
9+
echo "Not on main, exiting!"
10+
exit 1
11+
fi
12+
13+
# And check that the main branch is clean
14+
STATUS=$(git status --porcelain)
15+
if [ -n "${STATUS}" ] ; then
16+
echo "Repository is not clean, exiting!"
17+
exit 1
18+
fi
19+
20+
# And check that the REMOTE points to the -tools repo.
21+
REMOTE="${REMOTE:-origin}"
22+
if [[ "$(git remote get-url $REMOTE 2>/dev/null)" != *"awsdocs/aws-doc-sdk-examples-tools.git"* ]] ; then
23+
echo "REMOTE=${REMOTE} is not set to awsdocs/aws-doc-sdk-examples-tools.git, please adjust accordingly and rerun."
24+
exit 1
25+
fi
26+
27+
# CURRENT and NEXT have the format YYYY.WW.REV, where YYYY is the current year,
28+
# WW is the current week, and REV is the number of releases this week.
29+
# The next revision compares the two, in this way
30+
# - If NEXT is later than CURRENT in any fields, accept NEXT.
31+
# - Otherwise, return CURRENT, with one added to REV.
32+
#
33+
# THIS FUNCTION IS NOT TRANSITIVE! It must be called with
34+
# `compare_versions CURRENT NEXT`
35+
compare_versions() {
36+
if [[ "$1" < "$2" ]] ; then
37+
echo "$2"
38+
else
39+
IFS='.' read -r y1 w1 r1 <<< "$1"
40+
r1=$((r1 + 1))
41+
echo "${y1}.${w1}.${r1}"
42+
fi
43+
}
44+
45+
# compare_versions 2024.44.4 2024.44.0 # 2024.44.5
46+
# compare_versions 2024.44.4 2024.45.0 # 2024.45.0
47+
# compare_versions 2024.44.4 2025.1.0 # 2025.1.0
48+
49+
CURRENT=$(grep version= setup.py | awk -F\" '{print $2}')
50+
NEXT=$(date +%Y.%W.0)
51+
VERSION=$(compare_versions "$CURRENT" "$NEXT")
52+
echo "Releasing $VERSION..."
53+
sed "/version=/ s/$CURRENT/$VERSION/" setup.py > setup.py.out ; mv setup.py.out setup.py
54+
git --no-pager diff
55+
git add setup.py
56+
git commit --message "Release ${VERSION}"
57+
58+
if [ "$1" == "--release" ] ; then
59+
git tag "$VERSION" main
60+
git push "$REMOTE" "$VERSION"
61+
git push "$REMOTE" main
62+
fi

0 commit comments

Comments
 (0)