Skip to content

Commit

Permalink
dont hardcode project name in build-actions
Browse files Browse the repository at this point in the history
  • Loading branch information
rainu committed Dec 12, 2024
1 parent db799d2 commit 33058f3
Showing 1 changed file with 38 additions and 34 deletions.
72 changes: 38 additions & 34 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
name: Wails build

on:
push:
tags:
# Match any new tag
- '*'
# inspired by https://github.com/dAppServer/wails-build-action/blob/main/action.yml

on: [push]

env:
# Necessary for most environments as build failure can occur due to OOM issues
Expand All @@ -29,66 +27,72 @@ jobs:
]
runs-on: ${{ matrix.build.os }}
steps:
# Checkout code
- name: [Common] Check out code
uses: actions/checkout@v2

# Setup and configure GoLang
- name: Setup GoLang
- name: [Common] Setup GoLang
uses: actions/setup-go@v4
with:
check-latest: true
go-version: 1.23.1
# Setup and configure NodeJS
- name: Setup NodeJS
- name: [Common] Setup NodeJS
uses: actions/setup-node@v3
with:
node-version: 20
# install wails
- name: Install Wails
run: go install github.com/wailsapp/wails/v2/cmd/wails@v2.9.0

# install wails and dependencies
- name: [Common] Install Wails
run: |
WAILS_VERSION=$(cat go.mod | grep "^\s*github.com/wailsapp/wails/" | sed 's/^\s*//' | cut -d" " -f2)
echo "Use Wails version: ${WAILS_VERSION}"
go install github.com/wailsapp/wails/v2/cmd/wails@${WAILS_VERSION}
shell: bash
- name: Install Linux Wails deps
- name: [Linux] Install Wails deps
if: runner.os == 'Linux'
run: sudo apt-get update && sudo apt-get install libgtk-3-0 libwebkit2gtk-4.0-dev gcc-aarch64-linux-gnu upx-ucl
shell: bash
- name: Install macOS Wails deps
- name: [Windows] Install Wails deps
if: runner.os == 'Windows' && matrix.build.platform != 'windows/arm64'
run: choco install upx
shell: powershell
- name: [MacOS] Install Wails deps
if: runner.os == 'macOS'
run: brew install mitchellh/gon/gon
run: brew install upx
shell: bash
- name: Check out code into the Go module directory
uses: actions/checkout@v2
- name: Build
id: binary_build
# compression will warn if upx is not installed (windows/macOS) but will not break the build
run: wails build -platform ${{ matrix.build.platform }} -upx -o ${{ matrix.build.name }}

# Add permissions
- name: Add macOS perms
if: runner.os == 'macOS'
run: chmod +x build/bin/*/Contents/MacOS/*
shell: bash
- name: Add Linux perms
if: runner.os == 'Linux'
run: chmod +x build/bin/*
# Build
- name: [Common] Build
shell: bash
# compression will warn if upx is not installed (windows/macOS) but will not break the build
run: wails build -platform ${{ matrix.build.platform }} -upx -o ${{ matrix.build.name }}

# Package MacOS
- name: Build .app zip file
- name: [MacOS] Build .app zip file
if: runner.os == 'macOS'
shell: bash
run: |
ditto -c -k ./build/bin/ask-mai.app ./build/bin/${{ matrix.build.name }}.app.zip
- name: Building Installer
APP_DIR_NAME="$(cat wails.json | jq -r '.name' ).app"
ditto -c -k ./build/bin/${APP_DIR_NAME} ./build/bin/${{ matrix.build.name }}.app.zip
- name: [MacOS] Building Installer
if: runner.os == 'macOS'
shell: bash
run: |
productbuild --component ./build/bin/ask-mai.app ./build/bin/${{ matrix.build.name }}.pkg
APP_DIR_NAME="$(cat wails.json | jq -r '.name' ).app"
productbuild --component ./build/bin/${APP_DIR_NAME} ./build/bin/${{ matrix.build.name }}.pkg
# Upload build assets
- uses: actions/upload-artifact@v3
# Upload build assets (only for tags)
- name: [Common] Upload build artifacts
uses: actions/upload-artifact@v3
if: startsWith(github.ref, 'refs/tags/')
with:
name: Wails Build ${{ matrix.build.name }}
path: |
*/bin/
*\bin\*
- name: Release
- name: [Common] Release
uses: softprops/action-gh-release@v1
if: startsWith(github.ref, 'refs/tags/')
with:
Expand Down

0 comments on commit 33058f3

Please sign in to comment.