-
Notifications
You must be signed in to change notification settings - Fork 2
130 lines (113 loc) · 3.8 KB
/
build.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
name: Build
# Controls when the action will run.
on:
# Triggers the workflow on push or pull request events but only for the master branch
push:
branches: [ main ]
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:
jobs:
version:
runs-on: 'ubuntu-latest'
outputs:
version: ${{ steps.version.outputs.version }}
steps:
- name: Checking out the repo
uses: actions/checkout@v4
- name: Figure out version string
id: version
shell: sh
run: |
# get the latest commit hash in the short form
COMMIT=$(git rev-parse --short HEAD)
# get the latest commit date in the form of YYYYmmdd
DATE=$(git log -1 --format=%cd --date=format:'%y%m%d%H%M')
echo "version=${DATE}-${COMMIT}" >> "$GITHUB_OUTPUT"
build:
needs: [version]
# convert this to a matrix if builds differ between platforms
runs-on: ${{ matrix.os }}
strategy:
matrix:
# preferring older OS versions for better backward compat,
# the build platform may be the oldest platform it works on
os: [ 'ubuntu-22.04', 'ubuntu-22.04-arm', 'windows-2022', 'macos-14', 'macos-13' ]
# [ 'ubuntu-22.04', 'windows-latest', 'macos-latest']
outputs:
version: ${{ needs.version.outputs.version }}
steps:
- name: Checking out the repo
uses: actions/checkout@v4
# see *py_ver* in ci/update.py
- name: Setting up Python
uses: actions/setup-python@v5
with:
python-version: '3.12'
cache: pip
cache-dependency-path: |
requirements.txt
- name: Install dependencies
run: |
python -m pip install --upgrade pip
python -m pip install --progress-bar=off -r requirements.txt
python -m pip install pyinstaller
- name: Get OS and machine architecture
id: os
shell: python
run: |
import os, platform
machine = platform.machine().replace("x86_", "intel")
with open(os.environ["GITHUB_OUTPUT"], "a") as fd:
fd.write(f"res={platform.system()}-{machine}\n")
- name: Build
env:
VERSION: ${{ needs.version.outputs.version }}
shell: sh
run: |
OS=${{ steps.os.outputs.res }}
which sed
sed -E -i -e "s/(name=['\"])([^'\"\.]+)((\.[^'\"]+)?['\"],)/\1\2-$VERSION-${OS}\3/" LiveFT.spec
cat LiveFT.spec # show result of sed replacement
pyinstaller LiveFT.spec
- name: Create DMG
if: startsWith(matrix.os, 'macos')
shell: sh
run: |
cd dist
fn="$(ls -d LiveFT*.app)"; fn="${fn%.*}"
hdiutil create -fs HFS+ -srcfolder "$fn.app" -volname "$fn" "$fn.dmg"
rm -Rf "$fn.app" "$fn"
- name: Check what was created
shell: sh
run: ls -la dist
- name: Store built packages for publishing later
uses: actions/upload-artifact@v4
with:
name: package-${{ matrix.os }}
path: dist/*
overwrite: true
if-no-files-found: 'error'
publish:
needs: [build]
runs-on: 'ubuntu-latest'
steps:
- name: Download previuously built package artifacts
uses: actions/download-artifact@v4
with:
pattern: package-*
merge-multiple: true
path: dist
- name: Check contents
run: |
pwd
ls -la dist
[ "$(find dist -type f | wc -l)" -gt 0 ] # fails if no files where created
- name: Release
if: false
uses: softprops/action-gh-release@v2
with:
make_latest: true
draft: false
prerelease: false
tag_name: ${{ needs.build.outputs.version }}
files: dist/*