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

ci: Automate release of NeMo Toolkit #9453

Closed
wants to merge 2 commits into from
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
130 changes: 130 additions & 0 deletions .github/workflows/release-freeze.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,130 @@
name: "Prepare release"

on:
workflow_dispatch:
inputs:
next_version:
description: 'MAJOR.MINOR.PATCH[rcN] (Example: 2.0.0rc1, or 2.1.0)'
required: true
type: string
jobs:
create-release-branch:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
path: ${{ github.run_id }}
fetch-depth: 0
fetch-tags: true
ref: main

- name: Create release branch
id: release-branch
run: |
cd ${{ github.run_id }}

VERSION=$(python -c 'import nemo; print(nemo.__version__)')

git checkout -b "r$VERSION"
git push -u origin "r$VERSION"

echo "ref=r$VERSION" >> "$GITHUB_OUTPUT"

- name: Build Changelog
id: build-changelog
uses: mikepenz/[email protected]
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
# Configuration file is setup with filters for domains
# owner:repo must point to current repo
# fromTag: Auto resolved from historical tag order (previous tag compared to current tag)
# toTag: Current tag reference
configuration: ".github/workflows/config/changelog-config.json"
owner: ${{ github.repository_owner }}
repo: ${{ github.event.repository.name }}
ignorePreReleases: "false"
failOnError: "false"
fromTag: main
toTag: ${{ steps.release-branch.outputs.ref }}

- name: Append Changelog
run: |
echo "${{ steps.build-changelog.outputs.changelog }}"

- name: Create Release PR
uses: peter-evans/create-pull-request@v6
id: create-pull-request
with:
path: ${{ github.run_id }}
branch: ${{ steps.release-branch.outputs.ref }}
title: 'Release `${{ steps.bump-version.outputs.VERSION }}`'
body: |
🚀 PR to release NeMo `${{ steps.bump-version.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.bump-version.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
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
path: ${{ github.run_id }}
fetch-depth: 0
fetch-tags: true
ref: main

- name: Bump version
id: bump-version
env:
VERSION_FILE: ${{ github.run_id }}/nemo/package_info.py
run: |
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)
PRERELEASE=${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: Push version bump
run: |
git commit -m "Version bump NeMo Toolkit"
git push
89 changes: 89 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
name: "Release"

on:
pull_request:
types: [closed]
branches:
- main

jobs:
main:
if: startsWith(github.event.pull_request.head.ref, 'release/') # && github.event.pull_request.merged == true
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
path: ${{ github.run_id }}

- name: Get version number
id: version-number
run: |
cd ${{ github.run_id }}
VERSION=$(python -c "import nemo; print(nemo.__version__)")
echo "VERSION=$VERSION" >> "$GITHUB_OUTPUT"

- name: Extract changelog
id: extract-changelog
uses: peter-evans/find-comment@v3
with:
issue-number: ${{ github.event.number }}
body-includes: '# Detailed Changelogs'

- name: Extract summary
id: extract-summary
uses: peter-evans/find-comment@v3
with:
issue-number: ${{ github.event.number }}
body-includes: '# Highlights'

- name: Create Release doc
id: create-release-doc
env:
SUMMARY: ${{ steps.extract-summary.outputs.comment-body }}
CHANGELOG: ${{ steps.extract-changelog.outputs.comment-body }}
run: |

echo "TITLE<<EOF" >> $GITHUB_ENV
echo "NVIDIA Neural Modules ${{ steps.version-number.outputs.VERSION }}" >> $GITHUB_ENV
echo "EOF" >> $GITHUB_ENV

echo "BODY<<EOF" >> $GITHUB_ENV
echo "$SUMMARY" >> $GITHUB_ENV
echo "$CHANGELOG" >> $GITHUB_ENV
echo "EOF" >> $GITHUB_ENV

- name: Create Release
uses: softprops/action-gh-release@v2
with:
name: ${{ env.TITLE }}
tag_name: ${{ steps.version-number.outputs.VERSION }}
body: ${{ env.BODY }}

- name: Build, test, and release wheel
env:
TWINE_USERNAME: ${{ secrets.TWINE_USERNAME }}
TWINE_PASSWORD: ${{ secrets.TWINE_PASSWORD }}
run: |
cd ${{ github.run_id }}
python3 -m pip install --upgrade build
python3 -m build

pip install dist/*.whl

cd ../

INSTALLED_VERSION=$(python -c 'import nemo; print(nemo.__version__)')
EXPECTED_VERSION=${{ steps.version-number.outputs.VERSION }}

if [[ "$INSTALLED_VERSION" != "$EXPECTED_VERSION" ]]; then
echo 'Wheel has an outdated version, mission abort immediately!'
exit 1
fi

echo Proceed with uploading wheel...
cd ${{ github.run_id }}
python3 -m pip install --upgrade twine
python3 -m twine upload --repository pypi dist/*


1 change: 1 addition & 0 deletions MANIFEST.in
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
include requirements/*
Loading