Skip to content

Commit a787f8e

Browse files
committed
dont hardcode project name in build-actions
1 parent db799d2 commit a787f8e

File tree

1 file changed

+23
-27
lines changed

1 file changed

+23
-27
lines changed

.github/workflows/build.yml

Lines changed: 23 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
11
name: Wails build
22

3-
on:
4-
push:
5-
tags:
6-
# Match any new tag
7-
- '*'
3+
# inspired by https://github.com/dAppServer/wails-build-action/blob/main/action.yml
4+
5+
on: [push]
86

97
env:
108
# Necessary for most environments as build failure can occur due to OOM issues
@@ -40,49 +38,47 @@ jobs:
4038
uses: actions/setup-node@v3
4139
with:
4240
node-version: 20
43-
# install wails
41+
42+
# install wails and dependencies
4443
- name: Install Wails
45-
run: go install github.com/wailsapp/wails/v2/cmd/wails@v2.9.0
44+
run: |
45+
WAILS_VERSION=$(cat go.mod | grep "^\s*github.com/wailsapp/wails/" | sed 's/^\s*//' | cut -d" " -f2)
46+
echo "Use Wails version: ${WAILS_VERSION}"
47+
go install github.com/wailsapp/wails/v2/cmd/wails@${WAILS_VERSION}
4648
shell: bash
4749
- name: Install Linux Wails deps
4850
if: runner.os == 'Linux'
4951
run: sudo apt-get update && sudo apt-get install libgtk-3-0 libwebkit2gtk-4.0-dev gcc-aarch64-linux-gnu upx-ucl
5052
shell: bash
51-
- name: Install macOS Wails deps
52-
if: runner.os == 'macOS'
53-
run: brew install mitchellh/gon/gon
54-
shell: bash
55-
- name: Check out code into the Go module directory
53+
54+
# Checkout code
55+
- name: Check out code
5656
uses: actions/checkout@v2
57+
58+
# Build
5759
- name: Build
58-
id: binary_build
60+
shell: bash
5961
# compression will warn if upx is not installed (windows/macOS) but will not break the build
6062
run: wails build -platform ${{ matrix.build.platform }} -upx -o ${{ matrix.build.name }}
6163

62-
# Add permissions
63-
- name: Add macOS perms
64-
if: runner.os == 'macOS'
65-
run: chmod +x build/bin/*/Contents/MacOS/*
66-
shell: bash
67-
- name: Add Linux perms
68-
if: runner.os == 'Linux'
69-
run: chmod +x build/bin/*
70-
shell: bash
71-
7264
# Package MacOS
7365
- name: Build .app zip file
7466
if: runner.os == 'macOS'
7567
shell: bash
7668
run: |
77-
ditto -c -k ./build/bin/ask-mai.app ./build/bin/${{ matrix.build.name }}.app.zip
69+
APP_DIR_NAME="$(cat wails.json | jq -r '.name' ).app"
70+
ditto -c -k ./build/bin/${APP_DIR_NAME} ./build/bin/${{ matrix.build.name }}.app.zip
7871
- name: Building Installer
7972
if: runner.os == 'macOS'
8073
shell: bash
8174
run: |
82-
productbuild --component ./build/bin/ask-mai.app ./build/bin/${{ matrix.build.name }}.pkg
75+
APP_DIR_NAME="$(cat wails.json | jq -r '.name' ).app"
76+
productbuild --component ./build/bin/${APP_DIR_NAME} ./build/bin/${{ matrix.build.name }}.pkg
8377
84-
# Upload build assets
85-
- uses: actions/upload-artifact@v3
78+
# Upload build assets (only for tags)
79+
- name: Upload build artifacts
80+
uses: actions/upload-artifact@v3
81+
if: startsWith(github.ref, 'refs/tags/')
8682
with:
8783
name: Wails Build ${{ matrix.build.name }}
8884
path: |

0 commit comments

Comments
 (0)