Skip to content
Closed
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
40 changes: 40 additions & 0 deletions .github/workflows/bump_version.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# This script bumps up the version in setup.py for new releases.
# Usage: python bump_version.py {new_version} (--file_path <path-to setup.py>)

import argparse
import re
import xml.etree.ElementTree as ET


def bump_version(new_version, file_path):
with open(file_path, "r") as file:
read_me = file.read()

# Replace first instance of <version></version>
new_read_me = re.sub(
'<version>[0-9]+\.[0-9]+\.[-a-z0-9]+</version>',
f'<version>{new_version}</version>',
read_me, 1
)

with open(file_path, "w") as file:
file.write(new_read_me)

if __name__ == "__main__":
parser = argparse.ArgumentParser(
description="updates the version for a release",
formatter_class=argparse.ArgumentDefaultsHelpFormatter,
)
parser.add_argument("new_version", help="New Version as major.minor.patch")
parser.add_argument(
"--read_me", default="README.md", help="path to README.md"
)
parser.add_argument(
"--pom_xml", default="pom.xml", help="path to pom.xml"
)

args = parser.parse_args()

bump_version(args.new_version, args.read_me)
bump_version(args.new_version, args.pom_xml)

52 changes: 36 additions & 16 deletions .github/workflows/create-release-pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@ on:
workflow_dispatch:
inputs:
release_version:
description: 'The release_version used for the release branch name, e.g. release/vx.x.x'
default: 'vx.x.x'
description: 'The release_version used for the release branch name, e.g. release/x.x.x'
default: 'x.x.x'
required: true
type: string
pre_release_version:
description: "Pre-Release version, e.g. 'beta.1'"
description: "Pre-Release version, e.g. 'beta-1'"
required: false
type: string

Expand All @@ -26,19 +26,19 @@ jobs:
- name: Set Release Version and Branch to Check Out
id: set-release
run: |
if [[ $RELEASE_VERSION =~ ^v[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
if [[ $PRE_RELEASE_VERSION =~ ^[a-z.0-9]+$ ]]; then
if [[ $RELEASE_VERSION =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
if [[ $PRE_RELEASE_VERSION =~ ^[-a-z0-9]+$ ]]; then
echo "release-tag: $RELEASE_VERSION-$PRE_RELEASE_VERSION"
echo "release-tag=$RELEASE_VERSION-$PRE_RELEASE_VERSION" >> $GITHUB_OUTPUT
elif [[ -n $PRE_RELEASE_VERSION ]]; then
echo "Input pre_release_version is not empty, but does not match the regex pattern ^[a-z.0-9]+$"
echo "Input pre_release_version is not empty, but does not match the regex pattern ^[-a-z0-9]+$"
exit 1
else
echo "release-tag: $RELEASE_VERSION"
echo "release-tag=$RELEASE_VERSION" >> $GITHUB_OUTPUT
fi
else
echo "Version input doesn't match the regex pattern ^v[0-9]+\.[0-9]+\.[0-9]+$"
echo "Version input doesn't match the regex pattern ^[0-9]+\.[0-9]+\.[0-9]+$"
exit 1
fi

Expand All @@ -47,7 +47,7 @@ jobs:
with:
fetch-depth: 0

- name: Create Release Branch if it does not exist
- name: Create Release Branch if it Does Not Exist
run: |
if ! git show-ref --verify --quiet "refs/remotes/origin/$RELEASE_BRANCH"; then
git checkout -b $RELEASE_BRANCH
Expand Down Expand Up @@ -134,6 +134,12 @@ jobs:
echo "$(tail -n +2 CHANGELOG.md)" > CHANGELOG.md
echo -e "# Changelog\n\n# ${RELEASE_VERSION}\n\n${CHANGELOG_CONTENT}**Full Changelog**: https://github.com/${{ github.repository }}/compare/${PREVIOUS_VERSION}...${RELEASE_VERSION}" | cat - CHANGELOG.md > temp && mv temp CHANGELOG.md

- name: Update Version References in Source
env:
RELEASE_TAG: ${{ steps.set-release.outputs.release-tag }}
run: |
python3 .github/workflows/bump_version.py ${RELEASE_TAG}

- name: Commit Changes
uses: EndBug/add-and-commit@v9.1.3
env:
Expand All @@ -148,16 +154,24 @@ jobs:
GH_TOKEN: ${{ github.token }}
RELEASE_TAG: ${{ steps.set-release.outputs.release-tag }}
run: |
echo -e "# ${RELEASE_TAG}\n\n${CHANGELOG_CONTENT}**Full Changelog**: https://github.com/${{ github.repository }}/compare/${PREVIOUS_VERSION}...${RELEASE_TAG}" > msg_body.txt
# Note: There's an issue adding teams as reviewers, see https://github.com/cli/cli/issues/6395
echo -e "# ${RELEASE_TAG}\n\n${CHANGELOG_CONTENT}**Full Changelog**: https://github.com/${{ github.repository }}/compare/${PREVIOUS_VERSION}...${RELEASE_TAG}\n\n@algorand/devops" > msg_body.txt
export msg_body=$(cat msg_body.txt)
rm msg_body.txt
PULL_REQUEST_URL=$(gh pr create --base "master" \
--title "FOR REVIEW ONLY: ${{ github.event.repository.name }} $RELEASE_TAG" \
--label "Skip-Release-Notes" \
--body "$msg_body" | tail -n 1)
PULL_REQUEST_NUM=$(echo $PULL_REQUEST_URL | sed 's:.*/::')
echo "pull-request-master=$PULL_REQUEST_URL" >> $GITHUB_ENV
echo "pull-request-master-num=$PULL_REQUEST_NUM" >> $GITHUB_ENV
echo "Pull request to Master created: $PULL_REQUEST_URL"
if [[ $PULL_REQUEST_URL =~ ^https://github.com/${{ github.repository }}/pull/[0-9]+$ ]]; then
PULL_REQUEST_NUM=$(echo $PULL_REQUEST_URL | sed 's:.*/::')
echo "pull-request-master=$PULL_REQUEST_URL" >> $GITHUB_ENV
echo "pull-request-master-num=$PULL_REQUEST_NUM" >> $GITHUB_ENV
echo "Pull request to Master created: $PULL_REQUEST_URL"
else
echo "There was an issue creating the pull request to master branch."
exit 1
fi


- name: Create Pull Request to Develop
if: ${{ env.PRE_RELEASE_VERSION == '' }}
Expand All @@ -169,9 +183,15 @@ jobs:
--title "FOR REVIEW ONLY: Merge back ${{ github.event.repository.name }} $RELEASE_TAG to develop" \
--label "Skip-Release-Notes" \
--body "Merge back version changes to develop." | tail -n 1)
echo "Pull request to Develop created: $PULL_REQUEST_URL"
DEVELOP_PR_MESSAGE="\nPull Request to develop: $PULL_REQUEST_URL"
echo "pull-request-develop-message=$DEVELOP_PR_MESSAGE" >> $GITHUB_ENV
if [[ $PULL_REQUEST_URL =~ ^https://github.com/${{ github.repository }}/pull/[0-9]+$ ]]; then
echo "Pull request to Develop created: $PULL_REQUEST_URL"
DEVELOP_PR_MESSAGE="\nPull Request to develop: $PULL_REQUEST_URL"
echo "pull-request-develop-message=$DEVELOP_PR_MESSAGE" >> $GITHUB_ENV
else
echo "There was an issue creating the pull request to develop branch."
exit 1
fi


- name: Send Slack Message
id: slack
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
venv/
Loading