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: Add release workflow #382

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
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
6 changes: 3 additions & 3 deletions .github/workflows/release-freeze.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,14 @@ on:
options:
- major
- minor
- pre_release

jobs:
code-freeze:
uses: NVIDIA/NeMo-FW-CI-templates/.github/workflows/_code_freeze.yml@v0.1.0
uses: NVIDIA/NeMo-FW-CI-templates/.github/workflows/_code_freeze.yml@v0.8.0
with:
name_of_library: NeMo-Aligner
type_of_release: ${{ inputs.type_of_release }}
python_package: nemo_aligner
secrets:
SLACK_RELEASE_ENDPOINT: ${{ secrets.SLACK_RELEASE_ENDPOINT }}
SLACK_RELEASE_ENDPOINT: ${{ secrets.SLACK_RELEASE_ENDPOINT }}
SLACK_WEBHOOK_ADMIN: ${{ secrets.SLACK_WEBHOOK_ADMIN }}
163 changes: 23 additions & 140 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,149 +11,32 @@
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
name: "Release"

defaults:
run:
shell: bash -x -e -u -o pipefail {0}
name: "Release NeMo Aligner"

on:
workflow_dispatch:
inputs:
prerelease-sha:
type: string
description: "Commit SHA for prerelease tag (default: HEAD main)"
required: false

jobs:
build-container:
uses: NVIDIA/NeMo-FW-CI-templates/.github/workflows/_build_container.yml@v0.1.0
jobs:
prerelease:
uses: NVIDIA/NeMo-FW-CI-templates/.github/workflows/_release_library.yml@v0.9.0
with:
release-ref: ${{ inputs.prerelease-sha }}
image-name: nemo_aligner_container
dockerfile: Dockerfile
image-label: nemo-aligner

build-and-test-wheel:
needs: build-container
runs-on: self-hosted-azure-builder
container: nemoci.azurecr.io/nemo_aligner_container:${{ github.run_id }}
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
path: ${{ github.run_id }}

- name: Build and test wheel
run: |
cd ${{ github.run_id }}
EXPECTED_VERSION=$(python -c 'import nemo_aligner; print(nemo_aligner.__version__)')

python3 -m pip install --upgrade build
python3 -m build

pip install dist/*.whl

cd ../

INSTALLED_VERSION=$(python -c 'import nemo_aligner; print(nemo_aligner.__version__)')

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

- name: Upload wheel
uses: actions/upload-artifact@v4
with:
name: pip-wheel
path: ${{ github.run_id }}/dist/

publish-wheel:
needs: build-and-test-wheel
if: contains(fromJSON('["terryk", "gshennvm", "ko3n1g"]'), github.actor)
runs-on: ubuntu-latest
environment:
name: main
steps:
- name: Download wheel
uses: actions/download-artifact@v4
with:
name: pip-wheel
path: ${{ github.run_id }}/dist/

- name: Release wheel
env:
TWINE_USERNAME: ${{ secrets.TWINE_USERNAME }}
TWINE_PASSWORD: ${{ secrets.TWINE_PASSWORD }}
run: |
python3 -m pip install --upgrade twine
python3 -m twine upload --repository pypi ${{ github.run_id }}/dist/*

create-gh-release:
needs: publish-wheel
runs-on: ubuntu-latest
if: contains(fromJSON('["terryk", "gshennvm", "ko3n1g"]'), github.actor)
environment:
name: main
outputs:
version-number: ${{ steps.version-number.outputs.version }}
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
path: ${{ github.run_id }}

- name: Create release
id: version-number
run: |
cd ${{ github.run_id }}
VERSION=$(python -c "import nemo_aligner; print(nemo_aligner.__version__)")
echo "version=$VERSION" | tee -a "$GITHUB_OUTPUT"

NAME="NVIDIA NeMo-Aligner ${VERSION}"
CHANGELOG=$(awk '/^## '"$NAME"'/{flag=1; next} /^## /{flag=0} flag' CHANGELOG.md)
CHANGELOG=$(echo "$CHANGELOG" | sed '/./,$!d' | sed ':a;N;$!ba;s/\n$//')
SHA=${{ github.sha }}

PAYLOAD=$(jq \
-n \
-c \
--arg TAG_NAME "v${VERSION}" \
--arg CI_COMMIT_BRANCH "$SHA" \
--arg NAME "$NAME" \
--arg BODY "$CHANGELOG" \
'{
"tag_name": $TAG_NAME,
"target_commitish": $CI_COMMIT_BRANCH,
"name": $NAME,
"body": $BODY,
"draft": false,
"prerelease": false,
"generate_release_notes": false
}'
)
GH_TOKEN=${{ secrets.PAT }}
curl -L \
-X POST \
-H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer $GH_TOKEN" \
-H "X-GitHub-Api-Version: 2022-11-28" \
https://api.github.com/repos/NVIDIA/NeMo-Aligner/releases \
-d "$PAYLOAD"

notify:
needs: create-gh-release
runs-on: ubuntu-latest
if: contains(fromJSON('["terryk", "gshennvm", "ko3n1g"]'), github.actor)
steps:
- name: notify
run: |
VERSION=${{ needs.create-gh-release.outputs.version-number }}
URL="https://github.com/NVIDIA/NeMo-Aligner/releases/tag/v$VERSION"
WEBHOOK=${{ secrets.SLACK_WEBHOOK }}
MESSAGE='{
"blocks": [
{
"type": "section",
"text": {
"type": "mrkdwn",
"text": "Releasebot 🤖: NeMo-Aligner released <'$URL'|v'$VERSION'> 🚀"
}
}
]
}'

curl -X POST -H "Content-type: application/json" --data "$MESSAGE" $WEBHOOK
build-args: |
MAX_JOBS=32
ALIGNER_COMMIT=${{ github.event.pull_request.head.sha || github.sha }}
prune-filter-timerange: 24h
python-package: nemo_aligner
container-workdir: /opt/NeMo_Aligner
library-name: NeMo-Aligner
secrets:
TWINE_USERNAME: ${{ secrets.TWINE_USERNAME }}
TWINE_PASSWORD: ${{ secrets.TWINE_PASSWORD }}
SLACK_RELEASE_ENDPOINT: ${{ secrets.SLACK_RELEASE_ENDPOINT }}
Loading