-
Notifications
You must be signed in to change notification settings - Fork 2
173 lines (153 loc) · 6.43 KB
/
check-installation.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
name: Test Chirpity Compilation
run-name: ${{ github.actor }} is building chirpity
on: [push, workflow_dispatch]
jobs:
Build-Chirpity:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [windows-latest, macos-latest, ubuntu-latest]
env:
GH_TOKEN: ${{ secrets.GH_TOKEN }}
steps:
- run: echo "🎉 The job was automatically triggered by a ${{ github.event_name }} event."
- run: echo "🐧 This job is now running on a ${{ runner.os }} server hosted by GitHub!"
- run: echo "🔎 The name of your branch is ${{ github.ref }} and your repository is ${{ github.repository }}."
- name: Check out repository code
uses: actions/checkout@v4
- run: echo "💡 The ${{ github.repository }} repository has been cloned to the runner."
- run: echo "🖥️ The workflow is now ready to test your code on the runner."
- name: Setup node
uses: actions/setup-node@v3
with:
node-version: 20.0.x
- run: echo "🍏 Node setup status is ${{ job.status }}."
# Step to set up Python 3.11
- name: Set up Python 3.11
uses: actions/setup-python@v4
with:
python-version: '3.11'
- name: Install dependencies
run: |
npm install
echo "Install's status is ${{ job.status }}."
- name: Set platform-specific ffmpeg path
shell: bash
run: |
if [[ "$RUNNER_OS" == "Windows" ]]; then
PLATFORM="win32-x64"
BINARY="ffmpeg.exe"
elif [[ "$RUNNER_OS" == "macOS" ]]; then
PLATFORM="darwin-arm64"
BINARY="ffmpeg"
chmod +x ./build/$PLATFORM/ffmpeg
echo "Made ffmpeg binary executable for $PLATFORM."
elif [[ "$RUNNER_OS" == "Linux" ]]; then
PLATFORM="linux-x64"
BINARY="ffmpeg"
chmod +x ./build/$PLATFORM/ffmpeg
echo "Made ffmpeg binary executable for $PLATFORM."
fi
echo "Platform is $PLATFORM, Binary is $BINARY"
# Persist environment variables to the GitHub Actions environment
echo "PLATFORM=$PLATFORM" >> $GITHUB_ENV
echo "BINARY=$BINARY" >> $GITHUB_ENV
- name: Overwrite FFmpeg binary
run: |
echo "copying ./build/$PLATFORM/$BINARY to ./node_modules/@ffmpeg-installer/$PLATFORM/$BINARY"
cp ./build/$PLATFORM/$BINARY ./node_modules/@ffmpeg-installer/$PLATFORM/$BINARY
shell: bash
- name: Modify fluent-ffmpeg processor.js
run: |
sed -i -e '/^\s*setTimeout(function() {/,/}, 20);/c\
setTimeout(function() {\
if (ffmpegProc.exitCode === null){\
emitEnd(new Error('\''Output stream closed'\''));\
ffmpegProc.kill();\
}\
}, 5000);' ./node_modules/fluent-ffmpeg/lib/processor.js
# uncomment to view changed file
# cat ./node_modules/fluent-ffmpeg/lib/processor.js
shell: bash
- name: Modify colorScale.js - Add inverted greys colormap
run: |
# compatibility with sed on macOS
sed -i.bak '/"greys":\[{"index":0,"rgb":\[0,0,0\]},{"index":1,"rgb":\[255,255,255\]}\],/a\
"igreys":[{"index":0,"rgb":[255,255,255]},{"index":1,"rgb":[0,0,0]}],' ./node_modules/colormap/colorScale.js \
&& rm -f ./node_modules/colormap/colorScale.js.bak
shell: bash
# test application here
- name: Start Xvfb
if: runner.os == 'Linux'
run: |
sudo apt-get update
sudo apt-get install -y xvfb
Xvfb :99 -screen 0 1280x1024x24 &
# Set DISPLAY environment variable
echo "DISPLAY=:99" >> $GITHUB_ENV
# - name: Fire up Application
# env:
# DISPLAY: :99
# run: npm run test -- --disable-gpu --disable-software-rasterizer --disable-audio-output
# end test application
# Get the latest tag from origin/master
- name: Get the latest tag on origin/master
id: get_latest_tag
shell: bash
run: |
LATEST_TAG=$(gh api repos/${{ github.repository }}/tags --jq '.[0].name')
echo "LATEST_TAG=$LATEST_TAG" >> $GITHUB_ENV
# Get the current pushed tag
- name: Get the current pushed tag
id: get_current_tag
shell: bash
run: |
current_tag="${GITHUB_REF##*/}"
echo "CURRENT_TAG=$current_tag" >> $GITHUB_ENV
# Compare tags to decide if build should proceed
- name: Check if current tag is greater than the latest tag
id: check_tag
shell: bash
run: |
if [ "$(printf "%s\n%s" "$LATEST_TAG" "$CURRENT_TAG" | sort -V | tail -n 1)" != "$CURRENT_TAG" ]; then
echo "New tag is not greater than the latest tag on origin/master. Skipping build."
echo "skip_build=true" >> $GITHUB_ENV
fi
# Conditional build command for each OS
- name: Build Electron application
# if: env.skip_build != 'true' # Only run this if the tag comparison was true
shell: bash
run: |
if [[ "$RUNNER_OS" == "Windows" ]]; then
npm run build
elif [[ "$RUNNER_OS" == "macOS" ]]; then
npx electron-builder --mac -p always
else
npx electron-builder build --linux --x64 -p always
fi
- run: echo "Build status is ${{ job.status }}."
- name: Check installer exists
if: env.skip_build != 'true' # Only run this if the tag comparison was true
shell: bash
run: |
# Retrieve the version from package.json
VERSION=$(jq -r '.version' package.json)
# Construct the filename
if [[ "$RUNNER_OS" == "Windows" ]]; then
FILENAME="chirpity Setup $VERSION.exe"
elif [[ "$RUNNER_OS" == "macOS" ]]; then
FILENAME="chirpity-$VERSION-arm64.pkg"
else
FILENAME="chirpity-$VERSION.AppImage"
fi
# Check if the file exists
if [ -f "./dist/$FILENAME" ]; then
echo "Executable $FILENAME found in ./dist"
else
echo "Executable $FILENAME not found in ./dist" && exit 1
fi
- run: echo "File check status is ${{ job.status }}."
# Tests
- name: Test packaged application
if: runner.os != 'Linux'
run: npm test