diff --git a/.github/workflows/sign.yml b/.github/workflows/sign.yml index 38b1a29..049d178 100644 --- a/.github/workflows/sign.yml +++ b/.github/workflows/sign.yml @@ -16,6 +16,11 @@ on: description: Name of the package on PyPI required: true type: string + version: + description: Version on PyPI, when it differs from the tag without its leading v + required: false + default: '' + type: string request_id: description: Only used by ppt to find this run required: false @@ -30,19 +35,21 @@ concurrency: jobs: sign: + name: Sign the PyPI files of the release runs-on: ubuntu-latest timeout-minutes: 30 permissions: - contents: write - id-token: write + contents: write # upload the bundles and missing files to the release + id-token: write # the OIDC token Sigstore signs with env: GH_REPO: ${{ github.repository }} TAG: ${{ inputs.tag }} PACKAGE: ${{ inputs.package }} + PYPI_VERSION: ${{ inputs.version }} steps: - name: Validate inputs run: | - if ! [[ "$TAG" =~ ^v?[0-9][0-9A-Za-z.+!-]*$ ]]; then + if ! [[ "$TAG" =~ ^v?[0-9][0-9A-Za-z._+!-]*$ ]]; then echo "Invalid tag input" >&2 exit 1 fi @@ -50,6 +57,10 @@ jobs: echo "Invalid package input" >&2 exit 1 fi + if [ -n "$PYPI_VERSION" ] && ! [[ "$PYPI_VERSION" =~ ^v?[0-9][0-9A-Za-z._+!-]*$ ]]; then + echo "Invalid version input" >&2 + exit 1 + fi - name: Read the release env: @@ -95,7 +106,10 @@ jobs: TAG: str = os.environ['TAG'] PACKAGE: str = os.environ['PACKAGE'] - VERSION: str = TAG[1:] if TAG.startswith('v') else TAG + # The version input when ppt passes one, else the tag without its v. + VERSION: str = os.environ.get('PYPI_VERSION') or ( + TAG[1:] if TAG.startswith('v') else TAG + ) URL_TEMPLATE: str = os.environ.get( 'PYPI_JSON_URL', 'https://pypi.org/pypi/{package}/{version}/json' )