130 lines
3.5 KiB
YAML
130 lines
3.5 KiB
YAML
name: Build Windows Release
|
|
|
|
on:
|
|
push:
|
|
branches:
|
|
- master
|
|
- main
|
|
tags:
|
|
- "*"
|
|
pull_request:
|
|
branches:
|
|
- master
|
|
- main
|
|
workflow_dispatch:
|
|
inputs:
|
|
publish_release:
|
|
description: "Publish the installers to a GitHub Release"
|
|
required: true
|
|
default: true
|
|
type: boolean
|
|
release_tag:
|
|
description: "Release tag to create or update when publishing manually, for example v0.1.0"
|
|
required: false
|
|
default: "v0.1.0"
|
|
type: string
|
|
|
|
permissions:
|
|
contents: write
|
|
|
|
concurrency:
|
|
group: build-windows-release-${{ github.ref }}
|
|
cancel-in-progress: true
|
|
|
|
jobs:
|
|
windows-installer:
|
|
name: Windows installer
|
|
runs-on: windows-latest
|
|
|
|
defaults:
|
|
run:
|
|
shell: pwsh
|
|
|
|
steps:
|
|
- name: Checkout
|
|
uses: actions/checkout@v4
|
|
|
|
- name: Set up pnpm
|
|
uses: pnpm/action-setup@v4
|
|
with:
|
|
version: 11.19.0
|
|
|
|
- name: Set up Node.js
|
|
uses: actions/setup-node@v4
|
|
with:
|
|
node-version: 22
|
|
cache: pnpm
|
|
|
|
- name: Set up Rust
|
|
uses: dtolnay/rust-toolchain@stable
|
|
|
|
- name: Cache Rust dependencies
|
|
uses: Swatinem/rust-cache@v2
|
|
with:
|
|
workspaces: |
|
|
.
|
|
src-tauri
|
|
|
|
- name: Install Windows bundler dependencies
|
|
run: |
|
|
choco install nsis wixtoolset -y --no-progress
|
|
if (Test-Path "C:\Program Files (x86)\NSIS") {
|
|
Add-Content $env:GITHUB_PATH "C:\Program Files (x86)\NSIS"
|
|
}
|
|
if (Test-Path "C:\Program Files (x86)\WiX Toolset v3.14\bin") {
|
|
Add-Content $env:GITHUB_PATH "C:\Program Files (x86)\WiX Toolset v3.14\bin"
|
|
}
|
|
if (Test-Path "C:\Program Files (x86)\WiX Toolset v3.11\bin") {
|
|
Add-Content $env:GITHUB_PATH "C:\Program Files (x86)\WiX Toolset v3.11\bin"
|
|
}
|
|
|
|
- name: Install frontend dependencies
|
|
run: pnpm install --frozen-lockfile
|
|
|
|
- name: Run Rust tests
|
|
run: cargo test
|
|
|
|
- name: Build Windows desktop installers
|
|
run: pnpm run desktop:build
|
|
|
|
- name: Resolve release publishing
|
|
id: release
|
|
env:
|
|
DISPATCH_PUBLISH_RELEASE: ${{ inputs.publish_release }}
|
|
DISPATCH_RELEASE_TAG: ${{ inputs.release_tag }}
|
|
run: |
|
|
$publish = "false"
|
|
$tag = ""
|
|
|
|
if ($env:GITHUB_REF -like "refs/tags/*") {
|
|
$publish = "true"
|
|
$tag = $env:GITHUB_REF_NAME
|
|
} elseif ($env:GITHUB_EVENT_NAME -eq "workflow_dispatch" -and $env:DISPATCH_PUBLISH_RELEASE -eq "true") {
|
|
$publish = "true"
|
|
$tag = $env:DISPATCH_RELEASE_TAG.Trim()
|
|
if ([string]::IsNullOrWhiteSpace($tag)) {
|
|
throw "release_tag is required when publish_release is true."
|
|
}
|
|
}
|
|
|
|
"publish=$publish" >> $env:GITHUB_OUTPUT
|
|
"tag=$tag" >> $env:GITHUB_OUTPUT
|
|
|
|
- name: Upload installer artifacts
|
|
uses: actions/upload-artifact@v4
|
|
with:
|
|
name: clipforge-windows-installers
|
|
if-no-files-found: error
|
|
path: |
|
|
src-tauri/target/release/bundle/msi/*.msi
|
|
src-tauri/target/release/bundle/nsis/*.exe
|
|
|
|
- name: Publish GitHub release assets
|
|
if: steps.release.outputs.publish == 'true'
|
|
uses: softprops/action-gh-release@v2
|
|
with:
|
|
tag_name: ${{ steps.release.outputs.tag }}
|
|
files: |
|
|
src-tauri/target/release/bundle/msi/*.msi
|
|
src-tauri/target/release/bundle/nsis/*.exe
|