Debian Codegraph @

.github/workflows/release.yaml

raw symbols SCIP
1 name: Release
2 on:
3 push:
4 tags:
5 - 'v*'
6 jobs:
7 versions:
8 runs-on: ubuntu-latest
9 outputs:
10 python-version: ${{ steps.python-version.outputs.python_version }}
11 release-version: ${{ steps.release-version.outputs.release_version }}
12 steps:
13 - uses: actions/checkout@v4
14 - name: Get latest supported Python version
15 id: python-version
16 run: |
17 CLASSIFIERS="$(yq -p toml -o toml '.project.classifiers[]' pyproject.toml | grep "Programming Language :: Python :: " | grep "\.")"
18 VERSION="$(echo "${CLASSIFIERS}" | sed -e 's/Programming Language :: Python :: \([0-9.]*\)$/\1/g' | tail -n 1)"
19 echo "python_version=${VERSION}" > "${GITHUB_OUTPUT}"
20 # See: https://stackoverflow.com/questions/58177786/get-the-current-pushed-tag-in-github-actions
21 - name: Get release version
22 id: release-version
23 run: |
24 VERSION="$(yq -p toml -o toml -r '.project.version' pyproject.toml)"
25 echo "release_version=${VERSION}" >> "${GITHUB_OUTPUT}"
26
27 build:
28 runs-on: ubuntu-latest
29 needs:
30 - versions
31 steps:
32 - uses: actions/checkout@v4
33 - name: Set up Python ${{ needs.versions.outputs.python-version }}
34 uses: actions/setup-python@v5
35 with:
36 python-version: "${{ needs.versions.outputs.python-version }}"
37 - name: Install the world
38 run: |
39 python -m pip install --upgrade pip setuptools wheel
40 pip install -e .[dev]
41 - name: Build Package Distributions
42 run: python -m build
43 - name: Store Package Distributions
44 uses: actions/upload-artifact@v4
45 with:
46 name: package-distributions
47 path: dist/
48 - name: Build Man Page
49 run: sphinx-build -M man docs _build
50 - name: Store Man Page
51 uses: actions/upload-artifact@v4
52 with:
53 name: man-page
54 path: _build/man
55 - name: Build Release Notes
56 # thanks to https://gist.github.com/Integralist/57accaf446cf3e7974cd01d57158532c
57 run: mkdir notes && awk '/^##/ {block++} {if (block == 1) { print }}' CHANGELOG.md > notes/RELEASE.md
58 - name: Store Release Notes
59 uses: actions/upload-artifact@v4
60 with:
61 name: release-notes
62 path: notes
63
64 pypi-release:
65 runs-on: ubuntu-latest
66 needs:
67 - build
68 environment:
69 name: pypi
70 url: https://pypi.org/p/pypi
71 permissions:
72 id-token: write
73 steps:
74 - name: Download distributions
75 uses: actions/[email protected]
76 with:
77 name: package-distributions
78 path: dist/
79 - name: Publish release to PyPI
80 uses: pypa/gh-action-pypi-publish@release/v1
81
82 github-release:
83 runs-on: ubuntu-latest
84 needs:
85 - versions
86 - build
87 steps:
88 - uses: actions/checkout@v4
89 - name: Download distributions
90 uses: actions/[email protected]
91 with:
92 name: package-distributions
93 path: dist/
94 - name: Download man page
95 uses: actions/[email protected]
96 with:
97 name: man-page
98 path: man
99 - name: Download release notes
100 uses: actions/[email protected]
101 with:
102 name: release-notes
103 path: notes
104 - name: Create a GitHub release
105 env:
106 GITHUB_TOKEN: ${{ github.TOKEN }}
107 shell: bash
108 run: |
109 gh release create 'v${{ needs.versions.outputs.release-version }}' --title 'Release v${{ needs.versions.outputs.release-version }}' --notes "$(cat notes/RELEASE.md)" dist/* man/pyee.1