From ed2dda003446ccb483a9c68fd17a0fe634ba2451 Mon Sep 17 00:00:00 2001 From: Hynek Schlawack Date: Sat, 23 Mar 2024 14:48:50 +0100 Subject: [PATCH] Add skip-wheel to build only sdists --- .github/workflows/ci-argon2-cffi-bindings.yml | 1 + README.md | 3 +++ action.yml | 26 ++++++++++++++----- 3 files changed, 23 insertions(+), 7 deletions(-) diff --git a/.github/workflows/ci-argon2-cffi-bindings.yml b/.github/workflows/ci-argon2-cffi-bindings.yml index 329d617..a05281c 100644 --- a/.github/workflows/ci-argon2-cffi-bindings.yml +++ b/.github/workflows/ci-argon2-cffi-bindings.yml @@ -32,3 +32,4 @@ id: baipp with: path: hynek/argon2-cffi-bindings + skip-wheel: 'true' diff --git a/README.md b/README.md index 1332c20..2730188 100644 --- a/README.md +++ b/README.md @@ -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 diff --git a/action.yml b/action.yml index 003d63f..2719e2b 100644 --- a/action.yml +++ b/action.yml @@ -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. @@ -38,12 +42,16 @@ 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 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 + 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 }} @@ -66,6 +74,7 @@ runs: - run: /tmp/baipp/bin/check-wheel-contents /tmp/baipp/dist/*.whl shell: bash working-directory: ${{ inputs.path }} + if: ${{ inputs.skip-wheel }} != 'true' - name: Check PyPI README shell: bash @@ -82,17 +91,20 @@ runs: 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
SDist contents\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
\n' >> $GITHUB_STEP_SUMMARY - echo -e '\n
Wheel contents\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
\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
Wheel contents\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
\n' >> $GITHUB_STEP_SUMMARY + fi echo ----- Metadata Follows ----- echo -e '\n
Metadata\n' >> $GITHUB_STEP_SUMMARY