-
Notifications
You must be signed in to change notification settings - Fork 390
290 lines (258 loc) · 12.4 KB
/
build-macast.yaml
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
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
# Copyright (c) 2021 by xfangfang. All Rights Reserved.
name: Build Macast
on:
push:
branches:
- dev_test
- morelog
pull_request:
workflow_dispatch:
inputs:
ssh_darwin:
description: 'SSH connection to Darwin'
required: false
default: 'false'
ssh_ubuntu:
description: 'SSH connection to Ubuntu'
required: false
default: 'false'
release:
description: 'Push a new release'
required: false
default: 'false'
jobs:
release:
needs: [ build-nt, build-darwin, build-amd64, build-armv7 ]
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
- uses: actions/download-artifact@v2
- name: Version
run: |
ls -R
export VERSION=`cat macast/.version`
echo "VERSION=v$VERSION" >> $GITHUB_ENV
echo "DIST_DMG=Macast-MacOS-v${VERSION}.dmg" >> $GITHUB_ENV
echo "DIST_EXE=Macast-Windows-v${VERSION}.exe" >> $GITHUB_ENV
echo "DIST_EXE_DEBUG=Macast-Windows-v${VERSION}-debug.exe" >> $GITHUB_ENV
echo "DIST_AMD64=Macast-Linux-v${VERSION}-amd64" >> $GITHUB_ENV
echo "DIST_AMD64_DEB=Macast-Linux-v${VERSION}-amd64.deb" >> $GITHUB_ENV
echo "DIST_ARMV7=Macast-Linux-v${VERSION}-armv7" >> $GITHUB_ENV
echo "DIST_ARMV7_DEB=Macast-Linux-v${VERSION}-armv7.deb" >> $GITHUB_ENV
echo $GITHUB_ENV
- name: Upload
if: github.event.inputs.release == 'true' && github.event.inputs.release != 'false' && !cancelled()
uses: ncipollo/release-action@v1
with:
name: Macast ${{ env.VERSION }}
tag: ${{ env.VERSION }}
omitBodyDuringUpdate: true
body: This release is built by github-action.
token: ${{ secrets.GITHUB_TOKEN }}
allowUpdates: true
artifacts: ${{ env.DIST_DMG }}/${{ env.DIST_DMG }},${{ env.DIST_EXE }}/${{ env.DIST_EXE }},${{ env.DIST_EXE_DEBUG }}/${{ env.DIST_EXE_DEBUG }},${{ env.DIST_AMD64 }}/${{ env.DIST_AMD64 }},${{ env.DIST_AMD64_DEB }}/${{ env.DIST_AMD64_DEB }},${{ env.DIST_ARMV7_DEB }}/${{ env.DIST_ARMV7_DEB }}
build-amd64:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Install Requirement
run: |
sudo apt update
sudo apt install -y gettext
docker pull xfangfang/build-macast
- name: Build
id: compile
run: |
for file in i18n/*; do msgfmt -o $file/LC_MESSAGES/macast.mo $file/LC_MESSAGES/macast.po;echo $file;done
export VERSION=`cat macast/.version`
export DIST_AMD64_DEB=Macast-Linux-v${VERSION}-amd64.deb
export DIST_AMD64=Macast-Linux-v${VERSION}-amd64
echo "DIST_AMD64_DEB=${DIST_AMD64_DEB}" >> $GITHUB_ENV
echo "DIST_AMD64=${DIST_AMD64}" >> $GITHUB_ENV
echo "VERSION=v$VERSION" >> $GITHUB_ENV
docker run --rm -v "$(pwd):/src/" xfangfang/build-macast \
'pip install -r requirements/common.txt && \
pip install -U pyinstaller && \
pyinstaller --noconfirm -F -w \
--additional-hooks-dir=. \
--add-data="macast/.version:." \
--add-data="macast/xml/*:macast/xml" \
--add-data="i18n/zh_CN/LC_MESSAGES/*.mo:i18n/zh_CN/LC_MESSAGES" \
--add-data="macast/assets/*:macast/assets" \
--add-data="macast/assets/fonts/*:macast/assets/fonts" \
--exclude-module=tkinter \
--distpath="app" \
Macast.py'
sudo chown 1000 app/Macast
cp app/Macast $DIST_AMD64
#build deb
mkdir -p dist/DEBIAN
mkdir -p dist/usr/bin
mkdir -p dist/usr/share/applications
mkdir -p dist/usr/share/icons
echo -e "Package: Macast\nVersion: ${VERSION}\nArchitecture: amd64\nMaintainer: xfangfang\nDescription: DLNA Media Renderer\nDepends: mpv" > dist/DEBIAN/control
echo -e "[Desktop Entry]\nName=Macast\nComment=DLNA Media Renderer\nExec=/usr/bin/macast\nIcon=/usr/share/icons/Macast.png\nTerminal=false\nType=Application\nCategories=Video" > dist/usr/share/applications/macast.desktop
cp app/Macast dist/usr/bin/macast
cp macast/assets/icon.png dist/usr/share/icons/Macast.png
dpkg -b dist $DIST_AMD64_DEB
echo "::set-output name=status::success"
- name: SSH connection to Actions
uses: P3TERX/[email protected]
if: (github.event.inputs.ssh_ubuntu == 'true' && github.event.inputs.ssh_ubuntu != 'false') || contains(github.event.action, 'ssh_ubuntu')
env:
TELEGRAM_CHAT_ID: ${{ secrets.TELEGRAM_CHAT_ID }}
TELEGRAM_BOT_TOKEN: ${{ secrets.TELEGRAM_BOT_TOKEN }}
- name: Upload dist linux x64
uses: actions/upload-artifact@v2
if: steps.compile.outputs.status == 'success'
with:
name: ${{ env.DIST_AMD64 }}
path: ${{ env.DIST_AMD64 }}
- name: Upload dist deb
uses: actions/upload-artifact@v2
if: steps.compile.outputs.status == 'success'
with:
name: ${{ env.DIST_AMD64_DEB }}
path: ${{ env.DIST_AMD64_DEB }}
build-nt:
runs-on: windows-2019
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Install Requirement
run: |
pip3 install -r requirements/common.txt
pip3 install pyinstaller
$client = new-object System.Net.WebClient
$client.DownloadFile('https://github.com/xfangfang/Macast/releases/download/v0.1/mpv-0.34.0-x86_64.7z','mpv.7z')
7z x -obin mpv.7z *.exe
$client.DownloadFile('https://github.com/xfangfang/Macast/releases/download/v0.1/gettext0.21-iconv1.16-static-64.zip','gettext.zip')
7z x -ogettext gettext.zip bin/msgfmt.exe
- name: Build
id: compile
run: |
Get-ChildItem i18n | ForEach-Object -Process{gettext/bin/msgfmt -o $_/LC_MESSAGES/macast.mo $_/LC_MESSAGES/macast.po;echo $_.name}
$VERSION=cat macast/.version
echo "DIST_EXE=Macast-Windows-v${VERSION}.exe" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
echo "DIST_EXE_DEBUG=Macast-Windows-v${VERSION}-debug.exe" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
echo "VERSION=v${VERSION}" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
pyinstaller --noconfirm -F -w --additional-hooks-dir=. --add-data="macast/.version;." --add-data="macast/xml/*;macast/xml" --add-data="i18n/zh_CN/LC_MESSAGES/*.mo;i18n/zh_CN/LC_MESSAGES" --add-data="macast/assets/*;macast/assets" --add-data="macast/assets/fonts/*;macast/assets/fonts" --add-binary="bin/mpv.exe;bin" --icon=macast/assets/icon.ico Macast.py
cp dist/Macast.exe Macast-Windows-v${VERSION}.exe
pyinstaller --noconfirm -F --additional-hooks-dir=. --add-data="macast/.version;." --add-data="macast/xml/*;macast/xml" --add-data="i18n/zh_CN/LC_MESSAGES/*.mo;i18n/zh_CN/LC_MESSAGES" --add-data="macast/assets/*;macast/assets" --add-data="macast/assets/fonts/*;macast/assets/fonts" --add-binary="bin/mpv.exe;bin" --icon=macast/assets/icon.ico Macast.py
cp dist/Macast.exe Macast-Windows-v${VERSION}-debug.exe
echo "::set-output name=status::success"
- name: Upload dist
uses: actions/upload-artifact@v2
if: steps.compile.outputs.status == 'success'
with:
name: ${{ env.DIST_EXE }}
path: ${{ env.DIST_EXE }}
- name: Upload dist debug
uses: actions/upload-artifact@v2
if: steps.compile.outputs.status == 'success'
with:
name: ${{ env.DIST_EXE_DEBUG }}
path: ${{ env.DIST_EXE_DEBUG }}
build-darwin:
runs-on: macos-11
steps:
- name: Checkout
uses: actions/checkout@v2
- name: install create-dmg
run: brew install create-dmg
- name: install universal python
run: |
wget https://www.python.org/ftp/python/3.9.8/python-3.9.8-macos11.pkg
sudo installer -pkg python-3.9.8-macos11.pkg -target /
- name: Install Requirement
run: |
pip3 install -r requirements/darwin.txt
pip3 install py2app
wget https://laboratory.stolendata.net/~djinn/mpv_osx/mpv-latest.tar.gz
mkdir -p bin && tar --strip-components 2 -C bin -xzvf mpv-latest.tar.gz mpv.app/Contents/MacOS
- name: Build
id: compile
run: |
for file in i18n/*; do msgfmt -o $file/LC_MESSAGES/macast.mo $file/LC_MESSAGES/macast.po;echo $file;done
python3 setup_py2app.py py2app --arch=x86_64
cp -R bin dist/Macast.app/Contents/Resources/
export VERSION=`cat macast/.version`
echo "DIST_DMG=Macast-MacOS-v${VERSION}.dmg" >> $GITHUB_ENV
echo "VERSION=v$VERSION" >> $GITHUB_ENV
create-dmg --window-pos 200 120 --window-size 800 400 --icon-size 100 --icon "Macast.app" 200 190 --hide-extension "Macast.app" --app-drop-link 600 185 --volname "Macast-v${VERSION} Installer" Macast-MacOS-v${VERSION}.dmg "dist/"
echo "::set-output name=status::success"
- name: SSH connection to Actions
uses: P3TERX/[email protected]
if: (github.event.inputs.ssh_darwin == 'true' && github.event.inputs.ssh_darwin != 'false') || contains(github.event.action, 'ssh_darwin')
env:
TELEGRAM_CHAT_ID: ${{ secrets.TELEGRAM_CHAT_ID }}
TELEGRAM_BOT_TOKEN: ${{ secrets.TELEGRAM_BOT_TOKEN }}
- name: Upload dist
uses: actions/upload-artifact@v2
if: steps.compile.outputs.status == 'success'
with:
name: ${{ env.DIST_DMG }}
path: ${{ env.DIST_DMG }}
build-armv7:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Install Requirement
run: |
sudo apt update
sudo apt install -y gettext
docker pull xfangfang/build-macast
- name: Set up QEMU
uses: docker/setup-qemu-action@v1
- name: Set up Docker Buildx
id: buildx
uses: docker/setup-buildx-action@v1
- name: Build
id: compile
run: |
for file in i18n/*; do msgfmt -o $file/LC_MESSAGES/macast.mo $file/LC_MESSAGES/macast.po;echo $file;done
export VERSION=`cat macast/.version`
export BUILD_PLATFORM=armv7
export DIST_DEB=Macast-Linux-v${VERSION}-${BUILD_PLATFORM}.deb
export DIST=Macast-Linux-v${VERSION}-${BUILD_PLATFORM}
echo "DIST_DEB=${DIST_DEB}" >> $GITHUB_ENV
echo "DIST=${DIST}" >> $GITHUB_ENV
echo "VERSION=v$VERSION" >> $GITHUB_ENV
docker run --platform=linux/arm/v7 --rm -v "$(pwd):/src/" xfangfang/build-macast:armv7-220105 \
'pyinstaller --noconfirm -F -w \
--additional-hooks-dir=. \
--add-data="macast/.version:." \
--add-data="macast/xml/*:macast/xml" \
--add-data="i18n/zh_CN/LC_MESSAGES/*.mo:i18n/zh_CN/LC_MESSAGES" \
--add-data="macast/assets/*.png:assets" \
--exclude-module=tkinter \
--distpath="app" \
Macast.py'
sudo chown 1000 app/Macast
cp app/Macast $DIST
#build deb
mkdir -p dist/DEBIAN
mkdir -p dist/usr/bin
mkdir -p dist/usr/share/applications
mkdir -p dist/usr/share/icons
echo -e "Package: Macast\nVersion: ${VERSION}\nArchitecture: armhf\nMaintainer: xfangfang\nDescription: DLNA Media Renderer\nDepends: mpv" > dist/DEBIAN/control
echo -e "[Desktop Entry]\nName=Macast\nComment=DLNA Media Renderer\nExec=/usr/bin/macast\nIcon=/usr/share/icons/Macast.png\nTerminal=false\nType=Application\nCategories=Video" > dist/usr/share/applications/macast.desktop
cp app/Macast dist/usr/bin/macast
cp macast/assets/icon.png dist/usr/share/icons/Macast.png
dpkg -b dist $DIST_DEB
echo "::set-output name=status::success"
- name: Upload dist linux
uses: actions/upload-artifact@v2
if: steps.compile.outputs.status == 'success'
with:
name: ${{ env.DIST }}
path: ${{ env.DIST }}
- name: Upload dist deb
uses: actions/upload-artifact@v2
if: steps.compile.outputs.status == 'success'
with:
name: ${{ env.DIST_DEB }}
path: ${{ env.DIST_DEB }}