Skip to content

Commit 728d2a0

Browse files
authored
Fix: separate build and publish steps in CI (#145)
* Fix: separate build and publish steps in CI * Fix: align upload and download artifact version
1 parent a76ba97 commit 728d2a0

File tree

2 files changed

+30
-15
lines changed

2 files changed

+30
-15
lines changed

.github/workflows/publish-pypi.yml

Lines changed: 28 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,14 @@ on:
66
branches:
77
- main
88
jobs:
9-
build-publish:
9+
# setup build separate from publish
10+
# See https://github.com/pypa/gh-action-pypi-publish/issues/217#issuecomment-1965727093
11+
build:
1012
runs-on: ubuntu-latest
1113
# This ensures that the publish action only runs in the main repository
1214
# rather than forks
1315
# Environment is encouraged so adding
14-
environment: release
15-
if: github.repository_owner == 'pyopensci'
16-
permissions:
17-
id-token: write # this permission is mandatory for pypi publishing
16+
environment: build
1817
steps:
1918
- name: Checkout
2019
uses: actions/checkout@v4
@@ -42,17 +41,31 @@ jobs:
4241
echo ""
4342
echo "Generated files:"
4443
ls -lh dist/
45-
46-
- name: Publish package on test PyPI on merge in main branch
47-
# Test push to test pypi on merge to main
48-
if: github.event_name == 'push'
49-
uses: pypa/gh-action-pypi-publish@release/v1
44+
# Store an artifact of the build to use in the publish step below
45+
- name: Store the distribution packages
46+
uses: actions/upload-artifact@v4
5047
with:
51-
repository-url: https://test.pypi.org/legacy/
52-
# Allow existing releases on test PyPI without errors.
53-
# NOT TO BE USED in PyPI!
54-
skip-existing: true
55-
48+
name: python-package-distributions
49+
path: dist/
50+
publish:
51+
name: >-
52+
Publish Python 🐍 distribution 📦 to PyPI
53+
if: github.repository_owner == 'pyopensci'
54+
needs:
55+
- build
56+
runs-on: ubuntu-latest
57+
environment:
58+
name: pypi
59+
url: https://pypi.org/p/pyosmeta
60+
permissions:
61+
id-token: write # this permission is mandatory for pypi publishing
62+
steps:
63+
# Version 4 doesn't support github enterprise yet
64+
- name: Download all the dists
65+
uses: actions/download-artifact@v4
66+
with:
67+
name: python-package-distributions
68+
path: dist/
5669
- name: Publish package to PyPI
5770
# Only publish to real PyPI on release
5871
if: github.event_name == 'release'

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@
1313
- Add: support for partners and emeritus_editor in contributor model (@lwasser, #133)
1414
- Fix: Refactor all contributor GitHub related methods into gh_client module from contributors module (@lwasser, #125)
1515
- Fix: Add support for pagination in github issue requests (@lwasser, #139)
16+
- Fix: update ci workflow versions (@willingc, #113)
17+
- Fix: separate build from publish steps for added security in pypi publish workflow (@lwasser, #113)
1618

1719

1820
## [v0.2.3] - 2024-02-29

0 commit comments

Comments
 (0)