Skip to content

Commit 2b9b132

Browse files
authored
Merge pull request #15 from sandialabs/atpolonsky-patch-2
Refactor publish workflow for PyPI
2 parents 5ee9e8d + 18922bb commit 2b9b132

File tree

1 file changed

+60
-32
lines changed

1 file changed

+60
-32
lines changed

.github/workflows/publish.yml

Lines changed: 60 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,64 @@
1-
name: Publish to PyPI
2-
1+
name: Package
32
on:
4-
push:
5-
#branches:
6-
# - main # Triggers when push/merge to the 'main' branch
7-
tags:
8-
- 'v*' # Triggers whenever you push a tag starting with 'v' (e.g., v0.0.2)
9-
3+
pull_request:
4+
branches: main
5+
release:
6+
types: published
107
jobs:
11-
build-and-publish:
12-
name: Build and publish Python distribution
8+
Source:
139
runs-on: ubuntu-latest
14-
permissions:
15-
# This permission is REQUIRED for Trusted Publishing
16-
id-token: write
17-
contents: read
18-
1910
steps:
20-
- uses: actions/checkout@v4
21-
22-
- name: Set up Python
23-
uses: actions/setup-python@v5
24-
with:
25-
python-version: "3.12"
26-
27-
- name: Install dependencies
28-
run: |
29-
python -m pip install --upgrade pip
30-
pip install build
31-
32-
- name: Build binary wheel and source tarball
33-
run: python -m build
34-
35-
- name: Publish to PyPI
36-
uses: pypa/gh-action-pypi-publish@release/v1
11+
- name: Checkout
12+
uses: actions/checkout@v4
13+
- name: Python
14+
uses: actions/setup-python@v5
15+
with:
16+
python-version: 3.12
17+
- name: Requirements
18+
run: pip install --upgrade build pip twine
19+
- name: Build
20+
run: python -m build .
21+
- name: Check
22+
run: twine check dist/*
23+
- uses: actions/upload-artifact@v4
24+
with:
25+
name: dist
26+
path: dist
27+
#Wheel:
28+
# strategy:
29+
# fail-fast: false
30+
# matrix:
31+
# os: [macos-latest, ubuntu-latest, windows-latest]
32+
# runs-on: ${{ matrix.os }}
33+
# steps:
34+
# - name: Checkout
35+
# uses: actions/checkout@v4
36+
# - name: Python
37+
# uses: actions/setup-python@v5
38+
# with:
39+
# python-version: 3.12
40+
# - name: Requirements
41+
# run: pip install --upgrade build pip twine
42+
# - name: Wheel
43+
# run: python -m build . --wheel
44+
# - name: Check
45+
# run: twine check dist/*
46+
# - uses: actions/upload-artifact@v4
47+
# with:
48+
# name: ${{ matrix.os }}-dist
49+
# path: dist
50+
Twine:
51+
# needs: [Source, Wheel]
52+
needs: Source
53+
runs-on: ubuntu-latest
54+
steps:
55+
- uses: actions/download-artifact@v4
56+
- uses: actions/setup-python@v5
57+
with:
58+
check-latest: true
59+
python-version: 3.12
60+
- name: Requirements
61+
run: pip install --upgrade pip twine
62+
- name: Upload
63+
if: github.event_name == 'release'
64+
run: twine upload -u __token__ -p ${{ secrets.PYPI_TOKEN }} dist/*

0 commit comments

Comments
 (0)