-
Notifications
You must be signed in to change notification settings - Fork 0
71 lines (59 loc) · 2.29 KB
/
build.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
# https://docs.pypi.org/trusted-publishers/using-a-publisher/
# https://packaging.python.org/en/latest/guides/publishing-package-distribution-releases-using-github-actions-ci-cd-workflows/
# https://stackoverflow.com/questions/62968271/python-automatic-versioning-not-happening-while-running-in-github-actions
name: Build Python package
run-name: ${{ github.actor }} is building the Python package
# Workflow will when a new release in the GitHub web UI.
# It can also be triggered manually: https://docs.github.com/en/actions/using-workflows/manually-running-a-workflow#running-a-workflow
on:
release:
types: [released]
workflow_dispatch:
jobs:
build:
name: Build Python package
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
# Get the latest commit with a semver tag
# This allows re-running the build job even after further unclean commits were made:
# builds will always be for at least a tagged version, allowing them to be
# pushed to PyPI.
# Unfortunately, `semver_only: true` excludes tags with suffixes, like v1.0.0-rc.3,
# so it would prevent from building release candidate versions.
# By setting to `false`, we make the assumption that tags are only used on
# commits which correspond to releases.
- uses: actions-ecosystem/action-get-latest-tag@v1
id: get-latest-tag
with:
semver_only: false
# https://stackoverflow.com/a/73904531
- name: Checkout latest tagged release
run: |
echo "Restoring state to the commit tagged '${{ steps.get-latest-tag.outputs.tag }}'"
git checkout "tags/${{ steps.get-latest-tag.outputs.tag }}"
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.10"
- name: Install pypa/build
run: >-
python3 -m
pip install
build
--user
- name: Build a binary wheel and a source tarball
run: >-
python3 -m
build
--sdist
--wheel
--outdir dist/
- uses: actions/upload-artifact@v4
with:
name: release-build
path: dist/
- name: Display structure of created artifacts
run: ls -R