-
Notifications
You must be signed in to change notification settings - Fork 0
175 lines (145 loc) · 7.39 KB
/
release-linux.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
name: Release Linux App
on:
release:
types: [ published ]
workflow_dispatch:
inputs:
tag:
description: 'Version tag'
required: true
default: '1.0.0'
jobs:
release:
name: Release Linux App
runs-on: ubuntu-20.04
strategy:
matrix:
platform:
- linux/amd64
steps:
- name: Checkout source code
uses: actions/checkout@v3
- name: Normalise platform tag
id: normalise_platform
shell: bash
run: |
tag=$(echo ${{ matrix.platform }} | sed -e 's/\//_/g')
echo "tag=$tag" >> "$GITHUB_OUTPUT"
- name: Normalise platform arch
id: normalise_platform_arch
run: |
if [ "${{ matrix.platform }}" == "linux/amd64" ]; then
echo "arch=x86_64" >> "$GITHUB_OUTPUT"
elif [ "${{ matrix.platform }}" == "linux/aarch64" ]; then
echo "arch=aarch64" >> "$GITHUB_OUTPUT"
fi
- name: Normalise version tag
id: normalise_version
shell: bash
run: |
if [ "${{ github.event.release.tag_name }}" == "" ]; then
version=$(echo ${{ github.event.inputs.tag }} | sed -e 's/v//g')
echo "version=$version" >> "$GITHUB_OUTPUT"
else
version=$(echo ${{ github.event.release.tag_name }} | sed -e 's/v//g')
echo "version=$version" >> "$GITHUB_OUTPUT"
fi
- name: Setup Go
uses: actions/setup-go@v4
with:
go-version: stable
- name: Install wails
shell: bash
run: go install github.com/wailsapp/wails/v2/cmd/wails@v2.8.0
- name: Install Ubuntu prerequisites
shell: bash
run: |
sudo apt-get update
sudo apt-get install -y libgtk-3-dev libwebkit2gtk-4.0-dev libfuse-dev libfuse2
- name: Setup Node
uses: actions/setup-node@v3
with:
node-version: 20
- name: Build frontend assets
shell: bash
run: |
npm install -g npm@9
jq '.info.productVersion = "${{ steps.normalise_version.outputs.version }}"' wails.json > tmp.json
mv tmp.json wails.json
cd frontend
jq '.version = "${{ steps.normalise_version.outputs.version }}"' package.json > tmp.json
mv tmp.json package.json
npm install
- name: Build wails app for Linux
shell: bash
run: |
CGO_ENABLED=1 wails build -platform ${{ matrix.platform }} \
-ldflags "-X main.version=v${{ steps.normalise_version.outputs.version }} -X main.gaMeasurementID=${{ secrets.GA_MEASUREMENT_ID }} -X main.gaSecretKey=${{ secrets.LINUX_GA_SECRET }}" \
-o mysql-binlog
- name: Setup control template
shell: bash
run: |
content=$(cat build/linux/mysql-binlog_0.0.0_amd64/DEBIAN/control)
content=$(echo "$content" | sed -e "s/{{.Name}}/$(jq -r '.name' wails.json)/g")
content=$(echo "$content" | sed -e "s/{{.Info.ProductVersion}}/$(jq -r '.info.productVersion' wails.json)/g")
content=$(echo "$content" | sed -e "s/{{.Author.Name}}/$(jq -r '.author.name' wails.json)/g")
content=$(echo "$content" | sed -e "s/{{.Author.Email}}/$(jq -r '.author.email' wails.json)/g")
content=$(echo "$content" | sed -e "s/{{.Info.Comments}}/$(jq -r '.info.comments' wails.json)/g")
echo $content
echo "$content" > build/linux/mysql-binlog_0.0.0_amd64/DEBIAN/control
- name: Setup app template
shell: bash
run: |
content=$(cat build/linux/mysql-binlog_0.0.0_amd64/usr/share/applications/mysql-binlog.desktop)
content=$(echo "$content" | sed -e "s/{{.Info.ProductName}}/$(jq -r '.info.productName' wails.json)/g")
content=$(echo "$content" | sed -e "s/{{.Info.Comments}}/$(jq -r '.info.comments' wails.json)/g")
echo $content
echo "$content" > build/linux/mysql-binlog_0.0.0_amd64/usr/share/applications/mysql-binlog.desktop
- name: Package up deb file
shell: bash
run: |
mv build/bin/mysql-binlog build/linux/mysql-binlog_0.0.0_amd64/usr/local/bin/
cd build/linux
mv mysql-binlog_0.0.0_amd64 "mysql-binlog_${{ steps.normalise_version.outputs.version }}_amd64"
sed -i 's/0.0.0/${{ steps.normalise_version.outputs.version }}/g' "mysql-binlog_${{ steps.normalise_version.outputs.version }}_amd64/DEBIAN/control"
dpkg-deb --build -Zxz "mysql-binlog_${{ steps.normalise_version.outputs.version }}_amd64"
- name: Package up appimage file
run: |
curl https://github.com/linuxdeploy/linuxdeploy/releases/download/1-alpha-20240109-1/linuxdeploy-${{ steps.normalise_platform_arch.outputs.arch }}.AppImage \
-o linuxdeploy \
-L
chmod u+x linuxdeploy
./linuxdeploy --appdir AppDir
pushd AppDir
# Copy WebKit files.
find /usr/lib* -name WebKitNetworkProcess -exec mkdir -p $(dirname '{}') \; -exec cp --parents '{}' "." \; || true
find /usr/lib* -name WebKitWebProcess -exec mkdir -p $(dirname '{}') \; -exec cp --parents '{}' "." \; || true
find /usr/lib* -name libwebkit2gtkinjectedbundle.so -exec mkdir -p $(dirname '{}') \; -exec cp --parents '{}' "." \; || true
popd
mkdir -p AppDir/usr/share/icons/hicolor/512x512/apps
build_dir="build/linux/mysql-binlog_${{ steps.normalise_version.outputs.version }}_amd64"
cp -r $build_dir/usr/share/icons/hicolor/512x512/apps/mysql-binlog.png AppDir/usr/share/icons/hicolor/512x512/apps/
cp $build_dir/usr/local/bin/mysql-binlog AppDir/usr/bin/
sed -i 's#/usr/local/bin/mysql-binlog#mysql-binlog#g' $build_dir/usr/share/applications/mysql-binlog.desktop
curl -o linuxdeploy-plugin-gtk.sh "https://raw.githubusercontent.com/tauri-apps/linuxdeploy-plugin-gtk/master/linuxdeploy-plugin-gtk.sh"
sed -i '/XDG_DATA_DIRS/a export WEBKIT_DISABLE_COMPOSITING_MODE=1' linuxdeploy-plugin-gtk.sh
chmod +x linuxdeploy-plugin-gtk.sh
curl -o AppDir/AppRun https://github.com/AppImage/AppImageKit/releases/download/continuous/AppRun-${{ steps.normalise_platform_arch.outputs.arch }} -L
./linuxdeploy --appdir AppDir \
--output=appimage \
--plugin=gtk \
-e $build_dir/usr/local/bin/mysql-binlog \
-d $build_dir/usr/share/applications/mysql-binlog.desktop
- name: Rename deb
working-directory: ./build/linux
run: mv "mysql-binlog_${{ steps.normalise_version.outputs.version }}_amd64.deb" "mysql-binlog_${{ steps.normalise_version.outputs.version }}_${{ steps.normalise_platform.outputs.tag }}.deb"
- name: Rename appimage
run: mv mysql_binlog-${{ steps.normalise_platform_arch.outputs.arch }}.AppImage "mysql-binlog_${{ steps.normalise_version.outputs.version }}_${{ steps.normalise_platform.outputs.tag }}.AppImage"
- name: Upload release asset
uses: softprops/action-gh-release@v1
with:
tag_name: v${{ steps.normalise_version.outputs.version }}
files: |
./build/linux/mysql-binlog_${{ steps.normalise_version.outputs.version }}_${{ steps.normalise_platform.outputs.tag }}.deb
mysql-binlog_${{ steps.normalise_version.outputs.version }}_${{ steps.normalise_platform.outputs.tag }}.AppImage
token: ${{ secrets.GITHUB_TOKEN }}