-
Notifications
You must be signed in to change notification settings - Fork 3
91 lines (78 loc) · 3.03 KB
/
pypi-publish.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
---
name: Publish Python Package
# Publishes with trusted publishing to
# - PyPI on releases created in GitHub UI if status is published.
# For draft status, nothing happens.
# - TestPyPI on new tags "v1.2.3" or "v1.2.3.something" on main branch
#
# More on trusted publishing: https://docs.pypi.org/trusted-publishers/
on:
push:
tags:
# GitHub glob matching is limited [1]. So we can't define a pattern matching
# pep 440 version definition [N!]N(.N)*[{a|b|rc}N][.postN][.devN]
- 'v[0-9]+.[0-9]+.[0-9]+.?*'
release:
types: [published]
permissions: {}
jobs:
build:
name: Build Python 🐍 distributions 📦 for publishing
runs-on: ubuntu-latest
steps:
- name: Check out repository
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
with:
persist-credentials: false
- name: Set up Python
uses: actions/setup-python@0b93645e9fea7318ecaed2b359559ac225c90a2b
with:
python-version: 3.9
- name: Install just & Poetry incl. plugins
# We install poetry-dynamic-versioning into pipx because the automatic installallation
# by poetry 2.x triggers a Windows issue https://github.com/pypa/installer/issues/260
# and also does not work on Ubuntu in gh-actions.
run: |
pipx install rust-just
pipx install poetry
pipx inject poetry poetry-dynamic-versioning
- name: Build source and wheel archives
run: poetry build
- name: Store built distribution
uses: actions/upload-artifact@6f51ac03b9356f520e9adb1b1b7802705f340c2b
with:
name: distribution-files
path: dist/
pypi-publish:
name: Build and publish Python 🐍 package 📦 to PyPI and TestPyPI
needs: build
runs-on: ubuntu-latest
environment:
name: pypi-release
url: https://pypi.org/p/pid4cat_model
permissions:
id-token: write # this permission is mandatory for trusted publishing
steps:
- name: Download built distribution
uses: actions/download-artifact@fa0a91b85d4f404e444e00e005971372dc801d16
with:
name: distribution-files
path: dist
- name: Publish package 📦 to Test PyPI
if: github.event_name == 'push'
uses: pypa/gh-action-pypi-publish@76f52bc884231f62b9a034ebfe128415bbaabdfc
with:
repository-url: https://test.pypi.org/legacy/
verbose: true
- name: Publish package 📦 to PyPI
if: github.event_name == 'release'
uses: pypa/gh-action-pypi-publish@76f52bc884231f62b9a034ebfe128415bbaabdfc
with:
verbose: true
# [1] https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#filter-pattern-cheat-sheet
# Used actions: (updates managed by dependabot)
# - https://github.com/actions/checkout
# - https://github.com/actions/setup-python
# - https://github.com/actions/upload-artifact
# - https://github.com/actions/download-artifact
# - https://github.com/pypa/gh-action-pypi-publish/