Skip to content

Commit

Permalink
refactor: Update build pipeline to use new code sign
Browse files Browse the repository at this point in the history
  • Loading branch information
ci010 committed Feb 3, 2023
1 parent d85b7f5 commit d29175a
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 26 deletions.
12 changes: 1 addition & 11 deletions .github/workflows/build-arm64.yml
Original file line number Diff line number Diff line change
@@ -1,17 +1,7 @@
name: Build Arm64

on:
push:
branches:
- master
paths:
- 'xmcl-runtime/**'
- 'xmcl-runtime-api/**'
- 'xmcl-keystone-ui/**'
- 'xmcl-electron-app/**'
- 'package.json'
- 'pnpm-lock.yaml'
- '.github/**'
workflow_dispatch

jobs:
build-linux-arm64:
Expand Down
9 changes: 4 additions & 5 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ jobs:
BUILD_NUMBER: ${{ env.GITHUB_RUN_NUMBER }}
NODE_ENV: production
CURSEFORGE_API_KEY: ${{ secrets.CURSEFORGE_API_TOKEN }}
CSC_LINK: ${{ secrets.CODE_SIGN_BASE64 }}
CSC_KEY_PASSWORD: ${{ secrets.CODE_SIGN_PWD }}
- name: Upload Build
uses: actions/upload-artifact@v2
with:
Expand Down Expand Up @@ -105,6 +107,8 @@ jobs:
NODE_ENV: production
CURSEFORGE_API_KEY: ${{ secrets.CURSEFORGE_API_TOKEN }}
BUILD_TARGET: appx
CSC_LINK: ${{ secrets.CODE_SIGN_BASE64 }}
CSC_KEY_PASSWORD: ${{ secrets.CODE_SIGN_PWD }}
- name: Upload Build
uses: actions/upload-artifact@v2
with:
Expand Down Expand Up @@ -275,11 +279,6 @@ jobs:
prerelease: false
body: ${{ steps.prepare_release.outputs.changelog }}
asset_dir_path: ./build
- name: Echo sign command
run: |
echo "Please use following script to sign the app in the PC with credential!"
echo "pnpm --package=https://github.com/Voxelum/xmcl-release-script dlx xmcl-release-script ${{ steps.create_release.outputs.release_id }}"
- name: Checkout Website
uses: actions/checkout@v3
with:
Expand Down
2 changes: 1 addition & 1 deletion xmcl-electron-app/build.ts
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ async function start() {
}
await buildElectron(electronBuilderConfig, dir)
if (process.env.BUILD_TARGET === 'appx') {
await buildAppInstaller(version, path.join(__dirname, './build/output/xmcl.appinstaller'))
await buildAppInstaller(version, path.join(__dirname, './build/output/xmcl.appinstaller'), electronBuilderConfig.appx!.publisher!)
}
}
}
Expand Down
8 changes: 4 additions & 4 deletions xmcl-electron-app/build/appinstaller-builder.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import { writeFile } from 'fs-extra'

function getAppInstallerContent(version: string) {
function getAppInstallerContent(version: string, publisher: string) {
const result = `<?xml version="1.0" encoding="utf-8"?>
<AppInstaller
xmlns="http://schemas.microsoft.com/appx/appinstaller/2018"
Version="${version}.0"
Uri="https://xmcl.blob.core.windows.net/releases/xmcl.appinstaller" >
<MainPackage
Name="XMCL"
Publisher="E=cijhn@hotmail.com, CN=&quot;Open Source Developer, Hongze Xu&quot;, O=Open Source Developer, L=Beijing, C=CN"
Publisher="${publisher}"
Version="${version}.0"
ProcessorArchitecture="x64"
Uri="https://xmcl-release-ms.azureedge.net/releases/xmcl-${version}.appx" />
Expand All @@ -19,6 +19,6 @@ function getAppInstallerContent(version: string) {
return result.padEnd(1024, ' ')
}

export async function buildAppInstaller(version: string, destination: string) {
await writeFile(destination, getAppInstallerContent(version))
export async function buildAppInstaller(version: string, destination: string, publisher: string) {
await writeFile(destination, getAppInstallerContent(version, publisher))
}
12 changes: 7 additions & 5 deletions xmcl-electron-app/build/electron-builder.config.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import { Configuration } from 'electron-builder'
import { version } from '../package.json'
import { config as dotenv } from 'dotenv'

dotenv()

export const config: Configuration = {
productName: 'X Minecraft Launcher',
Expand Down Expand Up @@ -36,12 +38,12 @@ export const config: Configuration = {
artifactName: 'xmcl-${version}-${platform}-${arch}.${ext}',
appx: {
// eslint-disable-next-line no-template-curly-in-string
artifactName: 'xmcl-${version}-unsigned.${ext}',
artifactName: 'xmcl-${version}.${ext}',
displayName: 'X Minecraft Launcher',
applicationId: 'CI010.XMCL',
identityName: 'XMCL',
backgroundColor: 'transparent',
publisher: 'E=cijhn@hotmail.com, CN=&quot;Open Source Developer, Hongze Xu&quot;, O=Open Source Developer, L=Beijing, C=CN',
publisher: process.env.APPX_PUBLISHER,
publisherDisplayName: 'CI010',
setBuildNumber: true,
languages: ['en-US', 'zh-CN', 'ru'],
Expand Down Expand Up @@ -83,9 +85,9 @@ export const config: Configuration = {
},
artifactName: process.env.BUILD_TARGET === 'appx'
// eslint-disable-next-line no-template-curly-in-string
? 'xmcl-${version}-unsigned.${ext}'
? 'xmcl-${version}.${ext}'
// eslint-disable-next-line no-template-curly-in-string
: 'xmcl-${version}-${platform}-${arch}-unsigned.${ext}',
: 'xmcl-${version}-${platform}-${arch}.${ext}',
icon: 'icons/dark.ico',
files: [
'**/*.cs',
Expand Down
1 change: 1 addition & 0 deletions xmcl-electron-app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
},
"scripts": {
"build": "cross-env NODE_ENV=development esbuild build.ts --bundle --platform=node --external:electron --external:electron-builder --external:esbuild --format=cjs | node",
"build:appx": "cross-env NODE_ENV=production env BUILD_TARGET=appx npm run build",
"build:all": "cross-env NODE_ENV=production cross-env BUILD_TARGET=production npm run build",
"build:dir": "cross-env BUILD_TARGET=dir npm run build",
"check": "tsc --noEmit --project tsconfig.json && tsc --noEmit --project preload/tsconfig.json",
Expand Down

0 comments on commit d29175a

Please sign in to comment.