-
Notifications
You must be signed in to change notification settings - Fork 2
149 lines (134 loc) · 5.56 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
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
cat ./node_modules/fluent-ffmpeg/lib/processor.js
shell: bash
# test application here
- name: Fire up Application
run: npm run start
# end test application
# Fetch tags from origin
- name: Fetch all tags
run: git fetch --tags
# 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 }}."