-
Notifications
You must be signed in to change notification settings - Fork 80
162 lines (142 loc) · 5.17 KB
/
release.yaml
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
# Copyright (c) 2020-2021, NVIDIA CORPORATION.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# 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: "NeMo Aligner release"
defaults:
run:
shell: bash -x -e -u -o pipefail {0}
on:
workflow_dispatch:
inputs:
branch:
description: Branch to release
required: true
type: string
# to be removed later:
pull_request:
jobs:
build-container:
uses: ./.github/workflows/_build_container.yml
build-and-test-wheel:
needs: build-container
runs-on: self-hosted-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$//')
PAYLOAD=$(jq \
-n \
-c \
--arg TAG_NAME "v${VERSION}" \
--arg CI_COMMIT_BRANCH "${{ github.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
}'
)
curl -L \
-X POST \
-H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer ${{ secrets.PAT }}" \
-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"
MESSAGE='{
"blocks": [
{
"type": "section",
"text": {
"type": "mrkdwn",
"text": "Releasebot 🤖: NeMo-Aligner released <'$URL'|`'$VERSION'`> 🚀"
}
}
]
}'
curl -X POST -H "Content-type: application/json" --data "$MESSAGE" ${{ secrets.SLACK_WEBHOOK }}