From ad93952c527a2fb56a706e457878e2e1b700bc23 Mon Sep 17 00:00:00 2001 From: Hynek Schlawack Date: Sun, 24 Mar 2024 14:23:52 +0100 Subject: [PATCH] Add upload-name-suffix (#97) * Add upload-name-suffix So you can build more than one package per workflow. This also allows us to join our CI workflows again. Fixes #92 * add changelog entry * It's plural * It's only one CI again * Use de-dup for cross-platform testing * Add Windows * Clarify platform support * How does macOS not have a tree command --- .github/workflows/ci-structlog.yml | 35 ------------------- .../{ci-argon2-cffi-bindings.yml => ci.yml} | 24 ++++++++++++- CHANGELOG.md | 3 ++ README.md | 12 ++++++- action.yml | 11 ++++-- 5 files changed, 45 insertions(+), 40 deletions(-) delete mode 100644 .github/workflows/ci-structlog.yml rename .github/workflows/{ci-argon2-cffi-bindings.yml => ci.yml} (59%) diff --git a/.github/workflows/ci-structlog.yml b/.github/workflows/ci-structlog.yml deleted file mode 100644 index 6764664..0000000 --- a/.github/workflows/ci-structlog.yml +++ /dev/null @@ -1,35 +0,0 @@ ---- -name: CI w/ structlog - -on: - push: - branches: [main] - pull_request: - branches: [main] - workflow_dispatch: - -env: - FORCE_COLOR: "1" # Make tools pretty. - SETUPTOOLS_SCM_PRETEND_VERSION: "1.0" # avoid warnings about shallow checkout - -jobs: - check-structlog: - name: Build & verify the structlog package. - runs-on: ubuntu-latest - - steps: - - uses: actions/checkout@v4 - with: - repository: hynek/structlog - path: structlog - - - uses: actions/checkout@v4 - with: - path: action - - - uses: ./action - id: baipp - with: - path: structlog - - - run: echo Packages can be found at ${{ steps.baipp.outputs.dist }} diff --git a/.github/workflows/ci-argon2-cffi-bindings.yml b/.github/workflows/ci.yml similarity index 59% rename from .github/workflows/ci-argon2-cffi-bindings.yml rename to .github/workflows/ci.yml index a05281c..f792309 100644 --- a/.github/workflows/ci-argon2-cffi-bindings.yml +++ b/.github/workflows/ci.yml @@ -1,5 +1,5 @@ --- - name: CI w/ argon2-cffi-bindings + name: CI on: push: @@ -33,3 +33,25 @@ with: path: hynek/argon2-cffi-bindings skip-wheel: 'true' + + check-structlog: + name: Build & verify the structlog package. + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v4 + with: + repository: hynek/structlog + path: structlog + + - uses: actions/checkout@v4 + with: + path: action + + - uses: ./action + id: baipp + with: + path: structlog + upload-name-suffix: "-structlog" + + - run: echo Packages can be found at ${{ steps.baipp.outputs.dist }} diff --git a/CHANGELOG.md b/CHANGELOG.md index 0a98e47..ec3c868 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,6 +13,9 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), This is useful if you need to build your wheels using advanced tools like [*cibuildwheel*](https://cibuildwheel.pypa.io/) anyway. [#98](https://github.com/hynek/build-and-inspect-python-package/pull/98) +- New input: `upload-name-suffix` allows to build more than one package in a single workflow by distinguishing the artifact names. + [#97](https://github.com/hynek/build-and-inspect-python-package/pull/97) + ### Changed diff --git a/README.md b/README.md index 2bfa192..cb3f978 100644 --- a/README.md +++ b/README.md @@ -27,6 +27,8 @@ If you package an **application** as a Python package, this action is useful to ## Usage +This action only works on Linux runners: + ```yaml jobs: check-package: @@ -46,6 +48,8 @@ jobs: > - If you're using `download-artifact@v3`, you have to use `build-and-inspect-python-package@v1`. > - If you're using `download-artifact@v4`, you have to use `build-and-inspect-python-package@v2`. +While *build-and-inspect-python-package* will build a wheel for you by default, we recommend using [*cibuildwheel*] if your package contains compiled extensions. + ### Inputs @@ -53,8 +57,12 @@ jobs: - `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. - This is useful if you build your wheels using advanced tools like [*cibuildwheel*](https://cibuildwheel.pypa.io/) anyway. + This is useful if you build your wheels using advanced tools like [*cibuildwheel*] anyway. (*optional*, default: `'false'`). +- `upload-name-suffix`: A suffix to append to the artifact names to make them unique for `upload-artifact@v4`. + + Use this if you want to build multiple packages in one workflow. + (*optional*, default: `''`). ### Outputs @@ -84,3 +92,5 @@ After a successful run, you'll find multiple artifacts in the run's Summary view The scripts and documentation in this project are released under the [MIT License](LICENSE). [automated]: https://github.com/python-attrs/attrs/blob/main/.github/workflows/pypi-package.yml + +[*cibuildwheel*]: https://cibuildwheel.pypa.io/ diff --git a/action.yml b/action.yml index 6a526ca..7f61484 100644 --- a/action.yml +++ b/action.yml @@ -15,6 +15,10 @@ inputs: description: Only build the source distribution. required: false default: 'false' + upload-name-suffix: + description: Suffix to append to the artifact names. + required: false + default: "" outputs: dist: description: The location of the built packages. @@ -32,6 +36,7 @@ runs: - name: Install uv run: curl -LsSf https://astral.sh/uv/install.sh | sh shell: bash + if: runner.os != 'Windows' - name: Find uv cache run: echo "UV_CACHE=$(uv cache dir)" >>$GITHUB_ENV @@ -86,7 +91,7 @@ runs: - name: Upload built artifacts. uses: actions/upload-artifact@v4 with: - name: Packages + name: Packages${{ inputs.upload-name-suffix }} path: /tmp/baipp/dist/* - name: Check wheel contents if one was built @@ -136,7 +141,7 @@ runs: - name: Upload metadata uses: actions/upload-artifact@v4 with: - name: Package Metadata + name: Package Metadata${{ inputs.upload-name-suffix }} path: /tmp/baipp/dist/out/sdist/*/PKG-INFO - name: Extract PyPI README @@ -159,5 +164,5 @@ runs: - name: Upload PyPI README uses: actions/upload-artifact@v4 with: - name: PyPI README + name: PyPI README${{ inputs.upload-name-suffix }} path: /tmp/baipp/dist/out/sdist/PyPI-README.*