diff --git a/.github/workflows/desktop-release.yml b/.github/workflows/desktop-release.yml index de98b42..c83c292 100644 --- a/.github/workflows/desktop-release.yml +++ b/.github/workflows/desktop-release.yml @@ -19,16 +19,26 @@ concurrency: cancel-in-progress: false jobs: - build-and-release: - name: Build and publish Windows desktop - runs-on: windows-latest + build: + name: Build ${{ matrix.platform }} desktop + strategy: + fail-fast: false + matrix: + include: + - platform: windows + runner: windows-latest + artifact: desktop-windows + - platform: linux + runner: ubuntu-latest + artifact: desktop-linux + runs-on: ${{ matrix.runner }} timeout-minutes: 45 - steps: - name: Check out source uses: actions/checkout@v4 with: fetch-depth: 0 + ref: ${{ github.sha }} - name: Set up Node.js uses: actions/setup-node@v4 @@ -38,44 +48,30 @@ jobs: - name: Resolve release version id: version - shell: pwsh - run: | - if ("${{ github.event_name }}" -eq "workflow_dispatch") { - $version = "${{ inputs.version }}".Trim().TrimStart("v") - $tag = "v$version" - } else { - $tag = "${{ github.ref_name }}" - $version = $tag.TrimStart("v") - } - - if ($version -notmatch '^\d+\.\d+\.\d+(?:-[0-9A-Za-z.-]+)?$') { - throw "Invalid release version: $version" - } - - "version=$version" >> $env:GITHUB_OUTPUT - "tag=$tag" >> $env:GITHUB_OUTPUT - Write-Host "Building SketchForge $version ($tag)" - - - name: Ensure release tag exists - if: github.event_name == 'workflow_dispatch' - shell: pwsh + shell: bash env: - GH_TOKEN: ${{ github.token }} - TAG: ${{ steps.version.outputs.tag }} + INPUT_VERSION: ${{ inputs.version }} + TAG_NAME: ${{ github.ref_name }} + EVENT_NAME: ${{ github.event_name }} run: | - git fetch --tags --force - if (git rev-parse $env:TAG 2>$null) { - Write-Host "$env:TAG already exists." - } else { - git tag $env:TAG $env:GITHUB_SHA - git push origin $env:TAG - } + if [ "$EVENT_NAME" = "workflow_dispatch" ]; then + version="${INPUT_VERSION#v}" + else + version="${TAG_NAME#v}" + fi - - name: Set package version from release tag - shell: pwsh + if [[ ! "$version" =~ ^[0-9]+\.[0-9]+\.[0-9]+(-[0-9A-Za-z.-]+)?$ ]]; then + echo "Invalid release version: $version" >&2 + exit 1 + fi + + echo "version=$version" >> "$GITHUB_OUTPUT" + + - name: Set package version + shell: bash env: VERSION: ${{ steps.version.outputs.version }} - run: npm version $env:VERSION --no-git-tag-version --allow-same-version + run: npm version "$VERSION" --no-git-tag-version --allow-same-version - name: Install dependencies run: npm ci @@ -86,113 +82,166 @@ jobs: - name: Run tests run: npm test - - name: Build Windows desktop update + - name: Build desktop package run: npm run desktop:dist - - name: Verify updater artifacts + - name: Verify Windows artifacts + if: matrix.platform == 'windows' shell: pwsh env: VERSION: ${{ steps.version.outputs.version }} run: | - $installer = "dist/desktop/SketchForge-Setup-$env:VERSION-x64.exe" - $blockmap = "$installer.blockmap" - $latest = "dist/desktop/latest.yml" - - foreach ($file in @($installer, $blockmap, $latest)) { + $required = @( + "dist/desktop/SketchForge-Setup-$env:VERSION-x64.exe", + "dist/desktop/SketchForge-Setup-$env:VERSION-x64.exe.blockmap", + "dist/desktop/latest.yml" + ) + foreach ($file in $required) { if (-not (Test-Path $file -PathType Leaf)) { - throw "Missing updater artifact: $file" + throw "Missing Windows artifact: $file" } } - $metadata = Get-Content $latest -Raw - if ($metadata -notmatch "version:\s*$([regex]::Escape($env:VERSION))") { - throw "latest.yml does not contain version $env:VERSION" - } + - name: Verify Linux artifacts + if: matrix.platform == 'linux' + shell: bash + env: + VERSION: ${{ steps.version.outputs.version }} + run: | + test -f "dist/desktop/SketchForge-$VERSION-x86_64.AppImage" + test -f dist/desktop/latest-linux.yml - $hash = (Get-FileHash $installer -Algorithm SHA256).Hash.ToLowerInvariant() - Write-Host "Installer SHA-256: $hash" - Write-Host "Installer size: $((Get-Item $installer).Length) bytes" + - name: Store Windows artifacts + if: matrix.platform == 'windows' + uses: actions/upload-artifact@v4 + with: + name: ${{ matrix.artifact }} + path: | + dist/desktop/SketchForge-Setup-*-x64.exe + dist/desktop/SketchForge-Setup-*-x64.exe.blockmap + dist/desktop/latest.yml + if-no-files-found: error + + - name: Store Linux artifacts + if: matrix.platform == 'linux' + uses: actions/upload-artifact@v4 + with: + name: ${{ matrix.artifact }} + path: | + dist/desktop/SketchForge-*.AppImage + dist/desktop/latest-linux.yml + if-no-files-found: error + + attach: + name: Attach packages to release + needs: build + runs-on: ubuntu-latest + steps: + - name: Check out source + uses: actions/checkout@v4 + with: + fetch-depth: 0 + ref: ${{ github.sha }} + + - name: Resolve release metadata + id: version + shell: bash + env: + INPUT_VERSION: ${{ inputs.version }} + TAG_NAME: ${{ github.ref_name }} + EVENT_NAME: ${{ github.event_name }} + run: | + if [ "$EVENT_NAME" = "workflow_dispatch" ]; then + version="${INPUT_VERSION#v}" + tag="v$version" + else + tag="$TAG_NAME" + version="${tag#v}" + fi + + if [[ ! "$version" =~ ^[0-9]+\.[0-9]+\.[0-9]+(-[0-9A-Za-z.-]+)?$ ]]; then + echo "Invalid release version: $version" >&2 + exit 1 + fi + + echo "version=$version" >> "$GITHUB_OUTPUT" + echo "tag=$tag" >> "$GITHUB_OUTPUT" + + - name: Ensure release tag exists + if: github.event_name == 'workflow_dispatch' + env: + TAG: ${{ steps.version.outputs.tag }} + SOURCE_SHA: ${{ github.sha }} + run: | + git fetch --tags --force + if git rev-parse "$TAG" >/dev/null 2>&1; then + echo "$TAG already exists." + else + git tag "$TAG" "$SOURCE_SHA" + git push origin "$TAG" + fi + + - name: Download Windows artifacts + uses: actions/download-artifact@v4 + with: + name: desktop-windows + path: dist/release + + - name: Download Linux artifacts + uses: actions/download-artifact@v4 + with: + name: desktop-linux + path: dist/release - name: Create draft release - shell: pwsh env: GH_TOKEN: ${{ github.token }} TAG: ${{ steps.version.outputs.tag }} VERSION: ${{ steps.version.outputs.version }} run: | - $existing = gh release view $env:TAG --json isDraft 2>$null - if ($LASTEXITCODE -eq 0) { - $release = $existing | ConvertFrom-Json - if (-not $release.isDraft) { - throw "Release $env:TAG is already published. Refusing to replace a live updater release." + existing=$(gh release view "$TAG" --json isDraft 2>/dev/null || true) + if [ -n "$existing" ]; then + is_draft=$(jq -r '.isDraft' <<< "$existing") + if [ "$is_draft" != "true" ]; then + echo "Release $TAG is already published. Refusing to replace it." >&2 + exit 1 + fi + echo "Using existing draft release $TAG." + else + gh release create "$TAG" --draft --verify-tag \ + --title "SketchForge $VERSION" \ + --notes "SketchForge desktop $VERSION" + fi + + - name: Upload desktop packages + env: + GH_TOKEN: ${{ github.token }} + TAG: ${{ steps.version.outputs.tag }} + run: gh release upload "$TAG" dist/release/* --clobber + + - name: Verify release assets + env: + GH_TOKEN: ${{ github.token }} + TAG: ${{ steps.version.outputs.tag }} + VERSION: ${{ steps.version.outputs.version }} + run: | + assets=$(gh release view "$TAG" --json isDraft,assets) + test "$(jq -r '.isDraft' <<< "$assets")" = "true" + names=$(jq -r '.assets[].name' <<< "$assets") + for expected in \ + "SketchForge-Setup-$VERSION-x64.exe" \ + "SketchForge-Setup-$VERSION-x64.exe.blockmap" \ + "latest.yml" \ + "SketchForge-$VERSION-x86_64.AppImage" \ + "latest-linux.yml"; do + grep -Fxq "$expected" <<< "$names" || { + echo "GitHub release is missing $expected" >&2 + exit 1 } - Write-Host "Using existing draft release $env:TAG." - } else { - gh release create $env:TAG --draft --verify-tag --title "SketchForge $env:VERSION" --notes "SketchForge desktop $env:VERSION" - } + done - - name: Upload updater assets to draft - shell: pwsh + - name: Publish release as latest env: GH_TOKEN: ${{ github.token }} TAG: ${{ steps.version.outputs.tag }} - VERSION: ${{ steps.version.outputs.version }} - run: | - $installer = "dist/desktop/SketchForge-Setup-$env:VERSION-x64.exe" - gh release upload $env:TAG ` - $installer ` - "$installer.blockmap" ` - "dist/desktop/latest.yml" ` - --clobber - - - name: Verify GitHub release assets - shell: pwsh - env: - GH_TOKEN: ${{ github.token }} - TAG: ${{ steps.version.outputs.tag }} - VERSION: ${{ steps.version.outputs.version }} - run: | - $release = gh release view $env:TAG --json isDraft,assets | ConvertFrom-Json - if (-not $release.isDraft) { - throw "Release became public before verification." - } - - $expected = @( - "SketchForge-Setup-$env:VERSION-x64.exe", - "SketchForge-Setup-$env:VERSION-x64.exe.blockmap", - "latest.yml" - ) - $actual = @($release.assets | ForEach-Object { $_.name }) - - foreach ($name in $expected) { - if ($actual -notcontains $name) { - throw "GitHub release is missing $name" - } - } - - if ($release.assets.Count -lt 3) { - throw "Expected at least 3 release assets." - } - - - name: Publish release as Latest - shell: pwsh - env: - GH_TOKEN: ${{ github.token }} - TAG: ${{ steps.version.outputs.tag }} - run: gh release edit $env:TAG --draft=false --latest - - - name: Final release check - shell: pwsh - env: - GH_TOKEN: ${{ github.token }} - TAG: ${{ steps.version.outputs.tag }} - run: | - $release = gh release view $env:TAG --json tagName,isDraft,publishedAt,assets | ConvertFrom-Json - if ($release.isDraft) { - throw "Release $env:TAG is still a draft." - } - $latestTag = gh api "repos/$env:GITHUB_REPOSITORY/releases/latest" --jq '.tag_name' - if ($latestTag -ne $env:TAG) { - throw "Latest release is $latestTag instead of $env:TAG" - } - Write-Host "$env:TAG is published as Latest with $($release.assets.Count) assets." + run: gh release edit "$TAG" --draft=false --latest diff --git a/apps/desktop/electron-builder.yml b/apps/desktop/electron-builder.yml index 44f5e01..c15996e 100644 --- a/apps/desktop/electron-builder.yml +++ b/apps/desktop/electron-builder.yml @@ -46,6 +46,7 @@ mac: artifactName: ${productName}-${version}-${arch}.${ext} linux: + syncDesktopName: true icon: apps/web/public/assets/sketchforge/sketchforge-logo.png target: - AppImage diff --git a/package.json b/package.json index e66a10b..2ce010f 100644 --- a/package.json +++ b/package.json @@ -2,6 +2,12 @@ "name": "sketchforge", "version": "1.0.3", "private": true, + "description": "A local-first 3D design editor.", + "author": { + "name": "SketchForge contributors" + }, + "homepage": "https://sketchforge3d.com", + "desktopName": "sketchforge", "main": "apps/desktop/main.cjs", "license": "AGPL-3.0-only", "scripts": {