Skip to content

fix: Skip entire job instead of steps for platform filter #5

fix: Skip entire job instead of steps for platform filter

fix: Skip entire job instead of steps for platform filter #5

Workflow file for this run

name: Build SurfManager

Check failure on line 1 in .github/workflows/build.yml

View workflow run for this annotation

GitHub Actions / .github/workflows/build.yml

Invalid workflow file

(Line: 46, Col: 9): Unrecognized named-value: 'matrix'. Located at position 105 within expression: github.event_name == 'push' || github.event.inputs.platform == 'all' || github.event.inputs.platform == matrix.name
on:
push:
tags:
- 'v*'
workflow_dispatch:
inputs:
platform:
description: 'Target Platform'
required: true
default: 'all'
type: choice
options:
- all
- windows-amd64
- linux-amd64
- macos-amd64
- macos-arm64
jobs:
build:
strategy:
matrix:
include:
- os: windows-latest
platform: windows/amd64
output: SurfManager-windows-amd64.exe
name: windows-amd64
- os: ubuntu-20.04
platform: linux/amd64
output: SurfManager-linux-amd64
name: linux-amd64
- os: macos-latest
platform: darwin/amd64
output: SurfManager-darwin-amd64
name: macos-amd64
- os: macos-latest
platform: darwin/arm64
output: SurfManager-darwin-arm64
name: macos-arm64
runs-on: ${{ matrix.os }}
# Skip entire job if platform doesn't match (workflow_dispatch only)
if: |
github.event_name == 'push' ||
github.event.inputs.platform == 'all' ||
github.event.inputs.platform == matrix.name
steps:
- name: Checkout
if: steps.filter.outputs.skip == 'false'
uses: actions/checkout@v4
- name: Setup Go
if: steps.filter.outputs.skip == 'false'
uses: actions/setup-go@v5
with:
go-version: '1.22'
- name: Setup Node.js
if: steps.filter.outputs.skip == 'false'
uses: actions/setup-node@v4
with:
node-version: '20'
- name: Install Wails CLI
if: steps.filter.outputs.skip == 'false'
run: go install github.com/wailsapp/wails/v2/cmd/wails@latest
# Linux dependencies (Wails v2 requires webkit2gtk-4.0, only available on Ubuntu 20.04)
- name: Install Linux Dependencies
if: steps.filter.outputs.skip == 'false' && startsWith(matrix.os, 'ubuntu')
run: |
sudo apt-get update
sudo apt-get install -y libgtk-3-dev libwebkit2gtk-4.0-dev
# Build
- name: Build
if: steps.filter.outputs.skip == 'false'
run: wails build -platform ${{ matrix.platform }} -o ${{ matrix.output }}
# Package macOS .app to zip
- name: Package macOS App
if: steps.filter.outputs.skip == 'false' && startsWith(matrix.os, 'macos')
run: |
cd build/bin
# Wails creates .app bundle, zip it for distribution
if [ -d "*.app" ] || [ -d "${{ matrix.output }}.app" ]; then
zip -r ${{ matrix.output }}.zip *.app
elif [ -d "SurfManager.app" ]; then
mv SurfManager.app ${{ matrix.output }}.app
zip -r ${{ matrix.output }}.zip ${{ matrix.output }}.app
fi
# Upload artifact - Windows/Linux
- name: Upload Artifact (Windows/Linux)
if: steps.filter.outputs.skip == 'false' && !startsWith(matrix.os, 'macos')
uses: actions/upload-artifact@v4
with:
name: ${{ matrix.output }}
path: build/bin/${{ matrix.output }}*
# Upload artifact - macOS
- name: Upload Artifact (macOS)
if: steps.filter.outputs.skip == 'false' && startsWith(matrix.os, 'macos')
uses: actions/upload-artifact@v4
with:
name: ${{ matrix.output }}
path: build/bin/${{ matrix.output }}.zip
release:
needs: build
runs-on: ubuntu-latest
if: startsWith(github.ref, 'refs/tags/')
steps:
- name: Download all artifacts
uses: actions/download-artifact@v4
with:
path: artifacts
- name: Display structure
run: ls -R artifacts
- name: Create Release
uses: softprops/action-gh-release@v1
with:
files: artifacts/**/*
generate_release_notes: true
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}