-
Notifications
You must be signed in to change notification settings - Fork 0
144 lines (119 loc) · 3.8 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
name: Publish release
on:
workflow_dispatch:
push:
tags:
- "202[3-9].0[1-9].[1-9]" # 2023.02.2
- "202[3-9].0[1-9].[1-9]-rc[0-9]+" # 2023.02.2-rc1
- "202[3-9].0[1-9].[1-9][0-9]" # 2023.02.22
- "202[3-9].0[1-9].[1-9][0-9]-rc[0-9]+" # 2023.02.22-rc1
- "202[3-9].1[0-2].[1-9]" # 2023.11.1
- "202[3-9].1[0-2].[1-9]-rc[0-9]+" # 2023.11.1-rc1
- "202[3-9].1[0-2].[1-9][0-9]" # 2023.11.11
- "202[3-9].1[0-2].[1-9][0-9]-rc[0-9]+" # 2023.11.11-rc1
defaults:
run:
shell: bash
jobs:
package:
strategy:
matrix:
# https://docs.github.com/en/actions/using-github-hosted-runners/about-github-hosted-runners
os: [windows-latest, macos-latest, ubuntu-latest]
runs-on: ${{ matrix.os }}
steps:
- name: Checkout
uses: actions/checkout@v4
- uses: actions/setup-python@v4
with:
python-version-file: .github/workflows/.python-version
cache: pip
cache-dependency-path: "**/pyproject.toml"
- name: Install package
run: pip install -e .[test,dist]
- name: Test
run: ./bin/coverage.sh
- name: Package
run: pyinstaller --onefile pyinstaller_entrypoint.py --name hashfields
- name: Make artifact path
id: make-path
env:
ref: ${{ github.ref }}
runner: ${{ runner.os }}
run: |
echo "path=hashfields-${ref/refs\/tags\//}-${runner}.zip" >> $GITHUB_OUTPUT
- name: Zip (Linux)
if: runner.os != 'Windows'
env:
zip_path: ${{ steps.make-path.outputs.path }}
run: |
zip -r -j $zip_path dist/
ls -l $zip_path
- name: Zip (Windows)
if: runner.os == 'Windows'
env:
zip_path: ${{ steps.make-path.outputs.path }}
shell: pwsh
run: |
Compress-Archive -Path .\dist\* -DestinationPath ${env:zip_path}
dir ${env:zip_path}
- name: Upload artifacts
uses: actions/upload-artifact@v3
with:
name: package
path: ${{ steps.make-path.outputs.path }}
release:
runs-on: ubuntu-latest
needs: package
permissions:
# https://github.com/softprops/action-gh-release#permissions
contents: write
steps:
- name: Checkout
uses: actions/checkout@v4
- uses: actions/setup-python@v4
with:
python-version-file: .github/workflows/.python-version
cache: pip
cache-dependency-path: "**/pyproject.toml"
- name: Install build dependencies
run: pip install -e .[dist]
- name: Build package
run: |
python -m build
ls -al ./dist
- name: Download artifacts
uses: actions/download-artifact@v3
with:
name: package
path: ./package
- name: Check artifacts
run: |
ls -al ./package
- name: Release
id: release
uses: softprops/action-gh-release@v1
with:
files: |
./dist/*.whl
./dist/*.tar.gz
./package/*.zip
prerelease: ${{ contains(github.ref, '-rc') }}
generate_release_notes: ${{ !contains(github.ref, '-rc') }}
- name: Publish to Test PyPI
uses: pypa/gh-action-pypi-publish@release/v1.5
if: ${{ contains(github.ref, '-rc') }}
with:
user: __token__
password: ${{ secrets.PYPI_TEST_API_TOKEN }}
repository_url: https://test.pypi.org/legacy/
print_hash: true
skip_existing: true
verbose: true
- name: Publish to PyPI
uses: pypa/gh-action-pypi-publish@release/v1.5
if: ${{ !contains(github.ref, '-rc') }}
with:
user: __token__
password: ${{ secrets.PYPI_API_TOKEN }}
print_hash: true