Skip to content

Commit 4f8d4f3

Browse files
committed
Refactor publishing workflow
1 parent 2dde25a commit 4f8d4f3

2 files changed

Lines changed: 29 additions & 23 deletions

File tree

.github/workflows/pypi-publish.yml

Lines changed: 19 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
name: "Publish Python distribution to PyPI"
22
# Uses:
3-
# https://github.com/actions/setup-python : 0b93645e9fea7318ecaed2b359559ac225c90a2b
3+
# https://github.com/actions/setup-python : a26af69be951a213d495a4c3e4e4022e16d87065
44
# https://github.com/actions/checkout : 11bd71901bbe5b1630ceea73d27597364c9af683
5-
# https://github.com/actions/download-artifact : fa0a91b85d4f404e444e00e005971372dc801d16
6-
# https://github.com/actions/upload-artifact : 6f51ac03b9356f520e9adb1b1b7802705f340c2b
5+
# https://github.com/actions/download-artifact : d3f86a106a0bac45b974a628896c90dbdf5c8093
6+
# https://github.com/actions/upload-artifact : ea165f8d65b6e75b540449e92b4886f43607fa02
77
# https://github.com/actions/pypa/gh-action-pypi-publish : 76f52bc884231f62b9a034ebfe128415bbaabdfc
88

99
on:
@@ -12,45 +12,50 @@ on:
1212

1313
jobs:
1414
build:
15-
name: "Build distribution"
15+
name: "Build package"
1616
runs-on: "ubuntu-latest"
17+
outputs:
18+
artifact-id: "${{ steps.upload-artifact.outputs.artifact-id }}"
1719

1820
steps:
1921
- uses: "actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683"
2022
with:
2123
persist-credentials: false
2224

2325
- name: "Set up Python"
24-
uses: "actions/setup-python@0b93645e9fea7318ecaed2b359559ac225c90a2b"
26+
uses: "actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065"
2527
with:
2628
python-version: "3.12"
2729

2830
- name: "Build the package"
29-
run: "python -m pip install nox; nox --session build"
31+
run: "python -m pip install nox; nox -s build"
3032

3133
- name: "Store the distribution packages"
32-
uses: "actions/upload-artifact@6f51ac03b9356f520e9adb1b1b7802705f340c2b"
34+
id: "upload-artifact"
35+
uses: "actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02"
3336
with:
34-
name: "python-package-distributions"
35-
path: "dist/"
37+
path: "./dist"
3638

3739
publish-to-pypi:
3840
name: "Publish Python Distribution to PyPI"
39-
if: startsWith(github.ref, 'refs/tags/')
4041
needs: ["build"]
4142
runs-on: "ubuntu-latest"
4243
environment:
4344
name: "pypi"
44-
url: "https://pypi.org/p/commented-configparser"
45+
url: "https://pypi.org/project/commented-configparser/"
4546
permissions:
4647
id-token: "write"
4748

4849
steps:
4950
- name: "Download all the dists"
50-
uses: "actions/download-artifact@fa0a91b85d4f404e444e00e005971372dc801d16"
51+
uses: "actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093"
5152
with:
52-
name: "python-package-distributions"
53-
path: "dist/"
53+
artifact-ids: "${{ needs.build.outputs.artifact-id }}"
54+
path: "./dist"
55+
merge-multiple: true
5456

5557
- name: "Publish distribution to PyPI"
5658
uses: "pypa/gh-action-pypi-publish@76f52bc884231f62b9a034ebfe128415bbaabdfc"
59+
with:
60+
repository-url: "https://upload.pypi.org/legacy/"
61+
verbose: true

.github/workflows/pypi-test-publish.yml

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,10 @@ on:
1313

1414
jobs:
1515
build:
16-
name: "Build test distribution"
16+
name: "Build package"
1717
runs-on: "ubuntu-latest"
1818
outputs:
19-
artifact-id: ${{ steps.upload-artifact.outputs.artifact-id }}
19+
artifact-id: "${{ steps.upload-artifact.outputs.artifact-id }}"
2020

2121
steps:
2222
- uses: "actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683"
@@ -29,33 +29,34 @@ jobs:
2929
python-version: "3.12"
3030

3131
- name: "Build the package"
32-
run: "python -m pip install nox; nox --session build"
32+
run: "python -m pip install nox; nox -s build"
3333

3434
- name: "Store the distribution packages"
3535
id: "upload-artifact"
3636
uses: "actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02"
3737
with:
38-
path: "dist/"
38+
path: "./dist"
3939

4040
publish-to-pypi:
41-
name: "Publish Python Distribution to PyPI Test"
41+
name: "Publish Python Distribution to PyPI"
4242
needs: ["build"]
4343
runs-on: "ubuntu-latest"
4444
environment:
4545
name: "testpypi"
46-
url: "https://pypi.org/p/commented-configparser"
46+
url: "https://test.pypi.org/project/commented-configparser/"
4747
permissions:
4848
id-token: "write"
4949

5050
steps:
5151
- name: "Download all the dists"
5252
uses: "actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093"
5353
with:
54-
artifact-ids: ${{ needs.build.outputs.artifact-id }}
55-
path: "dist/"
54+
artifact-ids: "${{ needs.build.outputs.artifact-id }}"
55+
path: "./dist"
5656
merge-multiple: true
5757

5858
- name: "Publish distribution to PyPI"
5959
uses: "pypa/gh-action-pypi-publish@76f52bc884231f62b9a034ebfe128415bbaabdfc"
6060
with:
61-
repository-url: https://test.pypi.org/legacy/
61+
repository-url: "https://test.pypi.org/legacy/"
62+
verbose: true

0 commit comments

Comments
 (0)