Skip to content

Commit 73dcb8a

Browse files
authored
fix(ci): make the generated Simple Index tar file an actual release artifact (#1154)
Refs: 2a8412b
1 parent e95237a commit 73dcb8a

2 files changed

Lines changed: 18 additions & 12 deletions

File tree

.github/workflows/_build.yaml

Lines changed: 17 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ jobs:
9292
# profile picks the Hypothesis settings (see tests/conftest.py) which, for Github,
9393
# disable randomized testing to avoid breaking CI.
9494
- name: Build the package
95-
run: make dist
95+
run: make dist simple-index
9696
env:
9797
HYPOTHESIS_PROFILE: github
9898

@@ -119,24 +119,29 @@ jobs:
119119
shell: bash
120120
run: |
121121
set -euo pipefail
122-
TARBALL_PATH=$(find dist/ -type f -name "*.tar.gz")
123-
WHEEL_PATH=$(find dist/ -type f -name "*.whl")
124-
REQUIREMENTS_PATH=$(find dist/ -type f -name "*-requirements.txt")
125-
SBOM_PATH=$(find dist/ -type f -name "*-sbom.json")
126-
HTML_DOCS_PATH=$(find dist/ -type f -name "*-docs-html.zip")
127-
MARKDOWN_DOCS_PATH=$(find dist/ -type f -name "*-docs-md.zip")
128-
BUILD_EPOCH_PATH=$(find dist/ -type f -name "*-build-epoch.txt")
129-
DIGEST=$(sha256sum "$TARBALL_PATH" "$WHEEL_PATH" "$REQUIREMENTS_PATH" "$SBOM_PATH" "$HTML_DOCS_PATH" "$MARKDOWN_DOCS_PATH" "$BUILD_EPOCH_PATH" | base64 -w0)
122+
TARBALL_PATH=$(find dist/ -maxdepth 1 -type f -name "*.tar.gz")
123+
WHEEL_PATH=$(find dist/ -maxdepth 1 -type f -name "*.whl")
124+
SIMPLE_INDEX_PATH=$(find dist/ -maxdepth 1 -type f -name "*-simple-index.tar")
125+
REQUIREMENTS_PATH=$(find dist/ -maxdepth 1 -type f -name "*-requirements.txt")
126+
SBOM_PATH=$(find dist/ -maxdepth 1 -type f -name "*-sbom.json")
127+
HTML_DOCS_PATH=$(find dist/ -maxdepth 1 -type f -name "*-docs-html.zip")
128+
MARKDOWN_DOCS_PATH=$(find dist/ -maxdepth 1 -type f -name "*-docs-md.zip")
129+
BUILD_EPOCH_PATH=$(find dist/ -maxdepth 1 -type f -name "*-build-epoch.txt")
130+
DIGEST=$(sha256sum "$TARBALL_PATH" "$WHEEL_PATH" "$SIMPLE_INDEX_PATH" "$REQUIREMENTS_PATH" "$SBOM_PATH" "$HTML_DOCS_PATH" "$MARKDOWN_DOCS_PATH" "$BUILD_EPOCH_PATH" | base64 -w0)
130131
echo "Digest of artifacts is $DIGEST."
131132
echo "artifacts-sha256=$DIGEST" >> "$GITHUB_OUTPUT"
132133
133-
# For now only generate artifacts for the specified OS and Python version in env variables.
134-
# Currently reusable workflows do not support setting strategy property from the caller workflow.
134+
# For now only generate artifacts for the specified OS and Python version in env
135+
# variables. Currently reusable workflows do not support setting strategy property
136+
# from the caller workflow. Furthermore, add only top-level files as artifacts;
137+
# do not copy the generated simple-index/ folder.
135138
- name: Upload the package artifact for debugging and release
136139
if: matrix.os == env.ARTIFACT_OS && matrix.python == env.ARTIFACT_PYTHON
137140
uses: actions/upload-artifact@330a01c490aca151604b8cf639adc76d48f6c5d4 # v5.0.0
138141
with:
139142
name: artifact-${{ matrix.os }}-python-${{ matrix.python }}
140-
path: dist
143+
path: |
144+
dist/*.*
145+
!dist/simple-index
141146
if-no-files-found: error
142147
retention-days: 7

Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -209,6 +209,7 @@ simple-index: dist/$(PACKAGE_NAME)-$(PACKAGE_VERSION)-py3-none-any.whl dist/$(PA
209209
echo -e "<!-- https://peps.python.org/pep-0503/ -->\n<!DOCTYPE html><html lang='en'><head><meta name='pypi:repository-version' content='1.3'><title>Simple Index: $(PROJECT_NAME)</title></head><body><a href='$(PACKAGE_NAME)-$(PACKAGE_VERSION)-py3-none-any.whl#sha256="$$(python -c "with open('dist/$(PACKAGE_NAME)-$(PACKAGE_VERSION)-py3-none-any.whl', 'rb') as f: import hashlib; print(hashlib.sha256(f.read()).hexdigest());")"'>$(PACKAGE_NAME)-$(PACKAGE_VERSION)-py3-none-any.whl</a><a href='$(PACKAGE_NAME)-$(PACKAGE_VERSION).tar.gz#sha256="$$(python -c "with open('dist/$(PACKAGE_NAME)-$(PACKAGE_VERSION).tar.gz', 'rb') as f: import hashlib; print(hashlib.sha256(f.read()).hexdigest());")"'>$(PACKAGE_NAME)-$(PACKAGE_VERSION).tar.gz</a></body></html>" > dist/simple-index/$(PROJECT_NAME)/index.html
210210
cp -f dist/$(PACKAGE_NAME)-$(PACKAGE_VERSION)-py3-none-any.whl dist/simple-index/$(PROJECT_NAME)/
211211
cp -f dist/$(PACKAGE_NAME)-$(PACKAGE_VERSION).tar.gz dist/simple-index/$(PROJECT_NAME)/
212+
python -m tarfile --create dist/$(PACKAGE_NAME)-$(PACKAGE_VERSION)-pep503-simple-index.tar dist/simple-index/
212213

213214
# Build the HTML and Markdown documentation from the package's source.
214215
DOCS_SOURCE := $(shell git ls-files docs/source)

0 commit comments

Comments
 (0)