feat(ci): support to run release-tamagotchi.yml workflow for deb and rpm files
This commit is contained in:
@@ -4,8 +4,9 @@ permissions:
|
|||||||
contents: write
|
contents: write
|
||||||
|
|
||||||
env:
|
env:
|
||||||
PRODUCT_NAME: 'AIRI'
|
|
||||||
BUNDLE_NAME: ''
|
BUNDLE_NAME: ''
|
||||||
|
PRODUCT_NAME: 'AIRI'
|
||||||
|
VERSION: ''
|
||||||
|
|
||||||
on:
|
on:
|
||||||
release:
|
release:
|
||||||
@@ -40,32 +41,32 @@ jobs:
|
|||||||
- os: macos-13
|
- os: macos-13
|
||||||
artifact: darwin-x64
|
artifact: darwin-x64
|
||||||
target: x86_64-apple-darwin
|
target: x86_64-apple-darwin
|
||||||
|
arch: x64
|
||||||
builder-args: --macos --x64
|
builder-args: --macos --x64
|
||||||
ext: dmg
|
|
||||||
|
|
||||||
- os: macos-latest
|
- os: macos-latest
|
||||||
artifact: darwin-arm64
|
artifact: darwin-arm64
|
||||||
target: aarch64-apple-darwin
|
target: aarch64-apple-darwin
|
||||||
builder-args: --macos --arm64
|
builder-args: --macos --arm64
|
||||||
ext: dmg
|
arch: arm64
|
||||||
|
|
||||||
- os: ubuntu-latest
|
- os: ubuntu-latest
|
||||||
artifact: linux-x64
|
artifact: linux-x64
|
||||||
target: x86_64-unknown-linux-gnu
|
target: x86_64-unknown-linux-gnu
|
||||||
builder-args: --linux --x64
|
builder-args: --linux --x64
|
||||||
ext: AppImage
|
arch: x64
|
||||||
|
|
||||||
- os: ubuntu-24.04-arm
|
- os: ubuntu-24.04-arm
|
||||||
artifact: linux-arm64
|
artifact: linux-arm64
|
||||||
target: aarch64-unknown-linux-gnu
|
target: aarch64-unknown-linux-gnu
|
||||||
builder-args: --linux --arm64
|
builder-args: --linux --arm64
|
||||||
ext: AppImage
|
arch: arm64
|
||||||
|
|
||||||
- os: windows-latest
|
- os: windows-latest
|
||||||
artifact: windows-x64-setup
|
artifact: windows-x64-setup
|
||||||
target: x86_64-pc-windows-msvc
|
target: x86_64-pc-windows-msvc
|
||||||
builder-args: --windows --x64
|
builder-args: --windows --x64
|
||||||
ext: exe
|
arch: x64
|
||||||
|
|
||||||
runs-on: ${{ matrix.os }}
|
runs-on: ${{ matrix.os }}
|
||||||
steps:
|
steps:
|
||||||
@@ -108,58 +109,95 @@ jobs:
|
|||||||
# ---------
|
# ---------
|
||||||
# Nightly (schedule) builds only
|
# Nightly (schedule) builds only
|
||||||
# ---------
|
# ---------
|
||||||
- name: Get Name of Artifacts (Nightly + Windows Only)
|
|
||||||
|
- name: Get Artifacts Envs (Nightly + Windows Only)
|
||||||
if: ${{ github.event_name == 'schedule' && matrix.os == 'windows-latest' }}
|
if: ${{ github.event_name == 'schedule' && matrix.os == 'windows-latest' }}
|
||||||
run: |
|
run: |
|
||||||
pnpm -F @proj-airi/stage-tamagotchi name-of-artifacts ${{ matrix.target }} --out bundle_name
|
echo "BUNDLE_NAME=$(pnpm -F @proj-airi/stage-tamagotchi artifacts-metadata ${{ matrix.target }} --get-bundle-name)" >> $env:GITHUB_ENV
|
||||||
echo "BUNDLE_NAME=$(node -p "require('node:fs').readFileSync(require('node:path').join('apps', 'stage-tamagotchi', 'bundle_name')).toString('utf-8')")" >> $env:GITHUB_ENV
|
echo "VERSION=$(pnpm -F @proj-airi/stage-tamagotchi artifacts-metadata ${{ matrix.target }} --get-version)" >> $env:GITHUB_ENV
|
||||||
|
|
||||||
- name: Get Name of Artifacts (Nightly)
|
- name: Get Artifacts Envs (Nightly + Non-Windows)
|
||||||
if: ${{ github.event_name == 'schedule' && matrix.os != 'windows-latest' }}
|
if: ${{ github.event_name == 'schedule' && matrix.os != 'windows-latest' }}
|
||||||
run: |
|
run: |
|
||||||
pnpm -F @proj-airi/stage-tamagotchi name-of-artifacts ${{ matrix.target }} --out bundle_name
|
echo "VERSION=$(pnpm -F @proj-airi/stage-tamagotchi artifacts-metadata ${{ matrix.target }} --get-version)" >> $GITHUB_ENV
|
||||||
echo "BUNDLE_NAME=$(node -p "require('node:fs').readFileSync(require('node:path').join('apps', 'stage-tamagotchi', 'bundle_name')).toString('utf-8')")" >> $GITHUB_ENV
|
|
||||||
|
- name: Get Artifacts Envs (Nightly + macOS Only)
|
||||||
|
if: ${{ github.event_name == 'schedule' && (matrix.os == 'macos-latest' || matrix.os == 'macos-13') }}
|
||||||
|
run: |
|
||||||
|
echo "BUNDLE_NAME=$(pnpm -F @proj-airi/stage-tamagotchi artifacts-metadata ${{ matrix.target }} --get-bundle-name)" >> $GITHUB_ENV
|
||||||
|
|
||||||
- name: Rename Artifacts (Nightly)
|
- name: Rename Artifacts (Nightly)
|
||||||
if: ${{ github.event_name == 'schedule' }}
|
if: ${{ github.event_name == 'schedule' }}
|
||||||
run:
|
run:
|
||||||
pnpm run -F @proj-airi/stage-tamagotchi rename-artifacts ${{ matrix.target }}
|
pnpm run -F @proj-airi/stage-tamagotchi rename-artifacts ${{ matrix.target }}
|
||||||
|
|
||||||
- name: Upload Artifacts (Nightly)
|
- name: Upload Artifacts (Nightly + Non-Linux)
|
||||||
if: ${{ github.event_name == 'schedule' }}
|
if: ${{ github.event_name == 'schedule' && (matrix.os != 'ubuntu-latest' && matrix.os != 'ubuntu-24.04-arm') }}
|
||||||
uses: actions/upload-artifact@v4
|
uses: actions/upload-artifact@v4
|
||||||
with:
|
with:
|
||||||
name: ${{ env.BUNDLE_NAME }}
|
name: ${{ env.BUNDLE_NAME }}
|
||||||
path: apps/stage-tamagotchi/bundle/${{ env.BUNDLE_NAME }}
|
path: apps/stage-tamagotchi/bundle/${{ env.BUNDLE_NAME }}
|
||||||
|
|
||||||
# ---------
|
- name: Upload Artifacts (Nightly + Linux deb)
|
||||||
# Workflow Dispatch only
|
if: ${{ github.event_name == 'schedule' && (matrix.os == 'ubuntu-latest' || matrix.os == 'ubuntu-24.04-arm') }}
|
||||||
# ---------
|
uses: actions/upload-artifact@v4
|
||||||
|
with:
|
||||||
|
name: ${{ env.PRODUCT_NAME }}-${{ env.VERSION }}-linux-${{ matrix.arch }}.deb
|
||||||
|
path: apps/stage-tamagotchi/bundle/${{ env.PRODUCT_NAME }}-${{ env.VERSION }}-linux-${{ matrix.arch }}.deb
|
||||||
|
|
||||||
- name: Get Name of Artifacts (Manual + Windows Only)
|
- name: Upload Artifacts (Nightly + Linux rpm)
|
||||||
|
if: ${{ github.event_name == 'schedule' && (matrix.os == 'ubuntu-latest' || matrix.os == 'ubuntu-24.04-arm') }}
|
||||||
|
uses: actions/upload-artifact@v4
|
||||||
|
with:
|
||||||
|
name: ${{ env.PRODUCT_NAME }}-${{ env.VERSION }}-linux-${{ matrix.arch }}.rpm
|
||||||
|
path: apps/stage-tamagotchi/bundle/${{ env.PRODUCT_NAME }}-${{ env.VERSION }}-linux-${{ matrix.arch }}.rpm
|
||||||
|
|
||||||
|
# ---------
|
||||||
|
# Workflow Dispatch only
|
||||||
|
# ---------
|
||||||
|
|
||||||
|
- name: Get Artifacts Envs (Manual + Windows Only)
|
||||||
if: ${{ github.event_name == 'workflow_dispatch' && matrix.os == 'windows-latest' }}
|
if: ${{ github.event_name == 'workflow_dispatch' && matrix.os == 'windows-latest' }}
|
||||||
run: |
|
run: |
|
||||||
pnpm -F @proj-airi/stage-tamagotchi name-of-artifacts ${{ matrix.target }} --out bundle_name --release ${{ !inputs.build_only && !inputs.artifacts_only }} --tag ${{ inputs.tag }} --auto-tag ${{ !inputs.build_only }}
|
echo "BUNDLE_NAME=$(pnpm -F @proj-airi/stage-tamagotchi artifacts-metadata ${{ matrix.target }} --get-bundle-name --release ${{ !inputs.build_only && !inputs.artifacts_only }} --tag ${{ inputs.tag }} --auto-tag ${{ !inputs.build_only }})" >> $env:GITHUB_ENV
|
||||||
echo "BUNDLE_NAME=$(node -p "require('node:fs').readFileSync(require('node:path').join('apps', 'stage-tamagotchi', 'bundle_name')).toString('utf-8')")" >> $env:GITHUB_ENV
|
echo "VERSION=$(pnpm -F @proj-airi/stage-tamagotchi artifacts-metadata ${{ matrix.target }} --get-version --release ${{ !inputs.build_only && !inputs.artifacts_only }} --tag ${{ inputs.tag }} --auto-tag ${{ !inputs.build_only }})" >> $env:GITHUB_ENV
|
||||||
|
|
||||||
- name: Get Name of Artifacts (Manual)
|
- name: Get Artifacts Envs (Manual + Non-Windows)
|
||||||
if: ${{ github.event_name == 'workflow_dispatch' && matrix.os != 'windows-latest' }}
|
if: ${{ github.event_name == 'workflow_dispatch' && matrix.os != 'windows-latest' }}
|
||||||
run: |
|
run: |
|
||||||
pnpm -F @proj-airi/stage-tamagotchi name-of-artifacts ${{ matrix.target }} --out bundle_name --release ${{ !inputs.build_only && !inputs.artifacts_only }} --tag ${{ inputs.tag }} --auto-tag ${{ !inputs.build_only }}
|
echo "VERSION=$(pnpm -F @proj-airi/stage-tamagotchi artifacts-metadata ${{ matrix.target }} --get-version --release ${{ !inputs.build_only && !inputs.artifacts_only }} --tag ${{ inputs.tag }} --auto-tag ${{ !inputs.build_only }})" >> $GITHUB_ENV
|
||||||
echo "BUNDLE_NAME=$(node -p "require('node:fs').readFileSync(require('node:path').join('apps', 'stage-tamagotchi', 'bundle_name')).toString('utf-8')")" >> $GITHUB_ENV
|
|
||||||
|
- name: Get Artifacts Envs (Manual + macOS Only)
|
||||||
|
if: ${{ github.event_name == 'workflow_dispatch' && (matrix.os == 'macos-latest' || matrix.os == 'macos-13') }}
|
||||||
|
run: |
|
||||||
|
echo "BUNDLE_NAME=$(pnpm -F @proj-airi/stage-tamagotchi artifacts-metadata ${{ matrix.target }} --get-bundle-name --release ${{ !inputs.build_only && !inputs.artifacts_only }} --tag ${{ inputs.tag }} --auto-tag ${{ !inputs.build_only }})" >> $GITHUB_ENV
|
||||||
|
|
||||||
- name: Rename Artifacts (Manual)
|
- name: Rename Artifacts (Manual)
|
||||||
if: ${{ github.event_name == 'workflow_dispatch' }}
|
if: ${{ github.event_name == 'workflow_dispatch' }}
|
||||||
run: |
|
run: |
|
||||||
pnpm run -F @proj-airi/stage-tamagotchi rename-artifacts ${{ matrix.target }} --release ${{ !inputs.build_only && !inputs.artifacts_only }} --tag ${{ inputs.tag }} --auto-tag ${{ !inputs.build_only }}
|
pnpm run -F @proj-airi/stage-tamagotchi rename-artifacts ${{ matrix.target }} --release ${{ !inputs.build_only && !inputs.artifacts_only }} --tag ${{ inputs.tag }} --auto-tag ${{ !inputs.build_only }}
|
||||||
|
|
||||||
- name: Upload Artifacts (Manual + Non-Release)
|
- name: Upload Artifacts (Manual + Non-Release + Non-Linux)
|
||||||
if: ${{ github.event_name == 'workflow_dispatch' && !inputs.build_only && inputs.artifacts_only }}
|
if: ${{ github.event_name == 'workflow_dispatch' && !inputs.build_only && inputs.artifacts_only && (matrix.os != 'ubuntu-latest' && matrix.os != 'ubuntu-24.04-arm') }}
|
||||||
uses: actions/upload-artifact@v4
|
uses: actions/upload-artifact@v4
|
||||||
with:
|
with:
|
||||||
name: ${{ env.BUNDLE_NAME }}
|
name: ${{ env.BUNDLE_NAME }}
|
||||||
path: apps/stage-tamagotchi/bundle/${{ env.BUNDLE_NAME }}
|
path: apps/stage-tamagotchi/bundle/${{ env.BUNDLE_NAME }}
|
||||||
|
|
||||||
|
- name: Upload Artifacts (Manual + Non-Release + Linux deb)
|
||||||
|
if: ${{ github.event_name == 'workflow_dispatch' && !inputs.build_only && inputs.artifacts_only && (matrix.os == 'ubuntu-latest' || matrix.os == 'ubuntu-24.04-arm') }}
|
||||||
|
uses: actions/upload-artifact@v4
|
||||||
|
with:
|
||||||
|
name: ${{ env.PRODUCT_NAME }}-${{ env.VERSION }}-linux-${{ matrix.arch }}.deb
|
||||||
|
path: apps/stage-tamagotchi/bundle/${{ env.PRODUCT_NAME }}-${{ env.VERSION }}-linux-${{ matrix.arch }}.deb
|
||||||
|
|
||||||
|
- name: Upload Artifacts (Manual + Non-Release + Linux rpm)
|
||||||
|
if: ${{ github.event_name == 'workflow_dispatch' && !inputs.build_only && inputs.artifacts_only && (matrix.os == 'ubuntu-latest' || matrix.os == 'ubuntu-24.04-arm') }}
|
||||||
|
uses: actions/upload-artifact@v4
|
||||||
|
with:
|
||||||
|
name: ${{ env.PRODUCT_NAME }}-${{ env.VERSION }}-linux-${{ matrix.arch }}.rpm
|
||||||
|
path: apps/stage-tamagotchi/bundle/${{ env.PRODUCT_NAME }}-${{ env.VERSION }}-linux-${{ matrix.arch }}.rpm
|
||||||
|
|
||||||
- name: Upload To GitHub Releases (Manual + Overwrite Release)
|
- name: Upload To GitHub Releases (Manual + Overwrite Release)
|
||||||
if: ${{ github.event_name == 'workflow_dispatch' && !inputs.build_only && !inputs.artifacts_only }}
|
if: ${{ github.event_name == 'workflow_dispatch' && !inputs.build_only && !inputs.artifacts_only }}
|
||||||
uses: softprops/action-gh-release@v2
|
uses: softprops/action-gh-release@v2
|
||||||
|
|||||||
@@ -23,7 +23,7 @@
|
|||||||
"build:mac": "pnpm run build && electron-builder --mac",
|
"build:mac": "pnpm run build && electron-builder --mac",
|
||||||
"build:linux": "pnpm run build && electron-builder --linux",
|
"build:linux": "pnpm run build && electron-builder --linux",
|
||||||
"rename-artifacts": "mkdir -p bundle && tsx scripts/rename-artifacts.ts",
|
"rename-artifacts": "mkdir -p bundle && tsx scripts/rename-artifacts.ts",
|
||||||
"name-of-artifacts": "tsx scripts/name-of-artifacts.ts"
|
"artifacts-metadata": "tsx scripts/artifacts-metadata.ts"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@date-fns/utc": "^2.1.1",
|
"@date-fns/utc": "^2.1.1",
|
||||||
|
|||||||
@@ -0,0 +1,70 @@
|
|||||||
|
import process from 'node:process'
|
||||||
|
|
||||||
|
import { cac } from 'cac'
|
||||||
|
|
||||||
|
import { getElectronBuilderConfig, getFilenames, getVersion } from './utils'
|
||||||
|
|
||||||
|
async function main() {
|
||||||
|
const cli = cac('name-of-artifact')
|
||||||
|
.option(
|
||||||
|
'--release',
|
||||||
|
'Rename with version from package.json',
|
||||||
|
{ default: false },
|
||||||
|
)
|
||||||
|
.option(
|
||||||
|
'--auto-tag',
|
||||||
|
'Automatically tag the release with the latest git ref',
|
||||||
|
{ default: false },
|
||||||
|
)
|
||||||
|
.option(
|
||||||
|
'--tag <tag>',
|
||||||
|
'Tag to use for the release',
|
||||||
|
{ default: '', type: [String] },
|
||||||
|
)
|
||||||
|
.option(
|
||||||
|
'--get-bundle-name',
|
||||||
|
'Get the bundle name',
|
||||||
|
{ default: false },
|
||||||
|
)
|
||||||
|
.option(
|
||||||
|
'--get-product-name',
|
||||||
|
'Get the product name',
|
||||||
|
{ default: false },
|
||||||
|
)
|
||||||
|
.option(
|
||||||
|
'--get-version',
|
||||||
|
'Get the version',
|
||||||
|
{ default: false },
|
||||||
|
)
|
||||||
|
|
||||||
|
const args = cli.parse()
|
||||||
|
|
||||||
|
const argOptions = args.options as {
|
||||||
|
release: boolean
|
||||||
|
autoTag: boolean
|
||||||
|
tag: string[]
|
||||||
|
getBundleName: boolean
|
||||||
|
getProductName: boolean
|
||||||
|
getVersion: boolean
|
||||||
|
}
|
||||||
|
|
||||||
|
const target = args.args[0]
|
||||||
|
if (argOptions.getBundleName) {
|
||||||
|
const filenames = await getFilenames(target, argOptions)
|
||||||
|
console.info(filenames[0].releaseArtifactFilename)
|
||||||
|
}
|
||||||
|
if (argOptions.getProductName) {
|
||||||
|
const electronBuilderConfig = await getElectronBuilderConfig()
|
||||||
|
console.info(electronBuilderConfig.productName)
|
||||||
|
}
|
||||||
|
if (argOptions.getVersion) {
|
||||||
|
const version = await getVersion({ release: argOptions.release, autoTag: argOptions.autoTag, tag: argOptions.tag })
|
||||||
|
console.info(version)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
main()
|
||||||
|
.catch((error) => {
|
||||||
|
console.error('Error during generating name:', error)
|
||||||
|
process.exit(1)
|
||||||
|
})
|
||||||
@@ -1,60 +0,0 @@
|
|||||||
import process from 'node:process'
|
|
||||||
|
|
||||||
import { existsSync, mkdirSync, writeFileSync } from 'node:fs'
|
|
||||||
import { dirname } from 'node:path'
|
|
||||||
|
|
||||||
import { cac } from 'cac'
|
|
||||||
|
|
||||||
import { getFilename } from './utils'
|
|
||||||
|
|
||||||
async function main() {
|
|
||||||
const cli = cac('name-of-artifact')
|
|
||||||
.option(
|
|
||||||
'--release',
|
|
||||||
'Rename with version from package.json',
|
|
||||||
{ default: false },
|
|
||||||
)
|
|
||||||
.option(
|
|
||||||
'--auto-tag',
|
|
||||||
'Automatically tag the release with the latest git ref',
|
|
||||||
{ default: false },
|
|
||||||
)
|
|
||||||
.option(
|
|
||||||
'--tag <tag>',
|
|
||||||
'Tag to use for the release',
|
|
||||||
{ default: '', type: [String] },
|
|
||||||
)
|
|
||||||
.option(
|
|
||||||
'--out <path>',
|
|
||||||
'Path to output the filename',
|
|
||||||
{ default: 'bundle_name', type: [String] },
|
|
||||||
)
|
|
||||||
|
|
||||||
const args = cli.parse()
|
|
||||||
|
|
||||||
const argOptions = args.options as {
|
|
||||||
release: boolean
|
|
||||||
autoTag: boolean
|
|
||||||
tag: string[]
|
|
||||||
out: string[]
|
|
||||||
}
|
|
||||||
|
|
||||||
const target = args.args[0]
|
|
||||||
const filename = await getFilename(target, argOptions)
|
|
||||||
if (argOptions.out[0]) {
|
|
||||||
if (!existsSync(dirname(argOptions.out[0]))) {
|
|
||||||
mkdirSync(dirname(argOptions.out[0]), { recursive: true })
|
|
||||||
}
|
|
||||||
|
|
||||||
writeFileSync(argOptions.out[0], filename, { encoding: 'utf-8' })
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
console.info(filename)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
main()
|
|
||||||
.catch((error) => {
|
|
||||||
console.error('Error during generating name:', error)
|
|
||||||
process.exit(1)
|
|
||||||
})
|
|
||||||
@@ -7,7 +7,7 @@ import { cac } from 'cac'
|
|||||||
|
|
||||||
import packageJSON from '../package.json' assert { type: 'json' }
|
import packageJSON from '../package.json' assert { type: 'json' }
|
||||||
|
|
||||||
import { getElectronBuilderConfig, getFilename, getVersion } from './utils'
|
import { getElectronBuilderConfig, getFilenames, getVersion } from './utils'
|
||||||
|
|
||||||
async function main() {
|
async function main() {
|
||||||
const cli = cac('rename-artifact')
|
const cli = cac('rename-artifact')
|
||||||
@@ -66,39 +66,15 @@ async function main() {
|
|||||||
|
|
||||||
mkdirSync(bundlePrefix, { recursive: true })
|
mkdirSync(bundlePrefix, { recursive: true })
|
||||||
|
|
||||||
let renameFrom = ''
|
const filenames = await getFilenames(target, argOptions)
|
||||||
let renameTo = ''
|
console.info(filenames, 'is the target filename')
|
||||||
const filename = await getFilename(target, argOptions)
|
|
||||||
console.info(filename, 'is the target filename')
|
|
||||||
|
|
||||||
switch (target) {
|
for (const filename of filenames) {
|
||||||
case 'x86_64-pc-windows-msvc':
|
const renameFrom = join(srcPrefix, filename.outputFilename)
|
||||||
renameFrom = join(srcPrefix, `${beforeProductName}-${beforeVersion}-windows-x64-setup.exe`)
|
const renameTo = join(bundlePrefix, filename.releaseArtifactFilename)
|
||||||
renameTo = join(bundlePrefix, filename)
|
console.info('renaming, from:', renameFrom, 'to:', renameTo)
|
||||||
break
|
renameSync(renameFrom, renameTo)
|
||||||
case 'x86_64-unknown-linux-gnu':
|
|
||||||
renameFrom = join(srcPrefix, `${beforeProductName}-${beforeVersion}-linux-x86_64.AppImage`)
|
|
||||||
renameTo = join(bundlePrefix, filename)
|
|
||||||
break
|
|
||||||
case 'aarch64-unknown-linux-gnu':
|
|
||||||
renameFrom = join(srcPrefix, `${beforeProductName}-${beforeVersion}-linux-arm64.AppImage`)
|
|
||||||
renameTo = join(bundlePrefix, filename)
|
|
||||||
break
|
|
||||||
case 'aarch64-apple-darwin':
|
|
||||||
renameFrom = join(srcPrefix, `${beforeProductName}-${beforeVersion}-darwin-arm64.dmg`)
|
|
||||||
renameTo = join(bundlePrefix, filename)
|
|
||||||
break
|
|
||||||
case 'x86_64-apple-darwin':
|
|
||||||
renameFrom = join(srcPrefix, `${beforeProductName}-${beforeVersion}-darwin-x64.dmg`)
|
|
||||||
renameTo = join(bundlePrefix, filename)
|
|
||||||
break
|
|
||||||
default:
|
|
||||||
console.error('Target is not supported')
|
|
||||||
process.exit(1)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
console.info('renaming, from:', renameFrom, 'to:', renameTo)
|
|
||||||
renameSync(renameFrom, renameTo)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
main()
|
main()
|
||||||
|
|||||||
@@ -57,7 +57,34 @@ export async function getElectronBuilderConfig() {
|
|||||||
return yaml.parse(await readFile(resolve(import.meta.dirname, '..', 'electron-builder.yml'), 'utf-8')) as Configuration
|
return yaml.parse(await readFile(resolve(import.meta.dirname, '..', 'electron-builder.yml'), 'utf-8')) as Configuration
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function getFilename(target: string, options: { release: boolean, autoTag: boolean, tag: string[] }) {
|
export function applyTemplateOfArtifactName(
|
||||||
|
template: string,
|
||||||
|
productName: string,
|
||||||
|
version: string,
|
||||||
|
arch: string,
|
||||||
|
ext: string,
|
||||||
|
): string {
|
||||||
|
return template
|
||||||
|
// eslint-disable-next-line no-template-curly-in-string
|
||||||
|
.replace('${productName}', productName)
|
||||||
|
// eslint-disable-next-line no-template-curly-in-string
|
||||||
|
.replace('${version}', version)
|
||||||
|
// eslint-disable-next-line no-template-curly-in-string
|
||||||
|
.replace('${arch}', arch)
|
||||||
|
// eslint-disable-next-line no-template-curly-in-string
|
||||||
|
.replace('${ext}', ext)
|
||||||
|
}
|
||||||
|
|
||||||
|
interface FilenameOutputEntry {
|
||||||
|
target: string
|
||||||
|
extension: string
|
||||||
|
outputFilename: string
|
||||||
|
releaseArtifactFilename: string
|
||||||
|
productName: string
|
||||||
|
version: string
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function getFilenames(target: string, options: { release: boolean, autoTag: boolean, tag: string[] }): Promise<FilenameOutputEntry[]> {
|
||||||
const electronBuilder = await getElectronBuilderConfig()
|
const electronBuilder = await getElectronBuilderConfig()
|
||||||
const version = await getVersion(options)
|
const version = await getVersion(options)
|
||||||
|
|
||||||
@@ -65,62 +92,122 @@ export async function getFilename(target: string, options: { release: boolean, a
|
|||||||
throw new Error('<Target> is required')
|
throw new Error('<Target> is required')
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const beforeVersion = version
|
||||||
|
const productName = electronBuilder.productName!
|
||||||
|
|
||||||
switch (target) {
|
switch (target) {
|
||||||
case 'x86_64-pc-windows-msvc':
|
case 'x86_64-pc-windows-msvc':
|
||||||
|
|
||||||
return electronBuilder.nsis?.artifactName
|
return [
|
||||||
// eslint-disable-next-line no-template-curly-in-string
|
{
|
||||||
?.replace('${productName}', electronBuilder.productName!)
|
target: 'x86_64-pc-windows-msvc',
|
||||||
// eslint-disable-next-line no-template-curly-in-string
|
extension: 'exe',
|
||||||
.replace('${version}', version)
|
outputFilename: applyTemplateOfArtifactName(electronBuilder.nsis?.artifactName!, productName, beforeVersion, 'x64', 'exe'),
|
||||||
// eslint-disable-next-line no-template-curly-in-string
|
releaseArtifactFilename: applyTemplateOfArtifactName(electronBuilder.nsis?.artifactName!, productName, version, 'x64', 'exe'),
|
||||||
.replace('${arch}', 'x64')
|
productName,
|
||||||
// eslint-disable-next-line no-template-curly-in-string
|
version,
|
||||||
.replace('${ext}', 'exe') ?? `${electronBuilder.productName}-${version}-windows-x64-setup.exe`
|
},
|
||||||
break
|
]
|
||||||
case 'x86_64-unknown-linux-gnu':
|
case 'x86_64-unknown-linux-gnu':
|
||||||
return electronBuilder.linux?.artifactName
|
{
|
||||||
// eslint-disable-next-line no-template-curly-in-string
|
const artifacts: FilenameOutputEntry[] = []
|
||||||
?.replace('${productName}', electronBuilder.productName!)
|
if (electronBuilder.linux?.artifactName) {
|
||||||
// eslint-disable-next-line no-template-curly-in-string
|
if (
|
||||||
.replace('${version}', version)
|
(Array.isArray(electronBuilder.linux.target) && electronBuilder.linux.target.includes('deb'))
|
||||||
// eslint-disable-next-line no-template-curly-in-string
|
|| electronBuilder.linux.target === 'deb'
|
||||||
.replace('${arch}', 'x64')
|
) {
|
||||||
// eslint-disable-next-line no-template-curly-in-string
|
artifacts.push(
|
||||||
.replace('${ext}', 'AppImage') ?? `${electronBuilder.productName}-${version}-linux-x64.AppImage`
|
{
|
||||||
break
|
target: 'x86_64-unknown-linux-gnu',
|
||||||
|
extension: 'deb',
|
||||||
|
outputFilename: applyTemplateOfArtifactName(electronBuilder.linux.artifactName!, productName, beforeVersion, 'x64', 'deb'),
|
||||||
|
releaseArtifactFilename: applyTemplateOfArtifactName(electronBuilder.linux.artifactName!, productName, version, 'x64', 'deb'),
|
||||||
|
productName,
|
||||||
|
version,
|
||||||
|
},
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
if (
|
||||||
|
(Array.isArray(electronBuilder.linux.target) && electronBuilder.linux.target.includes('rpm'))
|
||||||
|
|| electronBuilder.linux.target === 'rpm'
|
||||||
|
) {
|
||||||
|
artifacts.push(
|
||||||
|
{
|
||||||
|
target: 'x86_64-unknown-linux-gnu',
|
||||||
|
extension: 'rpm',
|
||||||
|
outputFilename: applyTemplateOfArtifactName(electronBuilder.linux.artifactName!, productName, beforeVersion, 'x64', 'rpm'),
|
||||||
|
releaseArtifactFilename: applyTemplateOfArtifactName(electronBuilder.linux.artifactName!, productName, version, 'x64', 'rpm'),
|
||||||
|
productName,
|
||||||
|
version,
|
||||||
|
},
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return artifacts
|
||||||
|
}
|
||||||
case 'aarch64-unknown-linux-gnu':
|
case 'aarch64-unknown-linux-gnu':
|
||||||
return electronBuilder.linux?.artifactName
|
{
|
||||||
// eslint-disable-next-line no-template-curly-in-string
|
const artifacts: FilenameOutputEntry[] = []
|
||||||
?.replace('${productName}', electronBuilder.productName!)
|
if (electronBuilder.linux?.artifactName) {
|
||||||
// eslint-disable-next-line no-template-curly-in-string
|
if (
|
||||||
.replace('${version}', version)
|
(Array.isArray(electronBuilder.linux.target) && electronBuilder.linux.target.includes('deb'))
|
||||||
// eslint-disable-next-line no-template-curly-in-string
|
|| electronBuilder.linux.target === 'deb'
|
||||||
.replace('${arch}', 'arm64')
|
) {
|
||||||
// eslint-disable-next-line no-template-curly-in-string
|
artifacts.push(
|
||||||
.replace('${ext}', 'AppImage') ?? `${electronBuilder.productName}-${version}-linux-arm64.AppImage`
|
{
|
||||||
break
|
target: 'aarch64-unknown-linux-gnu',
|
||||||
|
extension: 'deb',
|
||||||
|
outputFilename: applyTemplateOfArtifactName(electronBuilder.linux.artifactName!, productName, beforeVersion, 'arm64', 'deb'),
|
||||||
|
releaseArtifactFilename: applyTemplateOfArtifactName(electronBuilder.linux.artifactName!, productName, version, 'arm64', 'deb'),
|
||||||
|
productName,
|
||||||
|
version,
|
||||||
|
},
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
if (
|
||||||
|
(Array.isArray(electronBuilder.linux.target) && electronBuilder.linux.target.includes('rpm'))
|
||||||
|
|| electronBuilder.linux.target === 'rpm'
|
||||||
|
) {
|
||||||
|
artifacts.push(
|
||||||
|
{
|
||||||
|
target: 'aarch64-unknown-linux-gnu',
|
||||||
|
extension: 'rpm',
|
||||||
|
outputFilename: applyTemplateOfArtifactName(electronBuilder.linux.artifactName!, productName, beforeVersion, 'arm64', 'rpm'),
|
||||||
|
releaseArtifactFilename: applyTemplateOfArtifactName(electronBuilder.linux.artifactName!, productName, version, 'arm64', 'rpm'),
|
||||||
|
productName,
|
||||||
|
version,
|
||||||
|
},
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return artifacts
|
||||||
|
}
|
||||||
case 'aarch64-apple-darwin':
|
case 'aarch64-apple-darwin':
|
||||||
return electronBuilder.dmg?.artifactName
|
return [
|
||||||
// eslint-disable-next-line no-template-curly-in-string
|
{
|
||||||
?.replace('${productName}', electronBuilder.productName!)
|
target: 'aarch64-apple-darwin',
|
||||||
// eslint-disable-next-line no-template-curly-in-string
|
extension: 'dmg',
|
||||||
.replace('${version}', version)
|
outputFilename: applyTemplateOfArtifactName(electronBuilder.dmg?.artifactName!, productName, beforeVersion, 'arm64', 'dmg'),
|
||||||
// eslint-disable-next-line no-template-curly-in-string
|
releaseArtifactFilename: applyTemplateOfArtifactName(electronBuilder.dmg?.artifactName!, productName, version, 'arm64', 'dmg'),
|
||||||
.replace('${arch}', 'arm64')
|
productName,
|
||||||
// eslint-disable-next-line no-template-curly-in-string
|
version,
|
||||||
.replace('${ext}', 'dmg') ?? `${electronBuilder.productName}-${version}-darwin-arm64.dmg`
|
},
|
||||||
break
|
]
|
||||||
case 'x86_64-apple-darwin':
|
case 'x86_64-apple-darwin':
|
||||||
return electronBuilder.dmg?.artifactName
|
return [
|
||||||
// eslint-disable-next-line no-template-curly-in-string
|
{
|
||||||
?.replace('${productName}', electronBuilder.productName!)
|
target: 'x86_64-apple-darwin',
|
||||||
// eslint-disable-next-line no-template-curly-in-string
|
extension: 'dmg',
|
||||||
.replace('${version}', version)
|
outputFilename: applyTemplateOfArtifactName(electronBuilder.dmg?.artifactName!, productName, beforeVersion, 'x64', 'dmg'),
|
||||||
// eslint-disable-next-line no-template-curly-in-string
|
releaseArtifactFilename: applyTemplateOfArtifactName(electronBuilder.dmg?.artifactName!, productName, version, 'x64', 'dmg'),
|
||||||
.replace('${arch}', 'x64')
|
productName,
|
||||||
// eslint-disable-next-line no-template-curly-in-string
|
version,
|
||||||
.replace('${ext}', 'dmg') ?? `${electronBuilder.productName}-${version}-darwin-x64.dmg`
|
},
|
||||||
|
]
|
||||||
default:
|
default:
|
||||||
console.error('Target is not supported')
|
console.error('Target is not supported')
|
||||||
process.exit(1)
|
process.exit(1)
|
||||||
|
|||||||
@@ -178,6 +178,7 @@ words:
|
|||||||
- nomic
|
- nomic
|
||||||
- novita
|
- novita
|
||||||
- nprogress
|
- nprogress
|
||||||
|
- nsis
|
||||||
- nuxi
|
- nuxi
|
||||||
- nuxt
|
- nuxt
|
||||||
- nuxtjs
|
- nuxtjs
|
||||||
|
|||||||
Reference in New Issue
Block a user