|
12 | 12 | # See the License for the specific language governing permissions and |
13 | 13 | # limitations under the License. |
14 | 14 |
|
| 15 | +# --------------------------------------------------------------------------- |
| 16 | +# Release: build wheel, publish to PyPI (or Test PyPI on dry-run), and |
| 17 | +# optionally create a GitHub release. |
| 18 | +# |
| 19 | +# No version-bump PR, no docs upload, no dummy branch push. |
| 20 | +# --------------------------------------------------------------------------- |
| 21 | + |
15 | 22 | name: "Release NeMo Safe Synthesizer" |
16 | 23 |
|
17 | 24 | on: |
|
22 | 29 | required: true |
23 | 30 | type: string |
24 | 31 | dry-run: |
25 | | - description: "Dry Run: only publish to test PyPI" |
| 32 | + description: "Dry Run: only publish to Test PyPI" |
26 | 33 | required: true |
27 | 34 | default: true |
28 | 35 | type: boolean |
|
31 | 38 | required: true |
32 | 39 | default: true |
33 | 40 | type: boolean |
34 | | - version-bump-branch: |
35 | | - description: Branch to push the version bump |
36 | | - required: true |
37 | | - type: string |
| 41 | + |
| 42 | +defaults: |
| 43 | + run: |
| 44 | + shell: bash -x -e -u -o pipefail {0} |
38 | 45 |
|
39 | 46 | permissions: |
40 | 47 | contents: write |
41 | | - pull-requests: write |
42 | 48 |
|
43 | 49 | jobs: |
44 | | - release: |
45 | | - uses: NVIDIA-NeMo/FW-CI-templates/.github/workflows/_release_library.yml@v0.81.1 |
46 | | - with: |
47 | | - release-ref: ${{ inputs.release-ref }} |
48 | | - python-package: nemo_safe_synthesizer |
49 | | - library-name: NeMo Safe Synthesizer |
50 | | - dry-run: ${{ inputs.dry-run }} |
51 | | - version-bump-branch: ${{ inputs.version-bump-branch }} |
52 | | - create-gh-release: ${{ inputs.create-gh-release }} |
53 | | - packaging: uv |
54 | | - has-src-dir: true |
55 | | - app-id: ${{ vars.BOT_ID }} |
56 | | - secrets: |
57 | | - TWINE_USERNAME: ${{ secrets.TWINE_USERNAME }} |
58 | | - TWINE_PASSWORD: ${{ secrets.TWINE_PASSWORD }} |
59 | | - SLACK_WEBHOOK_ADMIN: ${{ secrets.SLACK_WEBHOOK_ADMIN }} |
60 | | - SLACK_WEBHOOK: ${{ secrets.SLACK_RELEASE_ENDPOINT }} |
61 | | - PAT: ${{ secrets.PAT }} |
62 | | - SSH_KEY: ${{ secrets.SSH_KEY }} |
63 | | - SSH_PWD: ${{ secrets.SSH_PWD }} |
64 | | - BOT_KEY: ${{ secrets.BOT_KEY }} |
| 50 | + publish-wheel: |
| 51 | + name: Publish wheel (${{ inputs.dry-run && 'Test PyPI' || 'PyPI' }}) |
| 52 | + runs-on: linux-amd64-cpu4 |
| 53 | + outputs: |
| 54 | + version: ${{ steps.build.outputs.version }} |
| 55 | + steps: |
| 56 | + - name: Checkout at release ref |
| 57 | + uses: actions/checkout@v6 |
| 58 | + with: |
| 59 | + ref: ${{ inputs.release-ref }} |
| 60 | + fetch-depth: 0 |
| 61 | + fetch-tags: true |
| 62 | + |
| 63 | + - name: Install uv |
| 64 | + uses: astral-sh/setup-uv@v6 |
| 65 | + with: |
| 66 | + enable-cache: true |
| 67 | + |
| 68 | + - name: Set up Python |
| 69 | + uses: actions/setup-python@v6 |
| 70 | + with: |
| 71 | + python-version-file: ".python-version" |
| 72 | + |
| 73 | + - name: Build wheel |
| 74 | + id: build |
| 75 | + run: | |
| 76 | + make build-wheel |
| 77 | + WHEEL=$(ls dist/*.whl) |
| 78 | + VERSION=$(echo "$WHEEL" | sed -n 's/.*-\([0-9][^-]*\)-.*/\1/p') |
| 79 | + echo "version=$VERSION" >> "$GITHUB_OUTPUT" |
| 80 | + echo "Built: $WHEEL (version $VERSION)" |
| 81 | +
|
| 82 | + - uses: actions/upload-artifact@v7 |
| 83 | + with: |
| 84 | + name: nemo-safe-synthesizer-${{ steps.build.outputs.version }} |
| 85 | + path: dist/*.whl |
| 86 | + retention-days: 90 |
| 87 | + |
| 88 | + - name: Publish to Test PyPI (always, as pre-flight) |
| 89 | + env: |
| 90 | + TWINE_USERNAME: __token__ |
| 91 | + TWINE_PASSWORD: ${{ secrets.TEST_PYPI_PERSONAL_TOKEN }} |
| 92 | + run: | |
| 93 | + uvx twine upload \ |
| 94 | + --repository-url https://test.pypi.org/legacy/ \ |
| 95 | + --skip-existing \ |
| 96 | + --non-interactive \ |
| 97 | + --verbose \ |
| 98 | + dist/*.whl |
| 99 | +
|
| 100 | + - name: Publish to PyPI |
| 101 | + if: ${{ !inputs.dry-run }} |
| 102 | + env: |
| 103 | + TWINE_USERNAME: __token__ |
| 104 | + TWINE_PASSWORD: ${{ secrets.PYPI_PERSONAL_TOKEN }} |
| 105 | + run: | |
| 106 | + uvx twine upload \ |
| 107 | + --non-interactive \ |
| 108 | + --verbose \ |
| 109 | + dist/*.whl |
| 110 | +
|
| 111 | + create-gh-release: |
| 112 | + name: Create GitHub release |
| 113 | + needs: publish-wheel |
| 114 | + if: ${{ inputs.create-gh-release }} |
| 115 | + runs-on: ubuntu-latest |
| 116 | + steps: |
| 117 | + - name: Checkout at release ref |
| 118 | + uses: actions/checkout@v6 |
| 119 | + with: |
| 120 | + ref: ${{ inputs.release-ref }} |
| 121 | + fetch-depth: 0 |
| 122 | + |
| 123 | + - name: Download wheel artifact |
| 124 | + uses: actions/download-artifact@v4 |
| 125 | + with: |
| 126 | + name: nemo-safe-synthesizer-${{ needs.publish-wheel.outputs.version }} |
| 127 | + path: dist/ |
| 128 | + |
| 129 | + - name: Create GitHub release |
| 130 | + env: |
| 131 | + GH_TOKEN: ${{ github.token }} |
| 132 | + VERSION: ${{ needs.publish-wheel.outputs.version }} |
| 133 | + run: | |
| 134 | + PRERELEASE_FLAG="" |
| 135 | + if echo "$VERSION" | grep -qE '(rc|alpha|beta|\.dev)'; then |
| 136 | + PRERELEASE_FLAG="--prerelease" |
| 137 | + fi |
| 138 | +
|
| 139 | + gh release create "v${VERSION}" \ |
| 140 | + dist/*.whl \ |
| 141 | + --title "v${VERSION}" \ |
| 142 | + --notes-file CHANGELOG.md \ |
| 143 | + $PRERELEASE_FLAG |
0 commit comments