99 lines (90 loc) · 4.17 KB
/
python_release.yml
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
---
# --------------------( LICENSE )--------------------
# Copyright (c) 2014-2022 Beartype authors.
# 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@v3'
- name: "Publishing GitHub release..."
uses: 'ncipollo/release-action@v1'
with:
name: "beartype ${{ 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
# Perform this job *ONLY* if the prior job succeeded.
needs: release
steps:
- name: "Checking out repository..."
uses: 'actions/checkout@v3'
- name: "Installing latest stable Python 3.x..."
uses: 'actions/setup-python@v3'
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 setuptools wheel
- name: 'Installing package dependencies...'
run: |
python -m pip --quiet install --upgrade twine
- name: "Creating source tarball and binary wheel..."
run: |
set -xe
python setup.py sdist bdist_wheel
- name: "Publishing PyPI release from tag..."
uses: 'pypa/gh-action-pypi-publish@release/v1'
with:
user: __token__
password: ${{ secrets.PYPI_API_TOKEN }}
#FIXME: Enable after integrating this "pypi" job into the "release" job
#above. In theory, this should be trivial. Let's test this later, eh?
# - name: "Publishing GitHub release assets from tag..."
# uses: actions/upload-release-asset@v1.0.1
# env:
# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# with:
# upload_url: ${{ steps.create_release.outputs.upload_url }} # This pulls from the CREATE RELEASE step above, referencing it's ID to get its outputs object, which include a `upload_url`. See this blog post for more info: https://jasonet.co/posts/new-features-of-github-actions/#passing-data-to-future-steps
# asset_path: "dist/beartype-${{ github.ref }}.zip"
# asset_name: "beartype-${{ github.ref }}.zip"
# asset_content_type: application/zip