fix: pass app_version to CI and ship Windows NSIS installer only
Add app_version to workflow_dispatch inputs and worker dispatch payload. Collect only setup.exe from bundle/nsis, prefer installer URLs in release lookup, and use git-tag-safe job IDs.
This commit is contained in:
23
.github/workflows/build-app.yml
vendored
23
.github/workflows/build-app.yml
vendored
@@ -19,6 +19,10 @@ on:
|
|||||||
description: Application bundle identifier
|
description: Application bundle identifier
|
||||||
required: true
|
required: true
|
||||||
type: string
|
type: string
|
||||||
|
app_version:
|
||||||
|
description: Application version string
|
||||||
|
required: true
|
||||||
|
type: string
|
||||||
|
|
||||||
permissions:
|
permissions:
|
||||||
contents: write
|
contents: write
|
||||||
@@ -67,14 +71,17 @@ jobs:
|
|||||||
shell: pwsh
|
shell: pwsh
|
||||||
run: |
|
run: |
|
||||||
New-Item -ItemType Directory -Force -Path artifacts/windows | Out-Null
|
New-Item -ItemType Directory -Force -Path artifacts/windows | Out-Null
|
||||||
$bundleRoot = "template/src-tauri/target/release/bundle"
|
$nsisDir = "template/src-tauri/target/release/bundle/nsis"
|
||||||
if (Test-Path $bundleRoot) {
|
if (-not (Test-Path $nsisDir)) {
|
||||||
Get-ChildItem -Path $bundleRoot -Recurse -Include *setup.exe,*.exe,*.msi -ErrorAction SilentlyContinue |
|
Write-Error "NSIS bundle directory not found: $nsisDir"
|
||||||
Copy-Item -Destination artifacts/windows -Force
|
exit 1
|
||||||
}
|
}
|
||||||
Get-ChildItem -Path "template/src-tauri/target/release" -Filter "*.exe" -ErrorAction SilentlyContinue |
|
$installers = Get-ChildItem -Path $nsisDir -Filter "*-setup.exe"
|
||||||
Where-Object { $_.Name -notmatch "wix|candle|light" } |
|
if (-not $installers) {
|
||||||
Copy-Item -Destination artifacts/windows -Force
|
Write-Error "No NSIS installer (*-setup.exe) found in $nsisDir"
|
||||||
|
exit 1
|
||||||
|
}
|
||||||
|
$installers | Copy-Item -Destination artifacts/windows -Force
|
||||||
Get-ChildItem artifacts/windows
|
Get-ChildItem artifacts/windows
|
||||||
|
|
||||||
- uses: actions/upload-artifact@v4
|
- uses: actions/upload-artifact@v4
|
||||||
@@ -212,7 +219,7 @@ jobs:
|
|||||||
body: |
|
body: |
|
||||||
Automated build for **${{ inputs.app_name }}** (English: `${{ inputs.app_name_en }}`, version: `${{ inputs.app_version }}`, ID: `${{ inputs.app_identifier }}`).
|
Automated build for **${{ inputs.app_name }}** (English: `${{ inputs.app_name_en }}`, version: `${{ inputs.app_version }}`, ID: `${{ inputs.app_identifier }}`).
|
||||||
|
|
||||||
- Windows desktop installer/portable binary
|
- Windows NSIS installer (*-setup.exe)
|
||||||
- Android APK (arm64-v8a, signed for sideload install)
|
- Android APK (arm64-v8a, signed for sideload install)
|
||||||
draft: false
|
draft: false
|
||||||
prerelease: true
|
prerelease: true
|
||||||
|
|||||||
@@ -1,4 +1,10 @@
|
|||||||
import { nanoid } from "nanoid";
|
import { customAlphabet } from "nanoid";
|
||||||
|
|
||||||
|
// GitHub published releases reject tag names ending with '-'.
|
||||||
|
const generateJobId = customAlphabet(
|
||||||
|
"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz",
|
||||||
|
10,
|
||||||
|
);
|
||||||
import type { Env } from "../env";
|
import type { Env } from "../env";
|
||||||
import {
|
import {
|
||||||
getBuild,
|
getBuild,
|
||||||
@@ -112,7 +118,7 @@ async function createBuild(request: Request, env: Env): Promise<Response> {
|
|||||||
|
|
||||||
const buffer = new Uint8Array(await file.arrayBuffer());
|
const buffer = new Uint8Array(await file.arrayBuffer());
|
||||||
const { normalizedBuffer } = validateZipBuffer(buffer, maxUploadBytes(env));
|
const { normalizedBuffer } = validateZipBuffer(buffer, maxUploadBytes(env));
|
||||||
const jobId = nanoid(10);
|
const jobId = generateJobId();
|
||||||
const slug = slugifyIdentifier(appNameEn) || jobId.toLowerCase();
|
const slug = slugifyIdentifier(appNameEn) || jobId.toLowerCase();
|
||||||
const appIdentifier = normalizeAppIdentifier(
|
const appIdentifier = normalizeAppIdentifier(
|
||||||
identifierInput || `com.web2app.${slug}`,
|
identifierInput || `com.web2app.${slug}`,
|
||||||
@@ -148,6 +154,7 @@ async function createBuild(request: Request, env: Env): Promise<Response> {
|
|||||||
appName: appNameZh,
|
appName: appNameZh,
|
||||||
appNameEn,
|
appNameEn,
|
||||||
appIdentifier,
|
appIdentifier,
|
||||||
|
appVersion,
|
||||||
});
|
});
|
||||||
|
|
||||||
await updateBuild(env, jobId, {
|
await updateBuild(env, jobId, {
|
||||||
|
|||||||
@@ -115,6 +115,7 @@ export async function triggerBuildWorkflow(
|
|||||||
appName: string;
|
appName: string;
|
||||||
appNameEn: string;
|
appNameEn: string;
|
||||||
appIdentifier: string;
|
appIdentifier: string;
|
||||||
|
appVersion: string;
|
||||||
},
|
},
|
||||||
): Promise<number> {
|
): Promise<number> {
|
||||||
const { owner, repo, branch } = getGitHubConfig(env);
|
const { owner, repo, branch } = getGitHubConfig(env);
|
||||||
@@ -133,6 +134,7 @@ export async function triggerBuildWorkflow(
|
|||||||
app_name: input.appName,
|
app_name: input.appName,
|
||||||
app_name_en: input.appNameEn,
|
app_name_en: input.appNameEn,
|
||||||
app_identifier: input.appIdentifier,
|
app_identifier: input.appIdentifier,
|
||||||
|
app_version: input.appVersion,
|
||||||
},
|
},
|
||||||
}),
|
}),
|
||||||
},
|
},
|
||||||
@@ -217,18 +219,19 @@ export async function getReleaseAssets(
|
|||||||
assets: Array<{ name: string; browser_download_url: string }>;
|
assets: Array<{ name: string; browser_download_url: string }>;
|
||||||
};
|
};
|
||||||
|
|
||||||
let windowsUrl: string | null = null;
|
let windowsInstallerUrl: string | null = null;
|
||||||
|
let windowsFallbackUrl: string | null = null;
|
||||||
let androidUrl: string | null = null;
|
let androidUrl: string | null = null;
|
||||||
|
|
||||||
for (const asset of release.assets) {
|
for (const asset of release.assets) {
|
||||||
const name = asset.name.toLowerCase();
|
const name = asset.name.toLowerCase();
|
||||||
if (
|
if (name.endsWith("-setup.exe") || name.endsWith(".msi")) {
|
||||||
!windowsUrl &&
|
windowsInstallerUrl = asset.browser_download_url;
|
||||||
(name.endsWith(".exe") ||
|
} else if (
|
||||||
name.endsWith(".msi") ||
|
!windowsFallbackUrl &&
|
||||||
name.includes("windows"))
|
name.endsWith(".exe")
|
||||||
) {
|
) {
|
||||||
windowsUrl = asset.browser_download_url;
|
windowsFallbackUrl = asset.browser_download_url;
|
||||||
}
|
}
|
||||||
if (
|
if (
|
||||||
!androidUrl &&
|
!androidUrl &&
|
||||||
@@ -238,7 +241,10 @@ export async function getReleaseAssets(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return { windowsUrl, androidUrl };
|
return {
|
||||||
|
windowsUrl: windowsInstallerUrl ?? windowsFallbackUrl,
|
||||||
|
androidUrl,
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
export function getActionsRunUrl(env: Env, runId: number | null): string | null {
|
export function getActionsRunUrl(env: Env, runId: number | null): string | null {
|
||||||
|
|||||||
Reference in New Issue
Block a user