Repository navigation
168 lines (160 loc) · 7.07 KB
/
Copy pathrelease.yml
File metadata and controls
168 lines (160 loc) · 7.07 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
# SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
# SPDX-License-Identifier: Apache-2.0
name: Publish GitHub Release
on:
# PyPI Trusted Publishing rejects pull_request_target events.
pull_request:
branches: ["main"]
types: [closed]
workflow_dispatch:
inputs:
release_tag:
description: Published GitHub release tag
required: true
type: string
index:
description: Python package index (must match SKILLSPECTOR_PUBLISH_INDEX)
required: true
type: choice
options: [testpypi, pypi]
wheel_sha256:
description: SHA-256 of the approved wheel
required: true
type: string
sdist_sha256:
description: SHA-256 of the approved source distribution
required: true
type: string
permissions:
contents: read
concurrency:
group: ${{ github.event_name == 'workflow_dispatch' && 'publish-existing-github-release' || 'publish-github-release' }}
cancel-in-progress: false
env:
UV_VERSION: "0.10.10"
PYTHON_VERSION: "3.12"
UV_CACHE_DIR: .uv-cache
UV_LINK_MODE: copy
jobs:
publish:
if: >-
github.event_name == 'pull_request' &&
github.event.pull_request.merged == true &&
contains(github.event.pull_request.labels.*.name, 'release:publish')
runs-on: ubuntu-latest
permissions:
contents: write
outputs:
distribution-artifact: release-distributions-${{ github.run_attempt }}
distribution-index: ${{ vars.SKILLSPECTOR_PUBLISH_INDEX }}
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
with:
ref: ${{ github.event.pull_request.merge_commit_sha }}
persist-credentials: false
- name: Set up uv
# Pinned to a full commit SHA (third-party action); comment tracks the tag.
uses: astral-sh/setup-uv@d4b2f3b6ecc6e67c4457f6d3e41ec42d3d0fcb86 # v5.4.2
with:
version: "${{ env.UV_VERSION }}"
enable-cache: true
cache-dependency-glob: uv.lock
python-version: "${{ env.PYTHON_VERSION }}"
- name: Install locked build tooling
run: uv sync --locked --extra dev --no-install-project
- name: Build and validate distribution artifacts
run: |
uv run --no-sync python -m build --no-isolation
uv run --no-sync twine check dist/*
uv run --no-sync python scripts/release/public/check_distribution_assets.py dist/*.whl dist/*.tar.gz
- name: Create the GitHub release
env:
GH_TOKEN: ${{ github.token }}
run: |
python scripts/release/public/create_github_release.py \
--repository "$GITHUB_REPOSITORY" \
--target "${{ github.event.pull_request.merge_commit_sha }}" \
--asset dist/*.whl \
--asset dist/*.tar.gz
- name: Save validated distributions for index publishing
if: github.repository == 'NVIDIA/SkillSpector'
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
with:
name: release-distributions-${{ github.run_attempt }}
path: |
dist/*.whl
dist/*.tar.gz
if-no-files-found: error
prepare-existing-release:
if: >-
github.event_name == 'workflow_dispatch' &&
github.repository == 'NVIDIA/SkillSpector' &&
github.ref == 'refs/heads/main'
runs-on: ubuntu-latest
outputs:
distribution-artifact: release-distributions-${{ github.run_attempt }}
distribution-index: ${{ inputs.index }}
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
with:
persist-credentials: false
- name: Verify and download existing distributions
env:
GH_TOKEN: ${{ github.token }}
RELEASE_TAG: ${{ inputs.release_tag }}
REQUESTED_INDEX: ${{ inputs.index }}
CONFIGURED_INDEX: ${{ vars.SKILLSPECTOR_PUBLISH_INDEX }}
WHEEL_SHA256: ${{ inputs.wheel_sha256 }}
SDIST_SHA256: ${{ inputs.sdist_sha256 }}
run: |
if [[ "$REQUESTED_INDEX" != "$CONFIGURED_INDEX" ]]; then
echo "::error::Set SKILLSPECTOR_PUBLISH_INDEX to the requested index before dispatch."
exit 1
fi
python3 scripts/release/public/download_release_distributions.py \
--repository "$GITHUB_REPOSITORY" --tag "$RELEASE_TAG" \
--wheel-sha256 "$WHEEL_SHA256" --sdist-sha256 "$SDIST_SHA256" --output dist
- name: Save verified distributions for index publishing
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
with:
name: release-distributions-${{ github.run_attempt }}
path: |
dist/*.whl
dist/*.tar.gz
if-no-files-found: error
publish-index:
name: Publish to Python package index
needs: [publish, prepare-existing-release]
# The preparation job for the other event is skipped.
if: >-
!cancelled() &&
github.repository == 'NVIDIA/SkillSpector' &&
((needs.publish.result == 'success' &&
github.event.pull_request.head.repo.full_name == github.repository) ||
needs.prepare-existing-release.result == 'success') &&
vars.SKILLSPECTOR_PUBLISH_INDEX == (needs.publish.outputs.distribution-index || needs.prepare-existing-release.outputs.distribution-index) &&
contains(fromJSON('["pypi", "testpypi"]'), vars.SKILLSPECTOR_PUBLISH_INDEX)
runs-on: ubuntu-latest
environment:
name: ${{ (needs.publish.outputs.distribution-index || needs.prepare-existing-release.outputs.distribution-index) == 'pypi' && 'pypi-production' || 'pypi-test' }}
url: ${{ (needs.publish.outputs.distribution-index || needs.prepare-existing-release.outputs.distribution-index) == 'pypi' && 'https://pypi.org/project/skillspector/' || 'https://test.pypi.org/project/skillspector/' }}
permissions:
id-token: write
steps:
- name: Download validated release artifacts
uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4.3.0
with:
name: ${{ needs.publish.outputs.distribution-artifact || needs.prepare-existing-release.outputs.distribution-artifact }}
path: dist
- name: Set up uv
uses: astral-sh/setup-uv@d4b2f3b6ecc6e67c4457f6d3e41ec42d3d0fcb86 # v5.4.2
with:
version: "${{ env.UV_VERSION }}"
enable-cache: false
- name: Upload distributions with Trusted Publishing
env:
PUBLISH_URL: ${{ (needs.publish.outputs.distribution-index || needs.prepare-existing-release.outputs.distribution-index) == 'pypi' && 'https://upload.pypi.org/legacy/' || 'https://test.pypi.org/legacy/' }}
CHECK_URL: ${{ (needs.publish.outputs.distribution-index || needs.prepare-existing-release.outputs.distribution-index) == 'pypi' && 'https://pypi.org/simple/' || 'https://test.pypi.org/simple/' }}
run: |
uv publish --no-config --trusted-publishing always \
--publish-url "$PUBLISH_URL" --check-url "$CHECK_URL" dist/*