fix(ci): build will have artifact conflicts

This commit is contained in:
Neko Ayaka
2025-07-19 02:23:56 +08:00
parent c242179e9d
commit 3e665b25a7
2 changed files with 33 additions and 23 deletions
+17 -3
View File
@@ -17,6 +17,11 @@ on:
required: false
default: false
type: boolean
artifacts_only:
description: Upload artifacts without uploading to GitHub Releases
required: false
default: false
type: boolean
tag:
description: Attach to a specific tag/commit for the release (leave empty to auto-detect latest tag)
required: false
@@ -167,7 +172,7 @@ jobs:
run: pnpm run -F @proj-airi/stage-tamagotchi rename-artifacts ${{ matrix.target }}
- name: Rename Artifacts (Manual)
if: ${{ github.event_name == 'workflow_dispatch' && !github.event.inputs.build_only }}
if: ${{ github.event_name == 'workflow_dispatch' }}
run: pnpm run -F @proj-airi/stage-tamagotchi rename-artifacts ${{ matrix.target }} --release --tag ${{ github.event.inputs.tag }} --auto-tag
- name: Rename Artifacts (Automatic)
@@ -180,9 +185,18 @@ jobs:
with:
name: Artifacts
path: bundle/${{ env.PRODUCT_NAME }}_*
overwrite: true
- name: Upload To GitHub Releases (Manual)
if: ${{ github.event_name == 'workflow_dispatch' && !github.event.inputs.build_only }}
- name: Upload Artifacts (Manual + Non-Release)
if: ${{ github.event_name == 'workflow_dispatch' && !github.event.inputs.build_only && github.event.inputs.artifacts_only }}
uses: actions/upload-artifact@v4
with:
name: Artifacts
path: bundle/${{ env.PRODUCT_NAME }}_*
overwrite: true
- name: Upload To GitHub Releases (Manual + Release)
if: ${{ github.event_name == 'workflow_dispatch' && !github.event.inputs.build_only && !github.event.inputs.artifacts_only }}
uses: softprops/action-gh-release@v2
with:
files: bundle/${{ env.PRODUCT_NAME }}_*
@@ -92,38 +92,34 @@ console.log(readdirSync(srcPrefix))
mkdirSync(bundlePrefix, { recursive: true })
let renameFrom = ''
let renameTo = ''
switch (target) {
case 'x86_64-pc-windows-msvc':
renameSync(
join(srcPrefix, 'nsis', `${beforeProductName}_${beforeVersion}_x64-setup.exe`),
join(bundlePrefix, `${productName}_${version}_windows_amd64-setup.exe`),
)
renameFrom = join(srcPrefix, 'nsis', `${beforeProductName}_${beforeVersion}_x64-setup.exe`)
renameTo = join(bundlePrefix, `${productName}_${version}_windows_amd64-setup.exe`)
break
case 'x86_64-unknown-linux-gnu':
renameSync(
join(srcPrefix, 'appimage', `${beforeProductName}_${beforeVersion}_amd64.AppImage`),
join(bundlePrefix, `${productName}_${version}_linux_amd64.AppImage`),
)
renameFrom = join(srcPrefix, 'appimage', `${beforeProductName}_${beforeVersion}_amd64.AppImage`)
renameTo = join(bundlePrefix, `${productName}_${version}_linux_amd64.AppImage`)
break
case 'aarch64-unknown-linux-gnu':
renameSync(
join(srcPrefix, 'appimage', `${beforeProductName}_${beforeVersion}_aarch64.AppImage`),
join(bundlePrefix, `${productName}_${version}_linux_arm64.AppImage`),
)
renameFrom = join(srcPrefix, 'appimage', `${beforeProductName}_${beforeVersion}_aarch64.AppImage`)
renameTo = join(bundlePrefix, `${productName}_${version}_linux_arm64.AppImage`)
break
case 'aarch64-apple-darwin':
renameSync(
join(srcPrefix, 'dmg', `${beforeProductName}_${beforeVersion}_aarch64.dmg`),
join(bundlePrefix, `${productName}_${version}_macos_arm64.dmg`),
)
renameFrom = join(srcPrefix, 'dmg', `${beforeProductName}_${beforeVersion}_aarch64.dmg`)
renameTo = join(bundlePrefix, `${productName}_${version}_macos_arm64.dmg`)
break
case 'x86_64-apple-darwin':
renameSync(
join(srcPrefix, 'dmg', `${beforeProductName}_${beforeVersion}_x64.dmg`),
join(bundlePrefix, `${productName}_${version}_macos_amd64.dmg`),
)
renameFrom = join(srcPrefix, 'dmg', `${beforeProductName}_${beforeVersion}_x64.dmg`)
renameTo = join(bundlePrefix, `${productName}_${version}_macos_amd64.dmg`)
break
default:
console.error('Target is not supported')
process.exit(1)
}
console.log('renaming, from:', renameFrom, 'to:', renameTo)
renameSync(renameFrom, renameTo)