Skip to content

Code freeze

Code freeze #4

name: "NeMo Code freeze"
on:
workflow_dispatch:
inputs:
next_version:
description: 'MAJOR.MINOR.PATCH[rcN] (Example: 2.0.0rc1, or 2.1.0)'
required: true
type: string
is_prelease:
description: Whether to keep and bump the pre-release label
required: false
default: false
type: boolean
mcore_version:
description: 'Version of MCore to use (must be a valid git ref)'
required: true
type: string
jobs:
create-release-branch:
runs-on: ubuntu-latest
if: contains(fromJSON('["ko3n1g"]'), github.actor)
environment:
name: main
outputs:
version: ${{ steps.release-branch.outputs.version }}
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
path: ${{ github.run_id }}
fetch-depth: 0
fetch-tags: true
ref: main
- name: Get release branch ref
id: release-branch
run: |
cd ${{ github.run_id }}
VERSION=$(python -c 'import nemo; print(nemo.__version__)')
if [[ "${{ inputs.is_prelease }}" == "false" ]]; then
sed -i '/^PRE_RELEASE/c\PRE_RELEASE = '\''' nemo/package_info.py
fi
echo "Release version r$VERSION" > version
echo "version=$VERSION" >> "$GITHUB_OUTPUT"
- name: Pin branch name in Notebooks
run: |
cd ${{ github.run_id }}
find tutorials -type f -name "*.ipynb" -exec sed -i "s/BRANCH = 'main'/BRANCH = 'r${{ steps.release-branch.outputs.version }}'/g" {} +
- name: Pin MCore in Dockerfile
run: |
cd ${{ github.run_id }}
sed -i 's/^ARG MCORE_TAG=.*$/ARG MCORE_TAG=${{ inputs.mcore_version }}/' Dockerfile.ci
- name: Create Release PR
uses: peter-evans/create-pull-request@v6
id: create-pull-request
with:
path: ${{ github.run_id }}
branch: r${{ steps.release-branch.outputs.version }}
title: 'Release `${{ steps.release-branch.outputs.version }}`'
body: |
🚀 PR to release NeMo `${{ steps.release-branch.outputs.version }}`.
📝 Please remember the following to-do's before merge:
- [ ] Fill-in the comment `Highlights`
- [ ] Review the comment `Detailed Changelogs`
🚨 Please also keep in mind to _not_ delete the headings of the task commits. They are required by the post-merge automation.
🙏 Please merge this PR only if the CI workflow completed successfully.
commit-message: "[🤠]: Howdy folks, let's release NeMo `${{ steps.release-branch.outputs.version }}` !"
signoff: true
assignees: okoenig
labels: 'Run CICD'
- name: Add Summary comment
uses: peter-evans/create-or-update-comment@v4
with:
issue-number: ${{ steps.create-pull-request.outputs.pull-request-number }}
body: |
# Highlights
_<here-goes-the-summary...>_
- name: Add Changelog comment
uses: peter-evans/create-or-update-comment@v4
with:
issue-number: ${{ steps.create-pull-request.outputs.pull-request-number }}
body: |
# Detailed Changelogs
${{ steps.build-changelog.outputs.changelog }}
bump-next-version:
runs-on: ubuntu-latest
needs: [create-release-branch]
environment:
name: main
env:
VERSION_FILE: nemo/package_info.py
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
path: ${{ github.run_id }}
fetch-depth: 0
fetch-tags: true
ref: main
token: ${{ secrets.PAT }}
- name: Bump version
id: bump-version
run: |
cd ${{ github.run_id }}
FULL_VERSION_NUM=${{ inputs.next_version }}
VERSION=${FULL_VERSION_NUM%%rc*}
MAJOR=$(echo "$VERSION" | cut -d. -f1)
MINOR=$(echo "$VERSION" | cut -d. -f2)
PATCH=$(echo "$VERSION" | cut -d. -f3)
PRE_RELEASE=${FULL_VERSION_NUM#$VERSION}
sed -i 's/^MAJOR\s*=\s*[0-9]\+/MAJOR = '$MAJOR'/' $VERSION_FILE
sed -i 's/^MINOR\s*=\s*[0-9]\+/MINOR = '$MINOR'/' $VERSION_FILE
sed -i 's/^PATCH\s*=\s*[0-9]\+/PATCH = '$PATCH'/' $VERSION_FILE
sed -i 's/^PRE_RELEASE\s*=\s*'.*'/PRE_RELEASE = '\'$PRE_RELEASE\''/' $VERSION_FILE
cat $VERSION_FILE
PRE_RELEASE=$(echo $PRE_RELEASE | tr -d "'")
echo "version=$MAJOR.$MINOR.$PATCH$PRE_RELEASE" >> "$GITHUB_OUTPUT"
- name: Create Version Bump PR
uses: peter-evans/create-pull-request@v6
id: create-pull-request
with:
path: ${{ github.run_id }}
branch: bot/chore/version-bump-${{ inputs.next_version }}
title: 'Version bump to `${{ inputs.next_version }}`'
body: |
🚀 Version bump NeMo toolkit to `${{ inputs.next_version }}`
commit-message: "[🤠]: Howdy folks, let's bump NeMo `${{ inputs.next_version }}` !"
signoff: true
assignees: okoenig
labels: 'Run CICD'
notify:
runs-on: ubuntu-latest
needs: [create-release-branch, bump-next-version]
environment:
name: main
steps:
- name: Main
run: |
MESSAGE='{
"blocks": [
{
"type": "section",
"text": {
"type": "mrkdwn",
"text": "Releasebot 🤖: NeMo Toolkit has been frozen 🎉 to branch `r${{ needs.create-release-branch.outputs.version }}`"
}
}
]
}'
curl -X POST -H "Content-type: application/json" --data "$MESSAGE" ${{ secrets.SLACK_RELEASE_ENDPOINT }}