Release Build #2
Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Release Build | |
on: | |
push: | |
tags: | |
- 'v*' | |
workflow_dispatch: | |
inputs: | |
tag_name: | |
description: 'Tag name for release' | |
required: false | |
default: 'v0.0.0-dev' | |
env: | |
RUST_BACKTRACE: 1 | |
jobs: | |
create-release: | |
permissions: | |
contents: write | |
runs-on: ubuntu-latest | |
outputs: | |
release_id: ${{ steps.create_release.outputs.result }} | |
steps: | |
- name: Create release | |
id: create_release | |
uses: actions/github-script@v6 | |
with: | |
script: | | |
const { data } = await github.rest.repos.createRelease({ | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
tag_name: context.eventName === 'push' ? context.ref.replace('refs/tags/', '') : '${{ github.event.inputs.tag_name }}', | |
name: `WASM Component Designer ${context.eventName === 'push' ? context.ref.replace('refs/tags/', '') : '${{ github.event.inputs.tag_name }}'}`, | |
body: 'Release binaries for WASM Component Designer desktop application.', | |
draft: true, | |
prerelease: false | |
}) | |
return data.id | |
build-tauri: | |
needs: create-release | |
permissions: | |
contents: write | |
strategy: | |
fail-fast: false | |
matrix: | |
include: | |
- platform: 'macos-latest' | |
args: '' | |
target: 'aarch64-apple-darwin' | |
name: 'macOS-ARM64' | |
rust_target: 'aarch64-apple-darwin' | |
- platform: 'macos-13' | |
args: '' | |
target: 'x86_64-apple-darwin' | |
name: 'macOS-x64' | |
rust_target: 'x86_64-apple-darwin' | |
- platform: 'ubuntu-22.04' | |
args: '' | |
target: 'x86_64-unknown-linux-gnu' | |
name: 'Linux-x64' | |
rust_target: 'x86_64-unknown-linux-gnu' | |
- platform: 'windows-latest' | |
args: '' | |
target: 'x86_64-pc-windows-msvc' | |
name: 'Windows-x64' | |
rust_target: 'x86_64-pc-windows-msvc' | |
runs-on: ${{ matrix.platform }} | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Setup Node | |
uses: actions/setup-node@v4 | |
with: | |
node-version: 20 | |
- name: Install Rust stable | |
uses: dtolnay/rust-toolchain@stable | |
with: | |
targets: ${{ matrix.rust_target }} | |
- name: Rust cache | |
uses: swatinem/rust-cache@v2 | |
with: | |
workspaces: './glsp-tauri/src-tauri -> target' | |
- name: Install dependencies (Ubuntu only) | |
if: matrix.platform == 'ubuntu-22.04' | |
run: | | |
sudo apt-get update | |
sudo apt-get install -y libgtk-3-dev libwebkit2gtk-4.0-dev libayatana-appindicator3-dev librsvg2-dev libsoup2.4-dev | |
- name: Install web client dependencies | |
run: | | |
cd glsp-web-client | |
npm ci | |
- name: Build web client | |
run: | | |
cd glsp-web-client | |
npx vite build | |
- name: Install Tauri dependencies | |
run: | | |
cd glsp-tauri | |
npm ci | |
- name: Build Tauri app | |
run: | | |
cd glsp-tauri | |
npx tauri build ${{ matrix.args }} | |
- name: Upload macOS artifacts | |
if: matrix.platform == 'macos-latest' && matrix.target == 'aarch64-apple-darwin' | |
continue-on-error: true | |
uses: actions/github-script@v6 | |
with: | |
script: | | |
const fs = require('fs'); | |
const path = require('path'); | |
// Upload DMG | |
const dmgPath = path.join('target', 'release', 'bundle', 'dmg'); | |
const dmgFiles = fs.readdirSync(dmgPath).filter(f => f.endsWith('.dmg')); | |
for (const file of dmgFiles) { | |
console.log(`Uploading ${file}...`); | |
const data = fs.readFileSync(path.join(dmgPath, file)); | |
await github.rest.repos.uploadReleaseAsset({ | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
release_id: '${{ needs.create-release.outputs.release_id }}', | |
name: file.replace('_aarch64', '-arm64'), | |
data: data | |
}); | |
} | |
- name: Upload macOS x64 artifacts | |
if: matrix.platform == 'macos-latest' && matrix.target == 'x86_64-apple-darwin' | |
continue-on-error: true | |
uses: actions/github-script@v6 | |
with: | |
script: | | |
const fs = require('fs'); | |
const path = require('path'); | |
// For cross-compilation, check both possible paths | |
let dmgPath = path.join('target', 'x86_64-apple-darwin', 'release', 'bundle', 'dmg'); | |
if (!fs.existsSync(dmgPath)) { | |
dmgPath = path.join('target', 'release', 'bundle', 'dmg'); | |
} | |
if (!fs.existsSync(dmgPath)) { | |
console.log('DMG directory not found at expected paths'); | |
return; | |
} | |
const dmgFiles = fs.readdirSync(dmgPath).filter(f => f.endsWith('.dmg')); | |
for (const file of dmgFiles) { | |
console.log(`Uploading ${file}...`); | |
const data = fs.readFileSync(path.join(dmgPath, file)); | |
await github.rest.repos.uploadReleaseAsset({ | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
release_id: '${{ needs.create-release.outputs.release_id }}', | |
name: file.replace('_x64', '-x64'), | |
data: data | |
}); | |
} | |
- name: Upload Linux artifacts | |
if: matrix.platform == 'ubuntu-22.04' | |
continue-on-error: true | |
uses: actions/github-script@v6 | |
with: | |
script: | | |
const fs = require('fs'); | |
const path = require('path'); | |
// Upload AppImage | |
const appImagePath = path.join('target', 'release', 'bundle', 'appimage'); | |
if (fs.existsSync(appImagePath)) { | |
const appImageFiles = fs.readdirSync(appImagePath).filter(f => f.endsWith('.AppImage')); | |
for (const file of appImageFiles) { | |
console.log(`Uploading ${file}...`); | |
const data = fs.readFileSync(path.join(appImagePath, file)); | |
await github.rest.repos.uploadReleaseAsset({ | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
release_id: '${{ needs.create-release.outputs.release_id }}', | |
name: file, | |
data: data | |
}); | |
} | |
} | |
// Upload deb | |
const debPath = path.join('target', 'release', 'bundle', 'deb'); | |
if (fs.existsSync(debPath)) { | |
const debFiles = fs.readdirSync(debPath).filter(f => f.endsWith('.deb')); | |
for (const file of debFiles) { | |
console.log(`Uploading ${file}...`); | |
const data = fs.readFileSync(path.join(debPath, file)); | |
await github.rest.repos.uploadReleaseAsset({ | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
release_id: '${{ needs.create-release.outputs.release_id }}', | |
name: file, | |
data: data | |
}); | |
} | |
} | |
- name: Upload Windows artifacts | |
if: matrix.platform == 'windows-latest' | |
continue-on-error: true | |
uses: actions/github-script@v6 | |
with: | |
script: | | |
const fs = require('fs'); | |
const path = require('path'); | |
// Upload MSI | |
const msiPath = path.join('target', 'release', 'bundle', 'msi'); | |
if (fs.existsSync(msiPath)) { | |
const msiFiles = fs.readdirSync(msiPath).filter(f => f.endsWith('.msi')); | |
for (const file of msiFiles) { | |
console.log(`Uploading ${file}...`); | |
const data = fs.readFileSync(path.join(msiPath, file)); | |
await github.rest.repos.uploadReleaseAsset({ | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
release_id: '${{ needs.create-release.outputs.release_id }}', | |
name: file, | |
data: data | |
}); | |
} | |
} | |
publish-release: | |
permissions: | |
contents: write | |
runs-on: ubuntu-latest | |
needs: [create-release, build-tauri] | |
if: always() && needs.create-release.result == 'success' | |
steps: | |
- name: Publish release | |
uses: actions/github-script@v6 | |
with: | |
script: | | |
await github.rest.repos.updateRelease({ | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
release_id: '${{ needs.create-release.outputs.release_id }}', | |
draft: false, | |
prerelease: false | |
}) |