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

CICD: Fix typos and add team label to release PR workflow #504

Merged
merged 9 commits into from
Jun 30, 2023
74 changes: 23 additions & 51 deletions .github/workflows/create-release-pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ jobs:
fi

- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v3.5.3
with:
fetch-depth: 0

Expand Down Expand Up @@ -78,52 +78,25 @@ jobs:
fi

- name: Build Changelog
uses: mikepenz/[email protected]
id: build-changelog
env:
PREVIOUS_VERSION: ${{ steps.get-release.outputs.latest-tag }}
with:
fromTag: ${{ env.PREVIOUS_VERSION }}
toTag: ${{ env.RELEASE_BRANCH }}
failOnError: true
configurationJson: |
{
"categories": [
{
"title": "## New Features",
"labels": [
"New Feature"
]
},
{
"title": "## Enhancement",
"labels": [
"Enhancement"
]
},
{
"title": "## Bug Fixes",
"labels": [
"Bug-Fix"
]
},
{
"title": "## Not Yet Enabled",
"labels": [
"Not-Yet-Enabled"
]
}
],
"ignore_labels": [
"Skip-Release-Notes"
],
"sort": {
"order": "ASC",
"on_property": "mergedAt"
},
"template": "#{{CHANGELOG}}",
"pr_template": "- #{{TITLE}} by #{{AUTHOR}} in ##{{NUMBER}}"
}
run: |
CHANGELOG=$(curl -L \
-X POST \
-H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer ${{ github.token }}"\
-H "X-GitHub-Api-Version: 2022-11-28" \
https://api.github.com/repos/${{ github.repository }}/releases/generate-notes \
-d '{"tag_name":"${{ env.RELEASE_VERSION }}","target_commitish":"${{ env.RELEASE_BRANCH }}","previous_tag_name":"${{ env.PREVIOUS_VERSION }}","configuration_file_path":".github/release.yml"}' \
| jq -r '.body')

# The EOF steps are used to save multiline string in github:
# https://docs.github.com/en/actions/using-workflows/workflow-commands-for-github-actions#example-of-a-multiline-string
EOF=$(dd if=/dev/urandom bs=15 count=1 status=none | base64)
echo "changelog<<$EOF" >> $GITHUB_OUTPUT
echo -e "${CHANGELOG}" >> $GITHUB_OUTPUT
echo "$EOF" >> $GITHUB_OUTPUT

- name: Update Changelog
if: ${{ env.PRE_RELEASE_VERSION == '' }}
Expand All @@ -132,7 +105,7 @@ jobs:
PREVIOUS_VERSION: ${{ steps.get-release.outputs.latest-tag }}
run: |
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
echo -e "# Changelog\n\n# ${RELEASE_VERSION}\n\n${CHANGELOG_CONTENT}" | cat - CHANGELOG.md > temp && mv temp CHANGELOG.md

- name: Update version in setup.py
env:
Expand All @@ -154,14 +127,12 @@ 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}" > tmp_msg_body.txt
export msg_body=$(cat tmp_msg_body.txt)
rm tmp_msg_body.txt
# Note: There's an issue adding teams as reviewers, see https://github.com/cli/cli/issues/6395
PULL_REQUEST_URL=$(gh pr create --base "master" \
--title "FOR REVIEW ONLY: py-algorand-sdk $RELEASE_TAG" \
--title "FOR REVIEW ONLY: ${{ github.event.repository.name }} $RELEASE_TAG" \
--label "Skip-Release-Notes" \
--body "$msg_body" | tail -n 1)
--label "Team Hyper Flow" \
--body "${CHANGELOG_CONTENT}" | tail -n 1)
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
Expand All @@ -180,8 +151,9 @@ jobs:
run: |
# Note: There's an issue adding teams as reviewers, see https://github.com/cli/cli/issues/6395
PULL_REQUEST_URL=$(gh pr create --base "develop" \
--title "FOR REVIEW ONLY: Merge back py-algorand-sdk $RELEASE_TAG to develop" \
--title "FOR REVIEW ONLY: Merge back ${{ github.event.repository.name }} $RELEASE_TAG to develop" \
--label "Skip-Release-Notes" \
--label "Team Hyper Flow" \
--body "Merge back version changes to develop." | tail -n 1)
if [[ $PULL_REQUEST_URL =~ ^https://github.com/${{ github.repository }}/pull/[0-9]+$ ]]; then
echo "Pull request to Develop created: $PULL_REQUEST_URL"
Expand Down
9 changes: 9 additions & 0 deletions scripts/bump_version.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,14 @@

import argparse
import re
import sys


def check_version(new_version):
if not re.fullmatch(r"[0-9]+\.[0-9]+\.[a-z.0-9]+", new_version):
sys.exit(
"The version does not match the regex(major.minor.patch): [0-9]+\.[0-9]+\.[a-z.0-9]+"
)


def bump_version(new_version, setup_py_path):
Expand Down Expand Up @@ -31,4 +39,5 @@ def bump_version(new_version, setup_py_path):

args = parser.parse_args()

check_version(args.new_version)
bump_version(args.new_version, args.setup_py_path)