-
Notifications
You must be signed in to change notification settings - Fork 1
228 lines (220 loc) Β· 6.99 KB
/
main.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
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
---
"on":
push:
paths-ignore:
- "**.md"
- docs/*
pull_request:
paths-ignore:
- "**.md"
- docs/*
workflow_dispatch:
# /~https://github.com/softprops/action-gh-release/issues/236
permissions:
contents: write
env:
files: dist/*
python-version: 3.x
cache: pip
jobs:
test:
strategy:
fail-fast: false
matrix:
include:
- runs-on: ubuntu-latest
shell: bash
- runs-on: macos-latest
shell: bash
- runs-on: windows-latest
shell: msys2
runs-on: ${{matrix.runs-on}}
defaults:
run:
shell: ${{matrix.shell}} {0}
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: ${{env.python-version}}
cache: ${{env.cache}}
- uses: msys2/setup-msys2@v2
if: runner.os == 'Windows'
- name: Install dependencies
if: runner.os == 'Linux'
run: |
sudo apt-get -y update
sudo apt-get -y install librime-dev
- name: Install dependencies
if: runner.os == 'Windows'
run: |
pacman -Sy --noconfirm mingw-w64-x86_64-pkg-config \
mingw-w64-x86_64-librime mingw-w64-x86_64-python-pip \
mingw-w64-x86_64-ninja mingw-w64-x86_64-gcc
- uses: cachix/install-nix-action@v24
if: runner.os == 'macOS'
with:
nix_path: nixpkgs=channel:nixpkgs-unstable
extra_nix_config: |
experimental-features = nix-command flakes
access-tokens = github.com=${{ secrets.GITHUB_TOKEN }}
- name: Install dependencies
if: runner.os == 'macOS'
run: |
nix-env -if'<nixpkgs>' librime
- name: Test
run: |
PKG_CONFIG_PATH="$HOME/.nix-profile/lib/pkgconfig" pip install .[dev]
pytest --cov
- uses: codecov/codecov-action@v4
build:
needs: test
strategy:
fail-fast: false
matrix:
include:
- runs-on: ubuntu-latest
shell: bash
- runs-on: macos-latest
shell: bash
- runs-on: windows-latest
shell: msys2
runs-on: ${{matrix.runs-on}}
defaults:
run:
shell: ${{matrix.shell}} {0}
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: ${{env.python-version}}
cache: ${{env.cache}}
- uses: msys2/setup-msys2@v2
if: runner.os == 'Windows'
- name: Install dependencies
if: runner.os == 'Linux'
run: |
sudo apt-get -y update
sudo apt-get -y install librime-dev
- name: Install dependencies
if: runner.os == 'Windows'
# Dist currently only works with Git or Mercurial repos
run: |
pacman -Sy --noconfirm mingw-w64-x86_64-gcc \
mingw-w64-x86_64-pkg-config \
mingw-w64-x86_64-ninja \
mingw-w64-x86_64-librime \
mingw-w64-x86_64-python-build git
- uses: cachix/install-nix-action@v24
if: runner.os == 'macOS'
with:
nix_path: nixpkgs=channel:nixpkgs-unstable
extra_nix_config: |
experimental-features = nix-command flakes
access-tokens = github.com=${{ secrets.GITHUB_TOKEN }}
- name: Install dependencies
if: runner.os == 'macOS'
run: |
nix-env -if'<nixpkgs>' librime
- name: Upgrade version
if: startsWith(github.ref, 'refs/tags/')
run: |
perl -pi -e"s/(?<=version: ')[^']+/$GITHUB_REF_NAME/g" meson.build
git add -A
git config --global user.name 'Github Actions'
git config --global user.email \
'41898282+github-actions[bot]@users.noreply.github.com'
git commit -m ":bookmark: Dump version" || true
- name: Install common dependencies
if: runner.os != 'Windows'
# windows uses msys2's pip's python-build
# ERROR Command '['D:/a/_temp/msys64/mingw64/bin/python.exe', '-m',
# 'pip', '--python',
# 'D:/a/_temp/msys64/tmp/build-env-6w5hd7wi/bin/python.exe', 'install',
# '--use-pep517', '--no-warn-script-location', '--no-compile', '-r',
# 'D:/a/_temp/msys64/tmp/build-reqs-zy4dg0x1.txt']' returned non-zero
# exit status 1.
# ubuntu uses apt's pip's python-build
# ERROR Virtual environment creation failed, executable
# /tmp/build-env-c4hi79lc/local/bin/python missing
run: |
pip install uv
- name: Build
run: |
PKG_CONFIG_PATH="$HOME/.nix-profile/lib/pkgconfig" uv build --wheel
- if: runner.os == 'Linux'
run: |
uv build --sdist
- uses: actions/upload-artifact@v4
with:
name: artifact-${{matrix.runs-on}}
path: |
${{env.files}}
publish:
needs: build
runs-on: ubuntu-latest
if: startsWith(github.ref, 'refs/tags/')
steps:
- uses: actions/download-artifact@v4
with:
pattern: artifact-*
merge-multiple: true
path: dist
- name: Rename
run: |
sudo apt-get -y update
sudo apt-get -y install rename
rename \
's/linux/manylinux_2_17/;s/mingw_x86_64_msvcrt_gnu/win_amd64/' \
dist/*
- uses: pypa/gh-action-pypi-publish@release/v1
with:
password: ${{secrets.PYPI_API_TOKEN}}
- uses: softprops/action-gh-release@v2
with:
# body_path: build/CHANGELOG.md
files: |
${{env.files}}
deploy-aur:
needs: build
runs-on: ubuntu-latest
if: startsWith(github.ref, 'refs/tags/')
steps:
- uses: Freed-Wu/update-aur-package@v1.0.11
with:
package_name: python-pyrime
ssh_private_key: ${{secrets.AUR_SSH_PRIVATE_KEY}}
deploy-nur:
needs: build
runs-on: ubuntu-latest
if: startsWith(github.ref, 'refs/tags/')
steps:
- name: Trigger Workflow
run: >
curl -X POST -d '{"ref": "main"}'
-H "Accept: application/vnd.github.v3+json"
-H "Authorization: Bearer ${{secrets.GH_TOKEN}}"
https://api.github.com/repos/Freed-Wu/nur-packages/actions/workflows/version.yml/dispatches
deploy-ppa:
needs: build
runs-on: ubuntu-latest
if: startsWith(github.ref, 'refs/tags/')
steps:
- uses: actions/checkout@v4
with:
path: pyrime-${{github.ref_name}}
- name: Build
run: |
tar vcaf pyrime-${{github.ref_name}}.tar.gz \
pyrime-${{github.ref_name}}
- uses: yuezk/publish-ppa-package@main
with:
repository: freedwu/rime
series: jammy noble oracular plucky
extra_ppa: freedwu/backport
gpg_private_key: ${{secrets.GPG_PRIVATE_KEY}}
gpg_passphrase: ${{secrets.GPG_PASSPHRASE}}
tarball: ./*.tar.*
deb_email: ${{secrets.DEB_EMAIL}}
deb_fullname: freedwu
debmake_arguments: -bpyrime:python3