Repository navigation
169 lines (147 loc) · 4.91 KB
/
Copy pathrelease.yml
File metadata and controls
169 lines (147 loc) · 4.91 KB
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
169
# SPDX-FileCopyrightText: Copyright (c) 2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
# SPDX-License-Identifier: Apache-2.0
# ---------------------------------------------------------------------------
# Release: build wheel, publish to PyPI (or Test PyPI on dry-run), and
# optionally create a GitHub release.
#
# Required repository secrets (Settings → Secrets and variables → Actions):
# TEST_PYPI_PERSONAL_TOKEN – API token scoped to nemo-anonymizer on Test PyPI
# PYPI_PERSONAL_TOKEN – API token scoped to nemo-anonymizer on PyPI
# ---------------------------------------------------------------------------
name: "Release NeMo Anonymizer"
on:
workflow_dispatch:
inputs:
release-ref:
description: Full SHA (not short) or tag of the commit to build
required: true
type: string
dry-run:
description: "Dry Run: only publish to Test PyPI"
required: true
default: true
type: boolean
create-gh-release:
description: Create a GitHub release
required: true
default: true
type: boolean
defaults:
run:
shell: bash -x -e -u -o pipefail {0}
permissions:
contents: write
jobs:
publish-wheel:
name: Publish wheel (${{ inputs.dry-run && 'Test PyPI' || 'PyPI' }})
runs-on: ubuntu-latest
outputs:
version: ${{ steps.build.outputs.version }}
steps:
- name: Checkout at release ref
uses: actions/checkout@v7
with:
ref: ${{ inputs.release-ref }}
fetch-depth: 0
fetch-tags: true
- name: Install uv
uses: astral-sh/setup-uv@v7
with:
enable-cache: true
- name: Set up Python
uses: actions/setup-python@v7
with:
python-version-file: ".python-version"
- name: Build wheel
id: build
run: |
make build-wheel
WHEEL=$(ls dist/*.whl)
VERSION=$(echo "$WHEEL" | sed -n 's/.*-\([0-9][^-]*\)-.*/\1/p')
echo "version=$VERSION" >> "$GITHUB_OUTPUT"
echo "Built: $WHEEL (version $VERSION)"
- uses: actions/upload-artifact@v7
with:
name: nemo-anonymizer-${{ steps.build.outputs.version }}
path: dist/*.whl
retention-days: 90
- name: Publish to Test PyPI (always, as pre-flight)
env:
TWINE_USERNAME: __token__
TWINE_PASSWORD: ${{ secrets.TEST_PYPI_PERSONAL_TOKEN }}
run: |
uvx twine upload \
--repository-url https://test.pypi.org/legacy/ \
--skip-existing \
--non-interactive \
--verbose \
dist/*.whl
- name: Publish to PyPI
if: ${{ !inputs.dry-run }}
env:
TWINE_USERNAME: __token__
TWINE_PASSWORD: ${{ secrets.PYPI_PERSONAL_TOKEN }}
run: |
uvx twine upload \
--non-interactive \
--verbose \
dist/*.whl
create-gh-release:
name: Create GitHub release
needs: publish-wheel
if: ${{ inputs.create-gh-release }}
runs-on: ubuntu-latest
steps:
- name: Checkout at release ref
uses: actions/checkout@v7
with:
ref: ${{ inputs.release-ref }}
fetch-depth: 0
- name: Download wheel artifact
uses: actions/download-artifact@v8
with:
name: nemo-anonymizer-${{ needs.publish-wheel.outputs.version }}
path: dist/
- name: Create GitHub release
env:
GH_TOKEN: ${{ github.token }}
VERSION: ${{ needs.publish-wheel.outputs.version }}
run: |
PRERELEASE_FLAG=""
if echo "$VERSION" | grep -qE '(^|[0-9])rc[0-9]+($|\+)'; then
PRERELEASE_FLAG="--prerelease"
fi
gh release create "v${VERSION}" \
dist/*.whl \
--generate-notes \
--title "v${VERSION}" \
$PRERELEASE_FLAG
deploy-release-docs:
name: Deploy release docs
needs: [publish-wheel, create-gh-release]
if: ${{ inputs.create-gh-release }}
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Checkout at release ref
uses: actions/checkout@v7
with:
ref: ${{ inputs.release-ref }}
fetch-depth: 0
- uses: ./.github/actions/setup-python-env
with:
ref: ${{ inputs.release-ref }}
fetch-depth: "0"
- name: Install docs dependencies
run: uv sync --group dev --group docs
- name: Configure git for mike
run: |
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
- name: Build docs
run: make docs-build
- name: Deploy release docs with mike
env:
VERSION: ${{ needs.publish-wheel.outputs.version }}
run: uv run --group docs mike deploy --push --update-aliases "$VERSION" latest