-
Notifications
You must be signed in to change notification settings - Fork 5
201 lines (192 loc) · 6.98 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
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
name: Release
on:
pull_request:
branches:
- main
types:
- closed
jobs:
tagging:
runs-on: ubuntu-latest
if: github.event.pull_request.merged == true && startsWith(github.event.pull_request.head.ref, 'release/')
steps:
- name: Get the version
id: get_version
run: |
echo ::set-output name=TAG::`echo $SOURCE_VERSION | cut -d / -f 2`
env:
SOURCE_VERSION: ${{ github.event.pull_request.head.ref }}
- name: Echo tag
run: echo ${{ steps.get_version.outputs.TAG }}
- uses: actions/checkout@v2
- run: |
git config --global user.email "[email protected]"
git config --global user.name "Masanori HIRANO"
git fetch origin ${{ github.event.pull_request.head.ref }}
git checkout main
git tag -a `echo '${{ github.event.pull_request.head.ref }}' | sed 's/release\///'` -m " "
git push origin `echo '${{ github.event.pull_request.head.ref }}' | sed 's/release\///'`
test:
# The type of runner that the job will run on
name: final test
runs-on: ${{ matrix.platform }}
needs: tagging
strategy:
max-parallel: 5
matrix:
platform: [ubuntu-latest, macos-latest, windows-latest]
python-version: [3.9, "3.10", "3.11", "3.12", "3.13"]
exclude:
- platform: windows-latest
python-version: 3.13
# Steps represent a sequence of tasks that will be executed as part of the job
steps:
- uses: actions/checkout@v2
- name: Set up Python ${{ matrix.python-version }}
uses: actions/[email protected]
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip setuptools wheel
python -m pip install poetry
poetry install
- name: Test
run: |
poetry run black --check --diff --quiet .
poetry run isort --check --quiet .
poetry run pflake8 .
poetry run mypy .
poetry run pytest tests/
releasetest:
# The type of runner that the job will run on
name: release test
needs: test
runs-on: ubuntu-latest
strategy:
matrix:
python-version: [3.11]
# Steps represent a sequence of tasks that will be executed as part of the job
steps:
- uses: actions/checkout@v2
- name: Set up Python ${{ matrix.python-version }}
uses: actions/[email protected]
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip setuptools wheel
python -m pip install poetry
poetry install
- name: test release
run: |
poetry config repositories.testpypi https://test.pypi.org/legacy/
poetry publish --build -r testpypi --username __token__ --password ${{ secrets.TEST_PYPI_TOKEN }}
releasetestcheck:
name: release test check
needs: releasetest
runs-on: ubuntu-latest
strategy:
matrix:
python-version: [3.11]
# Steps represent a sequence of tasks that will be executed as part of the job
steps:
- name: Get the version
id: get_version
run: |
echo ::set-output name=TAG::`echo $SOURCE_VERSION | cut -d / -f 2`
env:
SOURCE_VERSION: ${{ github.event.pull_request.head.ref }}
- uses: actions/checkout@v2
- name: Set up Python ${{ matrix.python-version }}
uses: actions/[email protected]
with:
python-version: ${{ matrix.python-version }}
- name: Sleep for 300 seconds
run: sleep 300s
shell: bash
- name: Install test package
run: |
python -m pip install -f https://test.pypi.org/simple/pams/ pams==${{ steps.get_version.outputs.TAG }}
python -m pip install pytest
rm -r pams
rm pyproject.toml
- name: Test
run: |
pytest tests/
release:
name: release
needs: [releasetestcheck, tagging]
runs-on: ubuntu-latest
strategy:
matrix:
python-version: [3.11]
# Steps represent a sequence of tasks that will be executed as part of the job
steps:
- name: Get the version
id: get_version
run: |
echo ::set-output name=TAG::`echo $SOURCE_VERSION | cut -d / -f 2`
env:
SOURCE_VERSION: ${{ github.event.pull_request.head.ref }}
- uses: actions/checkout@v2
- name: Set up Python ${{ matrix.python-version }}
uses: actions/[email protected]
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip setuptools wheel
python -m pip install poetry
poetry install
- name: release
run: |
poetry publish --build --username __token__ --password ${{ secrets.PYPI_TOKEN }}
- name: Create release
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ steps.get_version.outputs.TAG }}
release_name: ${{ steps.get_version.outputs.TAG }}
draft: false
prerelease: false
body: |
${{ github.event.pull_request.body }}
This release is automatically generated.
Please see the pull request.
[${{ github.event.pull_request.html_url }}](${{ github.event.pull_request.html_url }})
- name: Generate checksum
run: |
cd dist; sha256sum * > checksums.txt; cd -
- name: Upload tar.gz
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: dist/pams-${{ steps.get_version.outputs.TAG }}.tar.gz
asset_name: pams-${{ steps.get_version.outputs.TAG }}.tar.gz
asset_content_type: application/gzip
- name: Upload whl
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: dist/pams-${{ steps.get_version.outputs.TAG }}-py3-none-any.whl
asset_name: pams-${{ steps.get_version.outputs.TAG }}-py3-none-any.whl
asset_content_type: application/x-pywheel+zip
- name: Upload checksum
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: dist/checksums.txt
asset_name: pams-${{ steps.get_version.outputs.TAG }}-checksums.txt
asset_content_type: text/plain
- name: remove branch
run: |
git push --delete origin ${{ github.event.pull_request.head.ref }}