chore(ci): improve rename and bundle name of flatpak

This commit is contained in:
Neko Ayaka
2025-10-31 17:55:50 +08:00
parent b1bda8a604
commit 3a13c654d3
3 changed files with 70 additions and 4 deletions
+5 -3
View File
@@ -147,12 +147,12 @@ jobs:
if: ${{ matrix.os == 'ubuntu-latest' || matrix.os == 'ubuntu-24.04-arm' }}
working-directory: ./apps/stage-tamagotchi
run: |
mkdir -p bundle
mkdir -p dist
# Auto-install required SDK/Platform/BaseApp from Flathub in user scope
flatpak-builder --user --install-deps-from=flathub ./flatpak ai.moeru.airi.flatpak.yml --force-clean
flatpak build-export ./flatpak-repo ./flatpak
flatpak build-bundle ./flatpak-repo bundle/ai.moeru.airi-${{ matrix.arch }}.flatpak ai.moeru.airi
echo "FLATPAK_BUNDLE_NAME=ai.moeru.airi-${{ matrix.arch }}.flatpak" >> $GITHUB_ENV
export FLATPAK_OUTPUT_NAME=$(pnpm exec tsx scripts/artifacts-metadata.ts ${{ matrix.target }} --get-output-filename flatpak)
flatpak build-bundle ./flatpak-repo dist/${FLATPAK_OUTPUT_NAME} ai.moeru.airi
# ---------
# Nightly (schedule) builds only
@@ -188,6 +188,7 @@ jobs:
run: |
echo "DEB_BUNDLE_NAME=$(pnpm exec tsx scripts/artifacts-metadata.ts ${{ matrix.target }} --get-filename deb)" >> $GITHUB_ENV
echo "RPM_BUNDLE_NAME=$(pnpm exec tsx scripts/artifacts-metadata.ts ${{ matrix.target }} --get-filename rpm)" >> $GITHUB_ENV
echo "FLATPAK_BUNDLE_NAME=$(pnpm exec tsx scripts/artifacts-metadata.ts ${{ matrix.target }} --get-filename flatpak)" >> $GITHUB_ENV
- name: Upload Artifacts (Nightly + Non-Linux)
if: ${{ github.event_name == 'schedule' && (matrix.os != 'ubuntu-latest' && matrix.os != 'ubuntu-24.04-arm') }}
@@ -251,6 +252,7 @@ jobs:
run: |
echo "DEB_BUNDLE_NAME=$(pnpm exec tsx scripts/artifacts-metadata.ts ${{ matrix.target }} --get-filename deb --release ${{ !inputs.build_only && !inputs.artifacts_only }} --tag ${{ inputs.tag }} --auto-tag ${{ !inputs.build_only }})" >> $GITHUB_ENV
echo "RPM_BUNDLE_NAME=$(pnpm exec tsx scripts/artifacts-metadata.ts ${{ matrix.target }} --get-filename rpm --release ${{ !inputs.build_only && !inputs.artifacts_only }} --tag ${{ inputs.tag }} --auto-tag ${{ !inputs.build_only }})" >> $GITHUB_ENV
echo "FLATPAK_BUNDLE_NAME=$(pnpm exec tsx scripts/artifacts-metadata.ts ${{ matrix.target }} --get-filename flatpak --release ${{ !inputs.build_only && !inputs.artifacts_only }} --tag ${{ inputs.tag }} --auto-tag ${{ !inputs.build_only }})" >> $GITHUB_ENV
- name: Upload Artifacts (Manual + Non-Release + Non-Linux)
if: ${{ github.event_name == 'workflow_dispatch' && !inputs.build_only && inputs.artifacts_only && (matrix.os != 'ubuntu-latest' && matrix.os != 'ubuntu-24.04-arm') }}
@@ -16,6 +16,11 @@ async function main() {
'Get the release artifact filename for a specific extension (e.g., deb, rpm, dmg, exe)',
{ default: '', type: [String] },
)
.option(
'--get-output-filename <ext>',
'Get the build output filename for a specific extension (pre-rename)',
{ default: '', type: [String] },
)
.option(
'--auto-tag',
'Automatically tag the release with the latest git ref',
@@ -52,6 +57,7 @@ async function main() {
getProductName: boolean
getVersion: boolean
getFilename: string[]
getOutputFilename: string[]
}
const target = args.args[0]
@@ -69,6 +75,16 @@ async function main() {
}
console.info(match.releaseArtifactFilename)
}
if (argOptions.getOutputFilename && argOptions.getOutputFilename[0]) {
const ext = String(argOptions.getOutputFilename[0]).trim()
const filenames = await getFilenames(target, argOptions)
const match = filenames.find(f => f.extension === ext)
if (!match) {
console.error(`No artifact found for extension: ${ext}`)
process.exit(1)
}
console.info(match.outputFilename)
}
if (argOptions.getProductName) {
const electronBuilderConfig = await getElectronBuilderConfig()
console.info(electronBuilderConfig.productName)
+49 -1
View File
@@ -84,7 +84,7 @@ interface FilenameOutputEntry {
version: string
}
function mapArchFor(
export function mapArchFor(
target: string,
ext: string,
): string {
@@ -213,6 +213,30 @@ export async function getFilenames(target: string, options: { release: boolean,
},
)
}
// Flatpak artifact (built outside electron-builder, but we follow linux template)
artifacts.push(
{
target: 'x86_64-unknown-linux-gnu',
extension: 'flatpak',
outputFilename: applyTemplateOfArtifactName(
electronBuilder.linux.artifactName!,
productName,
beforeVersion,
mapArchFor(target, 'flatpak'),
'flatpak',
),
releaseArtifactFilename: applyTemplateOfArtifactName(
electronBuilder.linux.artifactName!,
productName,
version,
mapArchFor(target, 'flatpak'),
'flatpak',
),
productName,
version,
},
)
}
return artifacts
@@ -276,6 +300,30 @@ export async function getFilenames(target: string, options: { release: boolean,
},
)
}
// Flatpak artifact (built outside electron-builder, but we follow linux template)
artifacts.push(
{
target: 'aarch64-unknown-linux-gnu',
extension: 'flatpak',
outputFilename: applyTemplateOfArtifactName(
electronBuilder.linux.artifactName!,
productName,
beforeVersion,
mapArchFor(target, 'flatpak'),
'flatpak',
),
releaseArtifactFilename: applyTemplateOfArtifactName(
electronBuilder.linux.artifactName!,
productName,
version,
mapArchFor(target, 'flatpak'),
'flatpak',
),
productName,
version,
},
)
}
return artifacts