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

Update instructions to use YYYY.WW.REV for release versions. #100

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
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
25 changes: 6 additions & 19 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -89,27 +89,14 @@ There are two stages, testing and deployment.

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.

- 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`
- 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`
- 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`.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This description is rather opaque and the linked articles are long, but I see that it boils down to "run stamp.sh, probably with --release".
But maybe a crisper synopsis would help. Even just the comments in stamp.sh about how the tag is formed are probably enough.

- Run `stamp.sh` to automatically perform this action. Use `--release` to additionally create a tag and push to main.

- Here is a command line script to generate the local identifier, tested on Mac:

```
TAG_NAME=$(date +%Y-%m-%d)-A && \
SHA=$(git rev-parse HEAD) && \
git tag -a "$TAG_NAME" "$SHA" -m "Release $TAG_NAME" && \
git push origin "$TAG_NAME"
```

- The new version will be `{NEXT_SEMVER}+{LOCAL_VERSION}`, e.g. `1.1.4+2024-08-24-A`
- **Update `setup.py` with this version.**
- Create a tag at the SHA from the testing phase, using the local version identifier.

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)
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)
- NOTE: Remove the SHA from [.doc_gen/validation.yaml](https://github.com/awsdocs/aws-doc-sdk-examples/blob/main/.doc_gen/validation.yaml)
- This is easily accomplished in the UI.
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.
4. **Perform internal update process**.
- This is easily accomplished in the Github UI.
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.
3. **Perform internal update process**.

## Security

Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

setup(
name="aws_doc_sdk_examples_tools",
version="1.0.4+2024-09-20-A",
version="2024.40.0",
packages=["aws_doc_sdk_examples_tools"],
package_data={"aws_doc_sdk_examples_tools": ["config/*.yaml"]},
entry_points={
Expand Down
62 changes: 62 additions & 0 deletions stamp.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
#!/bin/sh

set -e # Exit on errors
# set -x # Shell debugging

# First, check that we're on the main branch.
BRANCH=$(git rev-parse --abbrev-rev HEAD)
if [ "$BRANCH" != "main" ] ; then
echo "Not on main, exiting!"
# exit 1
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You'll want to uncomment these.

fi

# And check that the main branch is clean
STATUS=$(git status --porcelain)
if [ -n "${STATUS}" ] ; then
echo "Repository is not clean, exiting!"
# exit 1
fi

# And check that the REMOTE points to the -tools repo.
REMOTE="${REMOTE:origin}"
if [ "$(git remote get-url $REMOTE 2>/dev/null)" != "[email protected]:awsdocs/aws-doc-sdk-examples-tools.git" ] ; then
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This fails for me because when I run this manually I get

$ git remote get-url origin
https://github.com/awsdocs/aws-doc-sdk-examples-tools.git

echo "REMOTE=${REMOTE} is not set to [email protected]:awsdocs/aws-doc-sdk-examples-tools.git, please adjust accordingly and rerun."
exit 1
fi

# CURRENT and NEXT have the format YYYY.WW.REV, where YYYY is the current year,
# WW is the current week, and REV is the number of releases this week.
# The next revision compares the two, in this way
# - If NEXT is later than CURRENT in any fields, accept NEXT.
# - Otherwise, return CURRENT, with one added to REV.
#
# THIS FUNCTION IS NOT TRANSITIVE! It must be called with
# `compare_versions CURRENT NEXT`
compare_versions() {
if [[ "$1" < "$2" ]] ; then
echo "$2"
else
IFS='.' read -r y1 w1 r1 <<< "$1"
r1=$((r1 + 1))
echo "${y1}.${w1}.${r1}"
fi
}

# compare_versions 2024.44.4 2024.44.0 # 2024.44.5
# compare_versions 2024.44.4 2024.45.0 # 2024.45.0
# compare_versions 2024.44.4 2025.1.0 # 2025.1.0

CURRENT=$(grep version= setup.py | awk -F\" '{print $2}')
NEXT=$(date +%Y.%W.0)
VERSION=$(compare_versions "$CURRENT" "$NEXT")
echo "Releasing $VERSION..."
sed -i '' "/version=/ s/$CURRENT/$VERSION/" setup.py
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The extra '' after sed -i makes this fail.

git --no-pager diff
git add setup.py
git commit --message "Release ${VERSION}"

if [ "$1" == "--release" ] ; then
git tag "$VERSION" main
git push "$REMOTE" "$VERSION"
git push "$REMOTE" main
fi