-
-
Notifications
You must be signed in to change notification settings - Fork 0
163 lines (131 loc) · 4.61 KB
/
generate-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
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
name: Generate a Release
on:
push:
tags:
- 'v[0-9].[0-9]+.[0-9]+'
- '!v[0-9].[0-9]+.[0-9]+rc[0-9]+'
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
permissions: read-all
jobs:
get-python-version:
name: Get Latest Python Version
runs-on: ubuntu-latest
outputs:
highest-version: ${{ steps.get-language-versions.outputs.latest-versions }}
steps:
- name: Get Required Version
uses: ActionsToolbox/get-language-versions-action@446919617fd774095b5dd3ed71c39dd3fd0d8f4f # v0.1.3
id: get-language-versions
with:
language: "python"
highest-only: true
get-python-versions:
name: Get Python Versions (>= 3.9)
runs-on: ubuntu-latest
outputs:
version-matrix: ${{ steps.get-language-versions.outputs.latest-versions }}
steps:
- name: Get Required Versions
uses: ActionsToolbox/get-language-versions-action@446919617fd774095b5dd3ed71c39dd3fd0d8f4f # v0.1.3
id: get-language-versions
with:
language: "python"
min-version: 3.9
remove-patch-version: true
run-tests:
name: Pytest
needs: get-python-versions
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
python-versions: ${{ fromJson(needs.get-python-versions.outputs.version-matrix) }}
steps:
- name: Checkout the Repository
uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4.1.6
- name: Setup Python ${{ matrix.python-versions }}
uses: actions/setup-python@82c7e631bb3cdc910f68e0081d67478d79c6982d # v5.1.0
with:
python-version: ${{ matrix.python-versions }}
- name: Upgrade Pip
run: python -m pip install --upgrade pip
- name: Install Build Tools
run: pip install setuptools wheel
- name: Build the Package
run: python setup.py sdist bdist_wheel
- name: Install the Package
run: pip install dist/*.whl
- name: Install Pytest
run: pip install pytest pytest-mock
- name: Run Pytest
run: pytest --no-header -vv
build-and-publish:
name: Build & publish to PyPI
runs-on: ubuntu-latest
needs:
- run-tests
- get-python-version
steps:
- name: Checkout the Repository
uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4.1.6
- name: Setup Python ${{ needs.get-python-version.outputs.highest-version }}
uses: actions/setup-python@82c7e631bb3cdc910f68e0081d67478d79c6982d # v5.1.0
with:
python-version: ${{ needs.get-python-version.outputs.highest-version }}
- name: Update Pip
run: python -m pip install --upgrade pip
- name: Install Required Tooling
run: pip install setuptools wheel twine
- name: Build Binary Wheel & Source Tarball
run: python setup.py sdist bdist_wheel
- name: Verify Binary Wheel & Source Tarball
run: twine check dist/*
- name: Publish to PyPI
env:
TWINE_USERNAME: __token__
TWINE_PASSWORD: ${{ secrets.PYPI_API_TOKEN }}
run: twine upload dist/*
set-release-version:
name: Set Release Version
runs-on: ubuntu-latest
outputs:
release-version: ${{ steps.set-release-version.outputs.release-version }}
steps:
- name: Checkout the Repository
uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4.1.6
with:
fetch-depth: 0
- name: Set the Release Version
id: set-release-version
run: |
echo "release-version=${GITHUB_REF#refs/*/}" >> "${GITHUB_OUTPUT}"
create-release:
name: Create a Release
permissions:
contents: write
runs-on: ubuntu-latest
needs:
- run-tests
- set-release-version
steps:
- name: Checkout the Repository
uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4.1.6
with:
fetch-depth: 0
- name: Generate Changelog
uses: Bullrich/generate-release-changelog@6b60f004b4bf12ff271603dc32dbd261965ad2f2 # v2.0.2
id: Changelog
env:
REPO: ${{ github.repository }}
- name: Create a Release
id: create_release
uses: softprops/action-gh-release@69320dbe05506a9a39fc8ae11030b214ec2d1f87 # v2.0.5
with:
token: ${{ secrets.GITHUB_TOKEN }}
tag_name: ${{ github.ref }}
name: ${{ needs.set-release-version.outputs.release-version }}
body: ${{ steps.Changelog.outputs.changelog }}
draft: false
prerelease: false