forked from NVIDIA/NeMo
-
Notifications
You must be signed in to change notification settings - Fork 0
168 lines (145 loc) Β· 5.8 KB
/
release-freeze.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
name: "Code freeze"
on:
workflow_dispatch:
inputs:
type_of_release:
type: choice
description: Type of release
options:
- major
- minor
- pre_release
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
token: ${{ secrets.PAT }}
- name: Get release branch ref
id: release-branch
run: |
cd ${{ github.run_id }}
if [[ "${{ inputs.type_of_release }}" != "pre_release" ]]; then
sed -i "/^PRE_RELEASE/c\PRE_RELEASE = ''" nemo/package_info.py
fi
VERSION=$(python -c 'import nemo; print(nemo.__version__)')
echo "Release version r$VERSION" > version
echo "version=$VERSION" >> "$GITHUB_OUTPUT"
git switch --force-create r$VERSION origin/main
git push -u origin r$VERSION --force
- 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 }}
base: r${{ steps.release-branch.outputs.version }}
branch: ci/release-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'
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 }}
PRE_RELEASE=$(cat nemo/package_info.py | awk '/^PRE_RELEASE = /' | awk -F"= " '{print $2}' | tr -d '"' | tr -d "'")
MAJOR=$(cat nemo/package_info.py | awk '/^MAJOR = /' | awk -F"= " '{print $2}')
MINOR=$(cat nemo/package_info.py | awk '/^MINOR = /' | awk -F"= " '{print $2}')
PATCH=$(cat nemo/package_info.py | awk '/^PATCH = /' | awk -F"= " '{print $2}')
if [[ "${{ inputs.type_of_release }}" == "pre_release" ]]; then
NEXT_MAJOR=$MAJOR
NEXT_MINOR=$MINOR
NEXT_PRE_RELEASE=rc$(( $(echo $PRE_RELEASE | awk -F"rc" '{print $2}') + 1))
elif [[ "${{ inputs.type_of_release }}" == "major" ]]; then
NEXT_MAJOR=$(( MAJOR + 1))
NEXT_MINOR=0
NEXT_PRE_RELEASE=rc0
else
NEXT_MAJOR=$MAJOR
NEXT_MINOR=$(( MINOR + 1))
NEXT_PRE_RELEASE=rc0
fi
sed -i "/^MAJOR/c\MAJOR = $NEXT_MAJOR" nemo/package_info.py
sed -i "/^MINOR/c\MINOR = $NEXT_MINOR" nemo/package_info.py
sed -i "/^PRE_RELEASE/c\PRE_RELEASE = '$NEXT_PRE_RELEASE'" nemo/package_info.py
echo "version=$NEXT_MAJOR.$NEXT_MINOR.$PATCH$NEXT_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-${{ steps.bump-version.outputs.version }}
title: 'Version bump to `${{ steps.bump-version.outputs.version }}`'
body: |
π Version bump NeMo-Toolkit to `${{ steps.bump-version.outputs.version }}`
commit-message: "[π€ ]: Howdy folks, let's bump NeMo-Toolkit `${{ steps.bump-version.outputs.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 }}