Skip to content

Commit 9abe999

Browse files
committed
feat: switch triggering workflow
1 parent c5ff293 commit 9abe999

File tree

3 files changed

+108
-34
lines changed

3 files changed

+108
-34
lines changed

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

Lines changed: 3 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
name: Publish Python 🐍 distribution 📦 to PyPI and TestPyPI
2-
3-
on: push
2+
on:
3+
release:
4+
types: [published]
45
jobs:
56
build:
67
name: Build distribution 📦
@@ -28,7 +29,6 @@ jobs:
2829
publish-to-pypi:
2930
name: >-
3031
Publish Python 🐍 distribution 📦 to PyPI
31-
if: startsWith(github.ref, 'refs/tags/') # only publish to PyPI on tag pushes
3232
needs:
3333
- build
3434
runs-on: ubuntu-latest
@@ -87,26 +87,3 @@ jobs:
8787
gh release upload
8888
'${{ github.ref_name }}' dist/**
8989
--repo '${{ github.repository }}'
90-
publish-to-testpypi:
91-
name: Publish Python 🐍 distribution 📦 to TestPyPI
92-
needs:
93-
- build
94-
runs-on: ubuntu-latest
95-
96-
environment:
97-
name: testpypi
98-
url: https://test.pypi.org/p/asyncapi_python_parser_jonaslagoni
99-
100-
permissions:
101-
id-token: write # IMPORTANT: mandatory for trusted publishing
102-
103-
steps:
104-
- name: Download all the dists
105-
uses: actions/download-artifact@v3
106-
with:
107-
name: python-package-distributions
108-
path: dist/
109-
- name: Publish distribution 📦 to TestPyPI
110-
uses: pypa/gh-action-pypi-publish@release/v1
111-
with:
112-
repository-url: https://test.pypi.org/legacy/

.github/workflows/semantic-release.yml

Lines changed: 95 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,37 @@ on:
77
- next
88

99
jobs:
10+
build:
11+
name: Build distribution 📦
12+
runs-on: ubuntu-latest
13+
14+
steps:
15+
- uses: actions/checkout@v4
16+
- name: Set up Python
17+
uses: actions/setup-python@v4
18+
with:
19+
python-version: "3.x"
20+
- name: Install pypa/build
21+
run: >-
22+
python3 -m
23+
pip install
24+
build
25+
--user
26+
- name: Build a binary wheel and a source tarball
27+
run: python3 -m build
28+
- name: Store the distribution packages
29+
uses: actions/upload-artifact@v3
30+
with:
31+
name: python-package-distributions
32+
path: dist/
1033
release:
1134
runs-on: ubuntu-latest
1235
concurrency: release
1336
permissions:
1437
id-token: write
1538
contents: write
16-
39+
needs:
40+
- build
1741
steps:
1842
- uses: actions/checkout@v3
1943
with:
@@ -22,4 +46,73 @@ jobs:
2246
- name: Python Semantic Release
2347
uses: python-semantic-release/python-semantic-release@master
2448
with:
25-
github_token: ${{ secrets.GH_TOKEN }}
49+
github_token: ${{ secrets.GH_TOKEN }}
50+
git_committer_name: jonaslagoni
51+
git_committer_email: jonas-lt@live.dk
52+
53+
54+
publish-to-pypi:
55+
name: >-
56+
Publish Python 🐍 distribution 📦 to PyPI
57+
if: steps.release.outputs.released == 'true'
58+
needs:
59+
- release
60+
runs-on: ubuntu-latest
61+
environment:
62+
name: pypi
63+
url: https://pypi.org/p/asyncapi_python_parser_jonaslagoni
64+
permissions:
65+
id-token: write # IMPORTANT: mandatory for trusted publishing
66+
steps:
67+
- name: Download all the dists
68+
uses: actions/download-artifact@v3
69+
with:
70+
name: python-package-distributions
71+
path: dist/
72+
- name: Publish distribution 📦 to PyPI
73+
uses: pypa/gh-action-pypi-publish@release/v1
74+
github-release:
75+
name: >-
76+
Sign the Python 🐍 distribution 📦 with Sigstore
77+
and upload them to GitHub Release
78+
needs:
79+
- publish-to-pypi
80+
runs-on: ubuntu-latest
81+
82+
permissions:
83+
contents: write # IMPORTANT: mandatory for making GitHub Releases
84+
id-token: write # IMPORTANT: mandatory for sigstore
85+
86+
steps:
87+
- name: Download all the dists
88+
uses: actions/download-artifact@v3
89+
with:
90+
name: python-package-distributions
91+
path: dist/
92+
- name: Sign the dists with Sigstore
93+
uses: sigstore/gh-action-sigstore-python@v1.2.3
94+
with:
95+
inputs: >-
96+
./dist/*.tar.gz
97+
./dist/*.whl
98+
- name: Create GitHub Release
99+
env:
100+
GITHUB_TOKEN: ${{ secrets.GH_TOKEN }}
101+
run: >-
102+
gh release create
103+
'${{ github.ref_name }}'
104+
--repo '${{ github.repository }}'
105+
--notes ""
106+
- name: Upload artifact signatures to GitHub Release
107+
env:
108+
GITHUB_TOKEN: ${{ secrets.GH_TOKEN }}
109+
# Upload to GitHub Release using the `gh` CLI.
110+
# `dist/` contains the built packages, and the
111+
# sigstore-produced signatures and certificates.
112+
run: >-
113+
gh release upload
114+
'${{ github.ref_name }}' dist/**
115+
--repo '${{ github.repository }}'
116+
117+
118+
released

pyproject.toml

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,18 +4,18 @@ build-backend = "hatchling.build"
44

55
[project]
66
name = "asyncapi_python_parser_jonaslagoni"
7-
version = "0.0.1"
7+
version = "0.0.2"
88
authors = [
99
{ name="jonaslagoni", email="jonas-lt@live.dk" },
1010
]
1111
description = "An AsyncAPI python parser, that supports all versions"
1212
readme = "README.md"
1313
requires-python = ">=3.7"
1414
classifiers = [
15-
"Programming Language :: Python :: 3",
16-
"License :: OSI Approved :: Apache Software License",
17-
"Operating System :: OS Independent",
18-
"Development Status :: 2 - Pre-Alpha",
15+
"Programming Language :: Python :: 3",
16+
"License :: OSI Approved :: Apache Software License",
17+
"Operating System :: OS Independent",
18+
"Development Status :: 2 - Pre-Alpha",
1919
]
2020

2121
[project.urls]
@@ -29,7 +29,10 @@ commit_parser = "angular"
2929
logging_use_named_masks = false
3030
major_on_zero = true
3131
allow_zero_version = true
32-
tag_format = "v{version}"
32+
tag_format = "chore: release v{version}"
33+
version_variable = [
34+
"pyproject.toml:version",
35+
]
3336

3437
[tool.semantic_release.branches.main]
3538
match = "main"
@@ -78,3 +81,4 @@ insecure = false
7881
[tool.semantic_release.publish]
7982
dist_glob_patterns = ["dist/*"]
8083
upload_to_vcs_release = true
84+

0 commit comments

Comments
 (0)