Skip to content

Commit

Permalink
Add skip-wheel to build only sdists (#98)
Browse files Browse the repository at this point in the history
* Add skip-wheel to build only sdists

* fix

* fix

* I'm too dumb for GHA's if

And the docs are too bad

* jfc

* Be a good quoting citizen

* Add name

* oops

* 🙄

* comments
  • Loading branch information
hynek authored Mar 23, 2024
1 parent ab41294 commit 5034e57
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 11 deletions.
1 change: 1 addition & 0 deletions .github/workflows/ci-argon2-cffi-bindings.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,3 +32,4 @@
id: baipp
with:
path: hynek/argon2-cffi-bindings
skip-wheel: 'true'
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,9 @@ jobs:
### Inputs

- `path`: the location of the Python package to build (*optional*, default: `.`).
- `skip-wheel`: Whether to skip building the wheel in addition to the source distribution.
The only meaningful value is `'true'` (note the quotes – GitHub Actions only allow string inputs) and everything else is treated as falsey.
(*optional*, default: `'false'`).


### Outputs
Expand Down
39 changes: 28 additions & 11 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@ inputs:
description: Where to look for the Python package to inspect.
required: false
default: .
skip-wheel:
description: Only build the source distribution.
required: false
default: 'false'
outputs:
dist:
description: The location of the built packages.
Expand Down Expand Up @@ -38,12 +42,18 @@ runs:
install -r ${{ github.action_path }}/requirements/tools.txt
shell: bash

# Build SDist, then build wheel out of it.
# Build SDist, then build wheel out of it if the user didn't forbid it.
# Set 'SOURCE_DATE_EPOCH' based on the last commit for build
# reproducibility.
- run: >
SOURCE_DATE_EPOCH=$(git log -1 --pretty=%ct)
/tmp/baipp/bin/python -m build --outdir /tmp/baipp/dist
- name: Build package
run: |
export SOURCE_DATE_EPOCH=$(git log -1 --pretty=%ct)
if [[ "${{ inputs.skip-wheel }}" == "true" ]]; then
/tmp/baipp/bin/python -m build --sdist --outdir /tmp/baipp/dist
else
/tmp/baipp/bin/python -m build --outdir /tmp/baipp/dist
fi
shell: bash
working-directory: ${{ inputs.path }}

Expand All @@ -63,7 +73,11 @@ runs:
name: Packages
path: /tmp/baipp/dist/*

- run: /tmp/baipp/bin/check-wheel-contents /tmp/baipp/dist/*.whl
- name: Check wheel contents if one was built
run: |
if [[ "${{ inputs.skip-wheel }}" != 'true' ]]; then
/tmp/baipp/bin/check-wheel-contents /tmp/baipp/dist/*.whl
fi
shell: bash
working-directory: ${{ inputs.path }}

Expand All @@ -76,23 +90,26 @@ runs:
--strict
/tmp/baipp/dist/*
- name: Show wheel & SDist contents hierarchically, including metadata.
- name: Show package contents hierarchically, including metadata.
shell: bash
working-directory: ${{ inputs.path }}
run: |
cd /tmp/baipp/dist
mkdir -p out/sdist
mkdir -p out/wheels
/tmp/baipp/bin/python -m wheel unpack --dest out/wheels *.whl
tar xf *.tar.gz -C out/sdist
echo -e '\n<details><summary>SDist contents</summary>\n' >> $GITHUB_STEP_SUMMARY
(cd /tmp/baipp/dist/out/sdist && tree -Da --timefmt="%Y-%m-%dT%H:%M:%SZ" * | sed 's/^/ /' | tee -a $GITHUB_STEP_SUMMARY)
echo -e '\n</details>\n' >> $GITHUB_STEP_SUMMARY
echo -e '\n<details><summary>Wheel contents</summary>\n' >> $GITHUB_STEP_SUMMARY
(cd /tmp/baipp/dist/out/wheels && tree -Da --timefmt="%Y-%m-%dT%H:%M:%SZ" * | sed 's/^/ /' | tee -a $GITHUB_STEP_SUMMARY)
echo -e '\n</details>\n' >> $GITHUB_STEP_SUMMARY
if [[ "${{ inputs.skip-wheel }}" != 'true' ]]; then
mkdir -p out/wheels
/tmp/baipp/bin/python -m wheel unpack --dest out/wheels *.whl
echo -e '\n<details><summary>Wheel contents</summary>\n' >> $GITHUB_STEP_SUMMARY
(cd /tmp/baipp/dist/out/wheels && tree -Da --timefmt="%Y-%m-%dT%H:%M:%SZ" * | sed 's/^/ /' | tee -a $GITHUB_STEP_SUMMARY)
echo -e '\n</details>\n' >> $GITHUB_STEP_SUMMARY
fi
echo ----- Metadata Follows -----
echo -e '\n<details><summary>Metadata</summary>\n' >> $GITHUB_STEP_SUMMARY
Expand Down

0 comments on commit 5034e57

Please sign in to comment.