Skip to content

Commit 74858d7

Browse files
authored
Merge pull request #32 from blowekamp/gha_add_publish_workflow
Create separate publish GH Action
2 parents acb19db + 08fe37c commit 74858d7

File tree

2 files changed

+50
-21
lines changed

2 files changed

+50
-21
lines changed

.github/workflows/main.yml

Lines changed: 2 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -60,11 +60,8 @@ jobs:
6060
6161
publish:
6262
needs: test
63-
name: Upload release to PyPI
63+
name: Create Artifact
6464
runs-on: ubuntu-latest
65-
permissions:
66-
id-token: write # IMPORTANT: this permission is mandatory for trusted publishing
67-
contents: write
6865
steps:
6966
- uses: actions/checkout@v3
7067
with:
@@ -84,20 +81,4 @@ jobs:
8481
uses: actions/upload-artifact@v3
8582
with:
8683
name: python-packages
87-
path: dist
88-
- name: Create Release and Upload
89-
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v')
90-
id: create_release
91-
env:
92-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
93-
run: |
94-
gh release create ${{ github.ref_name }} --repo ${{ github.repository }} --verify-tag --generate-notes --title "Release ${{ github.ref_name }}"
95-
gh release upload ${{ github.ref_name }} --repo ${{ github.repository }} dist/*
96-
97-
98-
- name: PyPI Publish package
99-
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v')
100-
# hash for release/v1.8
101-
uses: pypa/gh-action-pypi-publish@0bf742be3ebe032c25dd15117957dc15d0cfc38d
102-
with:
103-
password: ${{ secrets.PYPI_API_TOKEN }}
84+
path: dist

.github/workflows/publish.yml

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
name: Publish Package
2+
3+
on:
4+
push:
5+
tags:
6+
- 'v*'
7+
8+
concurrency:
9+
group: publish
10+
11+
12+
jobs:
13+
publish:
14+
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v')
15+
name: Upload release to Github Releases and PyPI
16+
runs-on: ubuntu-latest
17+
permissions:
18+
id-token: write
19+
contents: write
20+
environment: publish
21+
steps:
22+
- uses: actions/checkout@v3
23+
with:
24+
fetch-depth: 0
25+
- name: Set up Python 3.11
26+
uses: actions/setup-python@v4
27+
with:
28+
python-version: "3.11"
29+
- name: Build package
30+
run: |
31+
python -m pip install twine build
32+
python -m build --wheel --sdist
33+
python -m twine check dist/*
34+
ls -la dist
35+
- name: Create Release and Upload
36+
id: create_release
37+
env:
38+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
39+
run: |
40+
gh release create ${{ github.ref_name }} --repo ${{ github.repository }} --verify-tag --generate-notes --title "Release ${{ github.ref_name }}"
41+
gh release upload ${{ github.ref_name }} --repo ${{ github.repository }} dist/*
42+
43+
44+
- name: PyPI Publish package
45+
# hash for release/v1.8
46+
uses: pypa/gh-action-pypi-publish@0bf742be3ebe032c25dd15117957dc15d0cfc38d
47+
with:
48+
password: ${{ secrets.PYPI_API_TOKEN }}

0 commit comments

Comments
 (0)