Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 14 additions & 5 deletions .github/workflows/publish-libs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,16 @@
# A release is a change to a lib's VERSION file on master: every lib whose
# VERSION changed in the push is built and published at that version.
#
# From the Actions tab, `package` republishes one lib (its directory name under
# libs/) at its current VERSION, e.g. if a publish failed part way.
# From the Actions tab, `package` publishes one lib (its directory name under
# libs/) at its current VERSION, or `all` of them. `all` skips versions already
# on PyPI, so it publishes only what is missing: the first release of each lib,
# or what a run that failed part way left out.
#
# Publishing uses PyPI Trusted Publishing, so no token is stored here. A lib is
# published only once its PyPI project has a publisher for this repository,
# this workflow file and the `pypi` environment; for any other lib the upload
# fails. Uploading a version that is already on PyPI also fails.
# fails. On a push or for a named lib, uploading a version that is already on
# PyPI also fails: VERSION was not bumped, or that version is already out.
name: Publish libs to PyPI

on:
Expand All @@ -21,7 +24,7 @@ on:
workflow_dispatch:
inputs:
package:
description: "Lib to publish: its directory under libs/, e.g. lando-client"
description: "Lib to publish: its directory under libs/ (e.g. lando-client), or all"
required: true
type: string

Expand All @@ -43,7 +46,9 @@ jobs:
BEFORE: ${{ github.event.before }}
INPUT_PACKAGE: ${{ inputs.package }}
run: |
if [ -n "$INPUT_PACKAGE" ]; then
if [ "$INPUT_PACKAGE" = "all" ]; then
packages=$(printf '%s\n' libs/*/VERSION | cut -d/ -f2)
elif [ -n "$INPUT_PACKAGE" ]; then
if [[ "$INPUT_PACKAGE" == */* || ! -f "libs/$INPUT_PACKAGE/VERSION" ]]; then
echo "::error::libs/$INPUT_PACKAGE/VERSION does not exist"
exit 1
Expand Down Expand Up @@ -97,3 +102,7 @@ jobs:
path: dist/

- uses: pypa/gh-action-pypi-publish@release/v1
with:
# Only `all` publishes "whatever is missing". A push or a named lib
# asks for that exact version, so one already on PyPI fails the run.
skip-existing: ${{ inputs.package == 'all' }}