Some checks failed
CI / verify (push) Has been cancelled
CI / print-rust (push) Has been cancelled
Desktop Release / Windows x64 NSIS (push) Has been cancelled
Desktop Release / Linux x64 DEB (push) Has been cancelled
Desktop Release / Publish tagged desktop release (push) Has been cancelled
203 lines
6.2 KiB
YAML
203 lines
6.2 KiB
YAML
name: Desktop Release
|
|
|
|
on:
|
|
push:
|
|
branches: [main]
|
|
tags:
|
|
- "fieldlens-print-v*"
|
|
paths:
|
|
- "apps/print/**"
|
|
- ".gitea/workflows/desktop-release.yml"
|
|
pull_request:
|
|
paths:
|
|
- "apps/print/**"
|
|
- ".gitea/workflows/desktop-release.yml"
|
|
workflow_dispatch:
|
|
|
|
permissions:
|
|
code: read
|
|
releases: read
|
|
|
|
jobs:
|
|
windows-nsis:
|
|
name: Windows x64 NSIS
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
|
|
- uses: actions/setup-node@v4
|
|
with:
|
|
node-version: 24
|
|
|
|
- uses: dtolnay/rust-toolchain@stable
|
|
with:
|
|
targets: x86_64-pc-windows-msvc
|
|
|
|
- name: Install Windows cross-build tools
|
|
run: |
|
|
sudo apt-get update
|
|
sudo apt-get install -y nsis lld llvm clang
|
|
cargo install --locked cargo-xwin
|
|
|
|
- name: Install Node dependencies
|
|
run: npm install
|
|
|
|
- name: Build Windows NSIS installer
|
|
run: npm run bundle:windows --workspace @fieldlens/print
|
|
env:
|
|
XWIN_CACHE_DIR: ${{ runner.temp }}/xwin-cache
|
|
|
|
- name: Stage Windows installer
|
|
shell: bash
|
|
run: |
|
|
set -euo pipefail
|
|
source_file="$(find apps/print/src-tauri/target/x86_64-pc-windows-msvc/release/bundle/nsis -maxdepth 1 -type f -name '*-setup.exe' -print -quit)"
|
|
test -n "$source_file"
|
|
mkdir -p dist/desktop
|
|
cp "$source_file" dist/desktop/fieldlens-print-windows-x64-setup.exe
|
|
|
|
- name: Upload Windows installer
|
|
uses: actions/upload-artifact@v3
|
|
with:
|
|
name: fieldlens-print-windows-x64
|
|
path: dist/desktop/fieldlens-print-windows-x64-setup.exe
|
|
if-no-files-found: error
|
|
retention-days: 14
|
|
|
|
linux-deb:
|
|
name: Linux x64 DEB
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
|
|
- uses: actions/setup-node@v4
|
|
with:
|
|
node-version: 24
|
|
|
|
- uses: dtolnay/rust-toolchain@stable
|
|
|
|
- name: Install Tauri Linux prerequisites
|
|
run: |
|
|
sudo apt-get update
|
|
sudo apt-get install -y \
|
|
build-essential \
|
|
curl \
|
|
wget \
|
|
file \
|
|
libwebkit2gtk-4.1-dev \
|
|
libxdo-dev \
|
|
libssl-dev \
|
|
libayatana-appindicator3-dev \
|
|
librsvg2-dev \
|
|
patchelf
|
|
|
|
- name: Install Node dependencies
|
|
run: npm install
|
|
|
|
- name: Build Debian package
|
|
run: npm run bundle:deb --workspace @fieldlens/print
|
|
|
|
- name: Stage Debian package
|
|
shell: bash
|
|
run: |
|
|
set -euo pipefail
|
|
source_file="$(find apps/print/src-tauri/target/release/bundle/deb -maxdepth 1 -type f -name '*.deb' -print -quit)"
|
|
test -n "$source_file"
|
|
mkdir -p dist/desktop
|
|
cp "$source_file" dist/desktop/fieldlens-print-linux-x64.deb
|
|
|
|
- name: Upload Debian package
|
|
uses: actions/upload-artifact@v3
|
|
with:
|
|
name: fieldlens-print-linux-x64-deb
|
|
path: dist/desktop/fieldlens-print-linux-x64.deb
|
|
if-no-files-found: error
|
|
retention-days: 14
|
|
|
|
publish-release:
|
|
name: Publish tagged desktop release
|
|
if: gitea.ref == 'refs/heads/main' || startsWith(gitea.ref, 'refs/tags/fieldlens-print-v')
|
|
needs: [windows-nsis, linux-deb]
|
|
runs-on: ubuntu-latest
|
|
permissions:
|
|
code: read
|
|
releases: write
|
|
steps:
|
|
- name: Download Windows installer
|
|
uses: actions/download-artifact@v3
|
|
with:
|
|
name: fieldlens-print-windows-x64
|
|
path: release-assets
|
|
|
|
- name: Download Debian package
|
|
uses: actions/download-artifact@v3
|
|
with:
|
|
name: fieldlens-print-linux-x64-deb
|
|
path: release-assets
|
|
|
|
- name: Publish Gitea release assets
|
|
shell: bash
|
|
env:
|
|
GITEA_TOKEN: ${{ secrets.GITEA_TOKEN }}
|
|
GITEA_SERVER_URL: ${{ gitea.server_url }}
|
|
GITEA_REPOSITORY: ${{ gitea.repository }}
|
|
GITEA_REF: ${{ gitea.ref }}
|
|
GITEA_REF_NAME: ${{ gitea.ref_name }}
|
|
GITEA_SHA: ${{ gitea.sha }}
|
|
run: |
|
|
set -euo pipefail
|
|
|
|
api="${GITEA_SERVER_URL%/}/api/v1/repos/${GITEA_REPOSITORY}"
|
|
auth_header="Authorization: token ${GITEA_TOKEN}"
|
|
release_tag="$GITEA_REF_NAME"
|
|
if [ "$GITEA_REF" = "refs/heads/main" ]; then
|
|
release_tag="fieldlens-print-v0.1.0"
|
|
fi
|
|
|
|
status="$(curl -sS -o /tmp/release.json -w '%{http_code}' \
|
|
-H "$auth_header" \
|
|
"$api/releases/tags/$release_tag")"
|
|
|
|
if [ "$status" = "404" ]; then
|
|
jq -n \
|
|
--arg tag "$release_tag" \
|
|
--arg sha "$GITEA_SHA" \
|
|
'{
|
|
tag_name: $tag,
|
|
target_commitish: $sha,
|
|
name: ("FieldLens Print " + ($tag | sub("^fieldlens-print-"; ""))),
|
|
body: "FieldLens Print desktop installers.",
|
|
draft: false,
|
|
prerelease: false
|
|
}' > /tmp/create-release.json
|
|
|
|
curl -fsS \
|
|
-X POST \
|
|
-H "$auth_header" \
|
|
-H "Content-Type: application/json" \
|
|
--data-binary @/tmp/create-release.json \
|
|
"$api/releases" > /tmp/release.json
|
|
elif [ "$status" != "200" ]; then
|
|
cat /tmp/release.json
|
|
exit 1
|
|
fi
|
|
|
|
release_id="$(jq -r '.id' /tmp/release.json)"
|
|
test "$release_id" != "null"
|
|
|
|
curl -fsS -H "$auth_header" "$api/releases/$release_id/assets" > /tmp/assets.json
|
|
|
|
for file in release-assets/fieldlens-print-windows-x64-setup.exe release-assets/fieldlens-print-linux-x64.deb; do
|
|
name="$(basename "$file")"
|
|
existing_id="$(jq -r --arg name "$name" '.[] | select(.name == $name) | .id' /tmp/assets.json | head -n 1)"
|
|
if [ -n "$existing_id" ] && [ "$existing_id" != "null" ]; then
|
|
curl -fsS -X DELETE -H "$auth_header" "$api/releases/$release_id/assets/$existing_id"
|
|
fi
|
|
|
|
curl -fsS \
|
|
-X POST \
|
|
-H "$auth_header" \
|
|
-F "attachment=@$file" \
|
|
"$api/releases/$release_id/assets?name=$name"
|
|
done
|