-
Notifications
You must be signed in to change notification settings - Fork 16
104 lines (93 loc) · 4.2 KB
/
python_release.yml
File metadata and controls
104 lines (93 loc) · 4.2 KB
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
92
93
94
95
96
97
98
99
100
101
102
103
104
---
# --------------------( LICENSE )--------------------
# Copyright 2014-2025 by Alexis Pietak & Cecil Curry.
# See "LICENSE" for further details.
#
# --------------------( SYNOPSIS )--------------------
# GitHub-specific continuous deployment (CD) configuration, enabling automated
# publication of both source tarballs and binary wheels in various popular
# formats to both GitHub itself and PyPI on each push of a tag to the "master"
# branch of this repository.
#
# --------------------( SEE ALSO )--------------------
# * https://blog.chezo.uno/how-to-release-python-package-from-github-actions-d5a1d8edba6e
# Well-authored blog post strongly inspiring this configuration.
# * https://packaging.python.org/guides/publishing-package-distribution-releases-using-github-actions-ci-cd-workflows
# Official PyPA workflow also inspiring this configuration.
# ....................{ METADATA }....................
# Non-human-readable (i.e., machine-readable) label associated with this
# GitHub Actions workflow.
name: release
# ....................{ TRIGGER }....................
# Confine deployment to only new tags satisfying a release-specific format.
on:
push:
# Sequence of glob expressions matched against "refs/tags" pushed to the
# branches above.
tags:
- 'v**' # Match "v"-prefixed tags (e.g., "v6.9.6").
# ....................{ MAIN }....................
jobs:
# ...................{ GITHUB }...................
# Job publishing a human-readable changelog and codebase tarballs to GitHub
# for this release.
release:
name: "Create tagged release on GitHub"
runs-on: ubuntu-latest
steps:
- name: "Checking out repository..."
uses: 'actions/checkout@v4'
- name: "Publishing GitHub release..."
uses: 'ncipollo/release-action@v1'
with:
name: "BETSE ${{ github.ref }}"
body: ${{ github.event.commits[0].message }}
token: ${{ secrets.GITHUB_TOKEN }}
# ...................{ PYPI }...................
# Job publishing both a static distribution (sdist) and binary wheel to PyPI
# for this release.
pypi:
name: "Publish tagged release to PyPI"
runs-on: ubuntu-latest
# GitHub Environment associated with this job.
#
# Note that PyPI strongly recommends use of a GitHub Environment as an
# additional security precaution for GitHub repositories that grant push
# access to different users with differing permissions. So, basically *ALL*
# GitHub repositories is what we are saying. See also:
# * "Publishing to PyPI with a Trusted Publisher."
# https://docs.pypi.org/trusted-publishers
# * "Using environments for deployment."
# https://docs.github.com/en/actions/deployment/targeting-different-environments/using-environments-for-deployment#creating-an-environment
environment:
# Arbitrary name of this environment.
name: betse_barn
# Arbitrary URL associated with this environment.
url: https://pypi.org/project/betse
# Enable the "write" permission as required for PyPI Trusted Publishing.
# See also:
# https://github.com/pypa/gh-action-pypi-publish
permissions:
id-token: write # IMPORTANT: this permission is mandatory for trusted publishing
# Perform this job *ONLY* if the prior job succeeded.
needs: release
steps:
- name: "Checking out repository..."
uses: 'actions/checkout@v4'
- name: "Installing latest stable Python 3.x..."
uses: 'actions/setup-python@v5'
with:
python-version: '3.x'
# See "python_test.yml" for further details.
- name: 'Upgrading packager dependencies...'
run: |
set -xe
python -VV
python -m site
python -m pip --quiet install --upgrade pip hatch wheel
- name: "Creating source tarball and binary wheel..."
run: |
set -xe
hatch build -t sdist -t wheel
- name: "Publishing PyPI release from tag..."
uses: 'pypa/gh-action-pypi-publish@release/v1'