Skip to content

Commit e7e0e7e

Browse files
authored
Merge pull request #75 from mcflugen/mcflugen/add-publish-step
Publish to pypi/testpypi on manual trigger of GHA
2 parents 7b9f23b + edc4f34 commit e7e0e7e

1 file changed

Lines changed: 42 additions & 2 deletions

File tree

.github/workflows/test.yml

Lines changed: 42 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,23 @@
11
name: Test
22

3-
on: [push, pull_request]
3+
on:
4+
pull_request:
5+
push:
6+
branches: ["**"]
7+
workflow_dispatch:
8+
inputs:
9+
publish_to:
10+
description: Where to publish
11+
type: choice
12+
required: true
13+
default: none
14+
options:
15+
- none
16+
- testpypi
17+
- pypi
418

519
jobs:
6-
build-and-test:
20+
test:
721
# We want to run on external PRs, but not on our own internal PRs as they'll be run
822
# by the push to the branch. Without this if check, checks are duplicated since
923
# internal PRs match both the push and pull_request events.
@@ -39,3 +53,29 @@ jobs:
3953
uses: codecov/codecov-action@v6
4054
with:
4155
token: ${{ secrets.CODECOV_TOKEN }}
56+
57+
publish:
58+
needs: [test]
59+
runs-on: ubuntu-latest
60+
if: github.event_name == 'workflow_dispatch' && inputs.publish_to != 'none'
61+
env:
62+
REPOSITORY_URL: ${{ inputs.publish_to == 'testpypi' && 'https://test.pypi.org/legacy/' || 'https://upload.pypi.org/legacy/' }}
63+
64+
permissions:
65+
id-token: write
66+
67+
steps:
68+
- uses: actions/download-artifact@v8
69+
with:
70+
pattern: build-*
71+
merge-multiple: true
72+
path: ${{ github.workspace }}/dist
73+
74+
- name: Publish
75+
uses: pypa/gh-action-pypi-publish@release/v1
76+
with:
77+
repository-url: ${{ env.REPOSITORY_URL }}
78+
packages-dir: dist
79+
skip-existing: true
80+
print-hash: true
81+
verify-metadata: false

0 commit comments

Comments
 (0)