From 41e1dc984f7b436347f132384a085dc6e34b8733 Mon Sep 17 00:00:00 2001 From: Doug Miller Date: Tue, 6 Apr 2021 17:17:57 -0500 Subject: [PATCH] Updating release scripts --- .changelog_config.yaml | 11 ++++++ .github_changelog_generator | 8 ----- scripts/bump | 11 ------ scripts/changelog | 14 -------- scripts/prepare-release | 72 ++++++++++++++++++++++--------------- scripts/release | 24 +++---------- 6 files changed, 59 insertions(+), 81 deletions(-) create mode 100644 .changelog_config.yaml delete mode 100644 .github_changelog_generator delete mode 100755 scripts/bump delete mode 100755 scripts/changelog diff --git a/.changelog_config.yaml b/.changelog_config.yaml new file mode 100644 index 00000000..95246136 --- /dev/null +++ b/.changelog_config.yaml @@ -0,0 +1,11 @@ +--- +owner: recurly +repo: recurly-client-python +tag_matcher: ^4\..* +required_issue_labels: + - V4 +exclude_labels: + - bug? + - internal + - duplicate + - question diff --git a/.github_changelog_generator b/.github_changelog_generator deleted file mode 100644 index 76ba5255..00000000 --- a/.github_changelog_generator +++ /dev/null @@ -1,8 +0,0 @@ -user=recurly -project=recurly-client-python -unreleased=false -exclude-labels=internal,question,bug?,duplicate,V2 -exclude-tags-regex=^[^34]+\..* -issues-wo-labels=false -verbose=false -since-tag=3.0b2 diff --git a/scripts/bump b/scripts/bump deleted file mode 100755 index 709ee867..00000000 --- a/scripts/bump +++ /dev/null @@ -1,11 +0,0 @@ -#!/usr/bin/env bash -set -e - -if [ "$1" == "--next-version" ]; then - shift - bump2version --dry-run --list "$@" | grep new_version | cut -d "=" -f 2 -elif [ "$1" == "--this-version" ]; then - grep current_version .bumpversion.cfg | awk -F" = " '{print $2}' -else - bump2version "$@" -fi \ No newline at end of file diff --git a/scripts/changelog b/scripts/changelog deleted file mode 100755 index f5ae73ff..00000000 --- a/scripts/changelog +++ /dev/null @@ -1,14 +0,0 @@ -#!/usr/bin/env bash -set -e - -if [ -z "$GITHUB_TOKEN" ]; then - echo "Environment variable GITHUB_TOKEN must be set" -else - if [ "$1" == "--pending" ]; then - github_changelog_generator -t $GITHUB_TOKEN --unreleased-only -o "$2" - elif [ "$1" == "--release-tag" ]; then - github_changelog_generator -t $GITHUB_TOKEN --unreleased true --future-release "$2" - else - github_changelog_generator -t $GITHUB_TOKEN - fi -fi diff --git a/scripts/prepare-release b/scripts/prepare-release index 33862b65..5f43a7f1 100755 --- a/scripts/prepare-release +++ b/scripts/prepare-release @@ -1,36 +1,50 @@ #!/usr/bin/env bash -set -e - -# major,minor,patch -PART=${1} -NEXT_VERSION=$(./scripts/bump --next-version "$PART") -UNRELEASED_LOG="/tmp/python-pending-changes.md" - -if [ -z "$NEXT_VERSION" ]; then - echo "Failed to get next version" -else - # Generate pending changes in tmpfile - ./scripts/changelog --pending $UNRELEASED_LOG - # Add a git message header of Release X.Y.Z - printf "Release %s\n\n$(cat $UNRELEASED_LOG)" "$NEXT_VERSION" > $UNRELEASED_LOG - # Delete credit line - sed -i '' -e '$ d' $UNRELEASED_LOG - - git checkout -b "release-$NEXT_VERSION" - # Actually bump the version - ./scripts/bump "$PART" +# Usage +# +# ./prepare-release major|minor|patch [--notes-out ] [--tag-out ] +# - # Rebuild docs - ./scripts/build +set -e - # Make the commit - git add . --all - git commit -F "$UNRELEASED_LOG" +if [ -n "$(git status --porcelain)" ]; then + echo "Working directory is not clean. Aborting." + exit 1 +fi - # Push up this branch for PR - git push origin "release-$NEXT_VERSION" +if [ -z "$GITHUB_TOKEN" ]; then + echo "GITHUB_TOKEN must be set. Aborting." + exit 1 +fi - # Create PR - hub pull-request -c -F "$UNRELEASED_LOG" +# Bump version +# major|minor|patch +part=${1} +if [ "$part" != "patch" ] && [ "$part" != "minor" ] && [ "$part" != "major" ]; then + echo "'$part' is not a valid option: major|minor|patch" + exit 1 fi +new_version=$(bump2version --list "$part" | grep new_version | cut -d "=" -f 2) + +# Generate Changelog +changelogly --future-release "$new_version" + +while [[ "$#" -gt 0 ]]; do + case $1 in + # Create release notes artifact + -n|--notes-out) + echo "$new_version + + $( + cat CHANGELOG.md | sed -n "/^## \[$new_version\]/,/^##/p" | sed '$d;1d' + )" | awk '{$1=$1};1' > $2 + shift + ;; + + # Create release notes artifact + -t|--tag-out) + echo "v$new_version" > $2 + ;; + esac + shift +done diff --git a/scripts/release b/scripts/release index b083b3aa..b6782d88 100755 --- a/scripts/release +++ b/scripts/release @@ -1,14 +1,11 @@ #!/usr/bin/env bash + set -e -# TODO this file could be gone -RELEASED_LOG="/tmp/python-pending-changes.md" -THIS_VERSION=$(./scripts/bump --this-version) -# Generate the changelog with changes in this release -./scripts/changelog --release-tag "$THIS_VERSION" -git add CHANGELOG.md -git commit -m "Update Changelog for Release $THIS_VERSION" -git push origin master +# Usage +# +# ./release +# # Publish # First cleanup dist folder @@ -20,14 +17,3 @@ twine check dist/* # publish to pypi twine upload dist/* -# create release -hub release create -c -F $RELEASED_LOG $THIS_VERSION - -# Copy-pasteable messages for announcments -echo ":python: Python $THIS_VERSION Released :python:" -echo ":pypi: PyPi: https://pypi.org/project/recurly/$THIS_VERSION/" -echo "Release: https://github.com/recurly/recurly-client-python/releases/tag/$THIS_VERSION" -echo "Changelog:" -echo "\`\`\`" -cat "$RELEASED_LOG" -echo "\`\`\`"