Skip to content

Commit a272043

Browse files
committed
fix: release pipeline
1 parent eeaed08 commit a272043

File tree

1 file changed

+28
-33
lines changed

1 file changed

+28
-33
lines changed

.github/workflows/_release.yml

Lines changed: 28 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -70,16 +70,24 @@ jobs:
7070

7171
- name: Check Version
7272
id: check-version
73-
shell: bash
73+
shell: python
7474
working-directory: ${{ inputs.working-directory }}
7575
run: |
76-
echo pkg-name="$(python -c "import tomllib; print(tomllib.load(open('pyproject.toml', 'rb'))['project']['name'])")" >> $GITHUB_OUTPUT
77-
echo version="$(python -c "import tomllib; print(tomllib.load(open('pyproject.toml', 'rb'))['project']['version'])")" >> $GITHUB_OUTPUT
76+
import os
77+
import tomllib
78+
with open("pyproject.toml", "rb") as f:
79+
data = tomllib.load(f)
80+
pkg_name = data["project"]["name"]
81+
version = data["project"]["version"]
82+
with open(os.environ["GITHUB_OUTPUT"], "a") as f:
83+
f.write(f"pkg-name={pkg_name}\n")
84+
f.write(f"version={version}\n")
7885
7986
test-pypi-publish:
8087
needs:
8188
- build
82-
uses: ./.github/workflows/_test_release.yml
89+
uses:
90+
./.github/workflows/_test_release.yml
8391
permissions: write-all
8492
with:
8593
working-directory: ${{ inputs.working-directory }}
@@ -112,36 +120,24 @@ jobs:
112120

113121
- name: Set up Python + uv
114122
uses: "./.github/actions/uv_setup"
123+
id: setup-python
115124
with:
116125
python-version: ${{ env.PYTHON_VERSION }}
117126

127+
- uses: actions/download-artifact@v5
128+
with:
129+
name: dist
130+
path: ${{ inputs.working-directory }}/dist/
131+
118132
- name: Import published package
119133
shell: bash
120134
working-directory: ${{ inputs.working-directory }}
121135
env:
122136
PKG_NAME: ${{ needs.build.outputs.pkg-name }}
123137
VERSION: ${{ needs.build.outputs.version }}
124-
# Here we use:
125-
# - The default regular PyPI index as the *primary* index, meaning
126-
# that it takes priority (https://pypi.org/simple)
127-
# - The test PyPI index as an extra index, so that any dependencies that
128-
# are not found on test PyPI can be resolved and installed anyway.
129-
# (https://test.pypi.org/simple). This will include the PKG_NAME==VERSION
130-
# package because VERSION will not have been uploaded to regular PyPI yet.
131-
# - attempt install again after 5 seconds if it fails because there is
132-
# sometimes a delay in availability on test pypi
133138
run: |
134-
uv pip install \
135-
--index-strategy unsafe-best-match \
136-
--extra-index-url https://test.pypi.org/simple/ \
137-
"$PKG_NAME==$VERSION" || \
138-
( \
139-
sleep 5 && \
140-
uv pip install \
141-
--index-strategy unsafe-best-match \
142-
--extra-index-url https://test.pypi.org/simple/ \
143-
"$PKG_NAME==$VERSION" \
144-
)
139+
uv venv
140+
VIRTUAL_ENV=.venv uv pip install dist/*.whl
145141
146142
# Replace all dashes in the package name with underscores,
147143
# since that's how Python imports packages with dashes in the name.
@@ -153,18 +149,15 @@ jobs:
153149
run: uv sync --group test --group test_integration
154150
working-directory: ${{ inputs.working-directory }}
155151

156-
# Overwrite the local version of the package with the test PyPI version.
152+
# Overwrite the local version of the package with the built version
157153
- name: Import published package (again)
158154
working-directory: ${{ inputs.working-directory }}
159155
shell: bash
160156
env:
161157
PKG_NAME: ${{ needs.build.outputs.pkg-name }}
162158
VERSION: ${{ needs.build.outputs.version }}
163159
run: |
164-
uv pip install \
165-
--index-strategy unsafe-best-match \
166-
--extra-index-url https://test.pypi.org/simple/ \
167-
"$PKG_NAME==$VERSION"
160+
VIRTUAL_ENV=.venv uv pip install dist/*.whl
168161
169162
- name: Run unit tests
170163
run: make tests
@@ -181,8 +174,9 @@ jobs:
181174
working-directory: ${{ inputs.working-directory }}
182175
id: min-version
183176
run: |
184-
uv pip install packaging
185-
min_versions="$(uv run python $GITHUB_WORKSPACE/.github/scripts/get_min_versions.py pyproject.toml release)"
177+
VIRTUAL_ENV=.venv uv pip install packaging requests
178+
python_version="$(uv run python --version | awk '{print $2}')"
179+
min_versions="$(uv run python $GITHUB_WORKSPACE/.github/scripts/get_min_versions.py pyproject.toml release $python_version)"
186180
echo "min-versions=$min_versions" >> "$GITHUB_OUTPUT"
187181
echo "min-versions=$min_versions"
188182
@@ -191,7 +185,7 @@ jobs:
191185
env:
192186
MIN_VERSIONS: ${{ steps.min-version.outputs.min-versions }}
193187
run: |
194-
uv pip install $MIN_VERSIONS
188+
VIRTUAL_ENV=.venv uv pip install $MIN_VERSIONS
195189
make tests
196190
working-directory: ${{ inputs.working-directory }}
197191

@@ -234,6 +228,7 @@ jobs:
234228
packages-dir: ${{ inputs.working-directory }}/dist/
235229
verbose: true
236230
print-hash: true
231+
# Temp workaround since attestations are on by default as of gh-action-pypi-publish v1\.11\.0
237232
attestations: false
238233

239234
mark-release:
@@ -269,7 +264,7 @@ jobs:
269264
- name: Create Release
270265
uses: ncipollo/release-action@v1
271266
with:
272-
artifacts: "${{ inputs.working-directory }}/dist/*"
267+
artifacts: "dist/*"
273268
token: ${{ secrets.GITHUB_TOKEN }}
274269
draft: false
275270
generateReleaseNotes: true

0 commit comments

Comments
 (0)