Skip to content

Commit 9fa1016

Browse files
authored
add release trigger that takes a tag as input (#3821)
This change to `release.yml` should allow us to use `workflow-dispatch`, i.e., manual triggering, to invoke the release workflow, with an explicit tag as input. This supports publishing a tagged release outside of the commit that creates that tag. This is useful for situations where we issued a release, but the github actions workflow was broken in some way that prevented us from uploading the release to pypi.
1 parent 93dd0e4 commit 9fa1016

File tree

1 file changed

+22
-2
lines changed

1 file changed

+22
-2
lines changed

.github/workflows/releases.yml

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,16 @@ on:
66
pull_request:
77
branches: [main]
88
workflow_dispatch:
9+
inputs:
10+
tag:
11+
description: 'Git tag to build and publish (e.g. v3.1.6)'
12+
required: true
13+
type: string
14+
test_pypi:
15+
description: 'Publish to Test PyPI instead of PyPI'
16+
required: false
17+
type: boolean
18+
default: true
919

1020
permissions:
1121
contents: read
@@ -25,6 +35,7 @@ jobs:
2535
steps:
2636
- uses: actions/checkout@v6
2737
with:
38+
ref: ${{ inputs.tag || github.ref }}
2839
submodules: true
2940
fetch-depth: 0
3041

@@ -61,10 +72,12 @@ jobs:
6172
upload_pypi:
6273
needs: [build_artifacts, test_dist_pypi]
6374
runs-on: ubuntu-latest
64-
if: github.event_name == 'push' && startsWith(github.event.ref, 'refs/tags/v')
75+
if: >-
76+
(github.event_name == 'push' && startsWith(github.event.ref, 'refs/tags/v'))
77+
|| github.event_name == 'workflow_dispatch'
6578
environment:
6679
name: releases
67-
url: https://pypi.org/p/zarr
80+
url: ${{ (github.event_name == 'workflow_dispatch' && inputs.test_pypi) && 'https://test.pypi.org/p/zarr' || 'https://pypi.org/p/zarr' }}
6881
permissions:
6982
id-token: write
7083
attestations: write
@@ -80,3 +93,10 @@ jobs:
8093
subject-path: dist/*
8194
- name: Publish package to PyPI
8295
uses: pypa/gh-action-pypi-publish@v1.13.0
96+
if: ${{ !(github.event_name == 'workflow_dispatch' && inputs.test_pypi) }}
97+
98+
- name: Publish package to Test PyPI
99+
uses: pypa/gh-action-pypi-publish@v1.13.0
100+
if: ${{ github.event_name == 'workflow_dispatch' && inputs.test_pypi }}
101+
with:
102+
repository-url: https://test.pypi.org/legacy/

0 commit comments

Comments
 (0)