Skip to content

Commit 7b177b7

Browse files
committed
ci: Add workflow for making PyPi releases
Add a workflow that will trigger when a "v*" tag is created that: * Runs the tox workflow * Builds sdist and wheel packages * Uploads packages to PyPi
1 parent 21a58bb commit 7b177b7

File tree

3 files changed

+59
-0
lines changed

3 files changed

+59
-0
lines changed

.github/workflows/release.yml

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
# See: https://packaging.python.org/en/latest/guides/publishing-package-distribution-releases-using-github-actions-ci-cd-workflows/
2+
name: Publish Python 🐍 distribution 📦 to PyPI
3+
4+
on:
5+
push:
6+
tags:
7+
- v* # Only run when a tag starting with "v" is created
8+
9+
permissions:
10+
contents: read
11+
12+
jobs:
13+
test:
14+
uses: ./.github/workflows/tox.yml
15+
build:
16+
name: Build distribution 📦
17+
needs:
18+
- test
19+
runs-on: ubuntu-latest
20+
steps:
21+
- uses: actions/checkout@v4
22+
- name: Set up Python
23+
uses: actions/setup-python@v4
24+
with:
25+
python-version: '3.x'
26+
- name: Install pypa/build
27+
run: python3 -m pip install --upgrade pip wheel build
28+
- name: Build a binary wheel and a source tarball
29+
run: python3 -m build
30+
- name: Store the distribution packages
31+
uses: actions/upload-artifact@v3
32+
with:
33+
name: python-package-distributions
34+
path: dist/
35+
36+
publish-to-pypi:
37+
name: Publish Python 🐍 distribution 📦 to PyPI
38+
needs:
39+
- build
40+
if: github.repository == 'bd808/python-ib3'
41+
runs-on: ubuntu-latest
42+
environment:
43+
name: release
44+
url: https://pypi.org/p/ib3
45+
permissions:
46+
id-token: write # IMPORTANT: mandatory for trusted publishing
47+
steps:
48+
- name: Download all the dists
49+
uses: actions/download-artifact@v3
50+
with:
51+
name: python-package-distributions
52+
path: dist/
53+
- name: Publish distribution 📦 to PyPI
54+
uses: pypa/gh-action-pypi-publish@release/v1

.github/workflows/tox.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ on:
44
branches:
55
- main
66
pull_request:
7+
workflow_call:
78

89
concurrency:
910
group: tox-${{ github.ref }}

.pre-commit-config.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,3 +67,7 @@ repos:
6767
hooks:
6868
- id: check-hooks-apply
6969
- id: check-useless-excludes
70+
- repo: https://github.com/rhysd/actionlint
71+
rev: v1.6.26
72+
hooks:
73+
- id: actionlint

0 commit comments

Comments
 (0)