Skip to content

Commit

Permalink
fix(CI): build and release
Browse files Browse the repository at this point in the history
  • Loading branch information
shiquda committed Dec 1, 2024
1 parent cc1f0f2 commit cc33199
Showing 1 changed file with 121 additions and 39 deletions.
160 changes: 121 additions & 39 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,115 +4,197 @@ on:
push:
tags:
- "v*.*.*" # trigger when tag is vX.X.X
workflow_dispatch:
inputs:
tag:
description: "Tag to build and release"
required: true
default: "v0.0.0"

jobs:
build:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
include:
- os: ubuntu-latest
build-platform: linux/amd64
build-name: crypto-monitor
- os: macos-latest
build-platform: darwin/universal
build-name: crypto-monitor
- os: windows-latest
build-platform: windows/amd64
installer-name: crypto-monitor-installer.exe
executable-name: crypto-monitor-windows-amd64.exe

steps:
- name: Checkout repository
uses: actions/checkout@v3

- name: Set up Go
- name: Setup GoLang
uses: actions/setup-go@v4
with:
go-version: "1.21"

- name: Set up Node.js
- name: Setup NodeJS
uses: actions/setup-node@v3
with:
node-version: "18"

- name: Install dependencies
- name: Install Linux Wails deps
if: runner.os == 'Linux'
run: sudo apt-get update && sudo apt-get install -y libgtk-3-0 libwebkit2gtk-4.0-dev gcc-aarch64-linux-gnu

- name: Install Wails
run: go install github.com/wailsapp/wails/v2/cmd/wails@latest

- name: Install Go Dependencies
run: go mod tidy

- name: Install frontend dependencies
run: |
cd frontend
npm install
- name: Build frontend
# https://wails.io/docs/reference/cli/#build
- name: Build Wails App (Non-Windows)
if: runner.os != 'Windows'
run: |
cd frontend
npm run build
wails build --platform ${{ matrix.build-platform }} -o ${{ matrix.build-name }}
working-directory: ./

- name: Install Wails
- name: Build Windows Installer
if: runner.os == 'Windows'
run: |
go install github.com/wailsapp/wails/v2/cmd/wails@latest
env:
GOPATH: ${{ github.workspace }}/go
wails build --platform ${{ matrix.build-platform }} -nsis -o ${{ matrix.installer-name }}
- name: Build Wails App
- name: Build Windows Executable
if: runner.os == 'Windows'
run: |
wails build -m release
env:
GOOS: ${{ matrix.os == 'windows-latest' && 'windows' || matrix.os == 'darwin-latest' && 'darwin' || 'linux' }}
GOARCH: "amd64"
wails build --platform ${{ matrix.build-platform }} -o ${{ matrix.executable-name }}
- name: Upload Build Artifact
- name: Package macOS .app
if: runner.os == 'macOS'
run: |
cd build/bin
zip -r "${{ matrix.build-name }}.zip" "${{ matrix.build-name }}.app"
- name: Upload Linux Build Artifact
if: runner.os == 'linux'
uses: actions/upload-artifact@v3
with:
name: crypto-monitor-${{ matrix.os }}
path: ./build/bin/${{ matrix.build-name }}

- name: Upload macOS Build Artifact
if: runner.os == 'macOS'
uses: actions/upload-artifact@v3
with:
name: crypto-monitor-${{ matrix.os }}
path: build/bin/crypto-monitor.${{ matrix.os == 'windows-latest' && 'exe' || matrix.os == 'darwin' && 'app' || 'linux' }}
path: ./build/bin/${{ matrix.build-name }}.zip

- name: Upload Windows Installer Artifact
if: runner.os == 'Windows'
uses: actions/upload-artifact@v3
with:
name: crypto-monitor-windows-installer
path: ./build/bin/${{ matrix.installer-name }}

- name: Upload Windows Executable Artifact
if: runner.os == 'Windows'
uses: actions/upload-artifact@v3
with:
name: crypto-monitor-windows-executable
path: ./build/bin/${{ matrix.executable-name }}

release:
needs: build
runs-on: ubuntu-latest
needs: build
if: startsWith(github.ref, 'refs/tags/') || github.event_name == 'workflow_dispatch'

steps:
- name: Download artifacts
- name: Download Non-Windows Ubuntu Artifact
uses: actions/download-artifact@v3
with:
name: crypto-monitor-ubuntu-latest
path: ./build
path: ./artifacts/ubuntu-latest

- name: Download macOS artifact
- name: Download Non-Windows macOS Artifact
uses: actions/download-artifact@v3
with:
name: crypto-monitor-macos-latest
path: ./build/macos
path: ./artifacts/macos-latest

- name: Download Windows artifact
- name: Download Windows Installer Artifact
uses: actions/download-artifact@v3
with:
name: crypto-monitor-windows-latest
path: ./build/windows
name: crypto-monitor-windows-installer
path: ./artifacts/windows-installer

- name: Create GitHub Release
- name: Download Windows Executable Artifact
uses: actions/download-artifact@v3
with:
name: crypto-monitor-windows-executable
path: ./artifacts/windows-executable

- name: Get Version
id: get_version
run: |
if [ "${{ github.event_name }}" == "workflow_dispatch" ]; then
echo "ref_name=${{ github.event.inputs.tag }}" >> $GITHUB_ENV
else
ref_name=${GITHUB_REF/refs\/tags\//} # This strips the refs/tags/ prefix
echo "ref_name=${ref_name}" >> $GITHUB_ENV
fi
- name: Create Release
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ github.ref }}
release_name: Release ${{ github.ref }}
tag_name: ${{ github.ref_name }}
release_name: Release ${{ github.ref_name }}
draft: false
prerelease: false

- name: Upload Windows Release Asset
- name: Upload Windows Installer Asset
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./artifacts/windows-installer/crypto-monitor-installer.exe
asset_name: crypto-monitor-${{ github.ref_name }}-windows-amd64-installer.exe
asset_content_type: application/vnd.microsoft.portable-executable

- name: Upload Windows Executable Asset
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./build/windows/crypto-monitor.exe
asset_name: crypto-monitor-windows.exe
asset_content_type: application/vnd.microsoft.package
asset_path: ./artifacts/windows-executable/crypto-monitor-windows-amd64.exe
asset_name: crypto-monitor-${{ github.ref_name }}-windows-amd64.exe
asset_content_type: application/vnd.microsoft.portable-executable

- name: Upload macOS Release Asset
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./build/macos/crypto-monitor.app
asset_name: crypto-monitor-macos.app
asset_content_type: application/x-apple-app
asset_path: ./artifacts/macos-latest/crypto-monitor.zip
asset_name: crypto-monitor-${{ github.ref_name }}-macos-universal.zip
asset_content_type: application/zip

- name: Upload Linux Release Asset
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./build/ubuntu-latest/crypto-monitor
asset_name: crypto-monitor-linux
asset_content_type: application/octet-stream
asset_path: ./artifacts/ubuntu-latest/crypto-monitor
asset_name: crypto-monitor-${{ github.ref_name }}-linux-amd64
asset_content_type: application/x-elf

0 comments on commit cc33199

Please sign in to comment.