Release Linux App #2
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | |
- linux/arm64 | |
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/arm64" ]; 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@latest | |
- 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 gcc-aarch64-linux-gnu | |
- name: Setup Bun | |
uses: oven-sh/setup-bun@v2 | |
with: | |
bun-version: 1.1.38 | |
- name: Build frontend | |
shell: bash | |
run: | | |
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 | |
bun install | |
- name: Build wails app for Linux | |
shell: bash | |
run: | | |
if [ "${{ matrix.platform }}" = "linux/arm64" ]; then | |
export CC_FOR_TARGET=gcc-aarch64-linux-gnu | |
export CC=aarch64-linux-gnu-gcc | |
fi | |
CGO_ENABLED=1 wails build -platform ${{ matrix.platform }} \ | |
-ldflags "-X main.version=${{ github.event.release.tag_name }} -X tinkerpad/backend/encrypt.secret=${{ secrets.TINKERPAD_SECRET }}" \ | |
-o tinkerpad | |
- name: Setup control template | |
shell: bash | |
run: | | |
content=$(cat build/linux/DEBIAN/control) | |
content=$(echo "$content" | sed -e "s/{{.Name}}/$(jq -r '.name' wails.json)/g") | |
content=$(echo "$content" | sed -e "s/{{.Info.ProductVersion}}/${{ github.event.release.tag_name }}/g") | |
content=$(echo "$content" | sed -e "s/{{.Info.Arch}}/${{ steps.normalise_platform.outputs.tag }}/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") | |
echo $content | |
echo "$content" > build/linux/DEBIAN/control | |
- name: Setup app template | |
shell: bash | |
run: | | |
content=$(cat build/linux/usr/share/applications/tinkerpad.desktop) | |
content=$(echo "$content" | sed -e "s/{{.Info.ProductName}}/$(jq -r '.name' wails.json)/g") | |
echo $content | |
echo "$content" > build/linux/usr/share/applications/tinkerpad.desktop | |
- name: Package up deb file | |
shell: bash | |
run: | | |
mkdir -p build/linux/usr/local/bin/ | |
mv build/bin/tinkerpad build/linux/usr/local/bin/ | |
cd build | |
mv linux "tinkerpad_${{ steps.normalise_version.outputs.version }}_${{ steps.normalise_platform.outputs.tag }}" | |
sed -i 's/0.0.0/${{ steps.normalise_version.outputs.version }}/g' "tinkerpad_${{ steps.normalise_version.outputs.version }}_${{ steps.normalise_platform.outputs.tag }}/DEBIAN/control" | |
dpkg-deb --build -Zxz "tinkerpad_${{ steps.normalise_version.outputs.version }}_${{ steps.normalise_platform.outputs.tag }}" | |
- 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/tinkerpad_${{ steps.normalise_version.outputs.version }}_${{ steps.normalise_platform.outputs.tag }}" | |
cp -r $build_dir/usr/share/icons/hicolor/512x512/apps/tinkerpad.png AppDir/usr/share/icons/hicolor/512x512/apps/ | |
cp $build_dir/usr/local/bin/tinkerpad AppDir/usr/bin/ | |
sed -i 's#/usr/local/bin/tinkerpad#tinkerpad#g' $build_dir/usr/share/applications/tinkerpad.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/tinkerpad \ | |
-d $build_dir/usr/share/applications/tinkerpad.desktop | |
- name: Rename appimage | |
run: mv Tinkerpad-${{ steps.normalise_platform_arch.outputs.arch }}.AppImage "tinkerpad_${{ 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/tinkerpad_${{ steps.normalise_version.outputs.version }}_${{ steps.normalise_platform.outputs.tag }}.deb | |
tinkerpad_${{ steps.normalise_version.outputs.version }}_${{ steps.normalise_platform.outputs.tag }}.AppImage | |
token: ${{ secrets.GITHUB_TOKEN }} |