This repository has been archived by the owner on Nov 13, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 124
149 lines (128 loc) · 3.96 KB
/
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
name: 'Release'
on:
workflow_dispatch:
inputs:
bumpVersion:
description: 'Whether to bump the version number'
required: true
type: boolean
default: true
versionLevel:
description: 'Which version level to bump'
required: true
type: choice
default: 'patch'
options:
- 'patch' # bug fixes
- 'minor' # new features, backwards compatible
- 'major' # breaking changes
generateBranch:
description: 'Whether to generate a release branch'
required: true
type: boolean
default: false
useTestPyPI:
description: 'Whether to use the test PyPI repository'
required: true
type: boolean
default: false
jobs:
build:
name: Build
runs-on: ubuntu-latest
outputs:
new_version: ${{ steps.store-version.outputs.new_version }}
steps:
- uses: actions/checkout@v3
with:
ref: release/0.2.0
token: ${{ secrets.VERSION_BUMP_PAT }}
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: 3.9 # The lowest we support
- name: Install Poetry
uses: snok/install-poetry@v1
with:
version: 1.3.2
- name: Bump version
if: ${{ inputs.bumpVersion == true }}
run: |
poetry version ${{ inputs.releaseLevel || 'patch' }}
- name: Store version number
id: store-version
run: |
echo "new_version=$(poetry version -s)" >> $GITHUB_OUTPUT
- name: Build wheel
run: |
poetry build
- name: Upload wheels
uses: actions/upload-artifact@v3
with:
name: wheels
path: ./dist/
test-all-OSes:
needs: build
uses: ./.github/workflows/pre-release-CI.yml
publish:
needs: [build, test-all-OSes]
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- uses: actions/checkout@v3
with:
ref: release/0.2.0
token: ${{ secrets.VERSION_BUMP_PAT }}
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: 3.9
- name: Install Poetry
uses: snok/install-poetry@v1
with:
version: 1.3.2
- name: download wheels
uses: actions/download-artifact@v2
with:
name: wheels
path: ./dist/
- name: Set version
env:
NEW_VERSION: ${{ needs.build.outputs.new_version }}
run: |
echo $NEW_VERSION
poetry version $NEW_VERSION
- name: Commit version update
if: ${{ inputs.bumpVersion == true }}
run: |
git config --global user.name "GitHub Action"
git config --global user.email "[email protected]"
git add pyproject.toml
git commit -m "Bump version to $(poetry version -s)"
git push
- name: Create release branch
if: ${{ github.event_name == 'workflow_dispatch' && inputs.generateBranch == 'true' }}
run: |
git checkout -b release/$(poetry version -s)
git push origin release/$(poetry version -s)
- name: Create GH release
uses: ncipollo/release-action@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag: V${{ needs.build.outputs.new_version }}
name: ${{ needs.build.outputs.new_version }}
artifacts: "dist/*"
bodyFile: "CHANGELOG.md"
- name: Publish to test pypi
if: ${{ inputs.useTestPyPI == true }}
run: |
poetry config repositories.testpypi https://test.pypi.org/legacy/
poetry config pypi-token.testpypi ${{ secrets.TEST_PYPI_TOKEN }}
poetry publish -r testpypi
- name: Publish to pypi
if: ${{ inputs.useTestPyPI == false }}
run: |
poetry config pypi-token.pypi ${{ secrets.PYPI_TOKEN }}
poetry publish