Skip to content

Commit 77ca2e1

Browse files
Merge pull request #11 from nextmv-io/feature/publish-with-action
Use a GH action for publishing
2 parents e015878 + 1930fb2 commit 77ca2e1

File tree

1 file changed

+51
-21
lines changed

1 file changed

+51
-21
lines changed

.github/workflows/publish.yml

Lines changed: 51 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -12,16 +12,15 @@ on:
1212
default: false
1313
type: boolean
1414

15-
permissions:
16-
contents: write
17-
1815
jobs:
19-
publish:
16+
bump: # This job is used to bump the version and create a release
2017
runs-on: ubuntu-latest
2118
env:
2219
VERSION: ${{ inputs.VERSION }}
2320
GH_TOKEN: ${{ github.token }}
2421
SSH_AUTH_SOCK: /tmp/ssh_agent.sock
22+
permissions:
23+
contents: write
2524
steps:
2625
- name: set up Python
2726
uses: actions/setup-python@v4
@@ -31,7 +30,7 @@ jobs:
3130
- name: install dependencies
3231
run: |
3332
pip install --upgrade pip
34-
pip install build twine hatch
33+
pip install build hatch
3534
3635
- name: configure git with the bot credentials
3736
run: |
@@ -76,23 +75,54 @@ jobs:
7675
--title $VERSION $PRERELEASE_FLAG
7776
working-directory: ./nextmv-py
7877

79-
- name: build binary wheel and source tarball
80-
env:
81-
TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }}
82-
TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }}
78+
- name: ensure passing build
8379
run: python -m build
8480
working-directory: ./nextmv-py
8581

86-
- name: publish to TestPyPI
87-
env:
88-
TWINE_USERNAME: ${{ secrets.TESTPYPI_USERNAME }}
89-
TWINE_PASSWORD: ${{ secrets.TESTPYPI_PASSWORD }}
90-
run: twine upload --repository testpypi dist/*
91-
working-directory: ./nextmv-py
82+
publish: # This job is used to publish the release to PyPI/TestPyPI
83+
runs-on: ubuntu-latest
84+
needs: bump
85+
strategy:
86+
matrix:
87+
include:
88+
- target-env: pypi
89+
target-url: https://pypi.org/p/nextmv
90+
- target-env: testpypi
91+
target-url: https://test.pypi.org/p/nextmv
92+
environment:
93+
name: ${{ matrix.target-env }}
94+
url: ${{ matrix.target-url }}
95+
permissions:
96+
contents: read
97+
id-token: write # This is required for trusted publishing to PyPI
98+
steps:
99+
- name: git clone develop
100+
uses: actions/checkout@v4
101+
with:
102+
ref: develop
92103

93-
- name: publish to PyPI
94-
env:
95-
TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }}
96-
TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }}
97-
run: twine upload dist/*
98-
working-directory: ./nextmv-py
104+
- name: set up Python
105+
uses: actions/setup-python@v4
106+
with:
107+
python-version: "3.12"
108+
109+
- name: install dependencies
110+
run: |
111+
pip install --upgrade pip
112+
pip install build hatch
113+
114+
- name: build binary wheel and source tarball
115+
run: python -m build
116+
117+
- name: Publish package distributions to PyPI
118+
if: ${{ matrix.target-env == 'pypi' }}
119+
uses: pypa/gh-action-pypi-publish@release/v1
120+
with:
121+
packages-dir: ./dist
122+
123+
- name: Publish package distributions to TestPyPI
124+
if: ${{ matrix.target-env == 'testpypi' }}
125+
uses: pypa/gh-action-pypi-publish@release/v1
126+
with:
127+
repository-url: https://test.pypi.org/legacy/
128+
packages-dir: ./dist

0 commit comments

Comments
 (0)