Skip to content

Commit

Permalink
ci: create build artifacts (#2153)
Browse files Browse the repository at this point in the history
Co-authored-by: László Monda <[email protected]>
  • Loading branch information
ert78gb and mondalaci authored Jan 7, 2024
1 parent bb6e99f commit 5c4c430
Show file tree
Hide file tree
Showing 2 changed files with 85 additions and 57 deletions.
35 changes: 35 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -59,3 +59,38 @@ jobs:
APPLE_ID: ${{ secrets.APPLE_ID }}
APPLE_APP_SPECIFIC_PASSWORD: ${{ secrets.APPLE_ID_PASS }}
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: List dist folder on Linux and Mac
if: runner.os == 'macOS' || runner.os == 'Linux'
run: ls -la dist

- name: Upload Mac installer artifact
if: runner.os == 'macOS'
uses: actions/upload-artifact@v4
with:
name: UHK.Agent-mac-installer
path: dist/UHK.Agent-*-mac.dmg
compression-level: 0
retention-days: 5

- name: Upload Linux AppImage artifact
if: runner.os == 'Linux'
uses: actions/upload-artifact@v4
with:
name: UHK.Agent-linux-x86_64.AppImage
path: dist/UHK.Agent-*-linux-x86_64.AppImage
compression-level: 0
retention-days: 5

- name: List dist folder on Windows
if: runner.os == 'Windows'
run: dir dist

- name: Upload Windows installer artifacts
if: runner.os == 'Windows'
uses: actions/upload-artifact@v4
with:
name: UHK.Agent-windows-installers
path: dist/UHK.Agent-*-win*.exe
compression-level: 0
retention-days: 5
107 changes: 50 additions & 57 deletions scripts/release.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
const exec = require('child_process').execSync;

const TEST_BUILD = process.env.TEST_BUILD; // set true if you would like to test on your local machine
const DIR = process.env.DIR;

// electron-builder security override.
// Need if wanna create test release build from PR
Expand All @@ -13,14 +12,15 @@ if (!process.env.CI && !TEST_BUILD) {
process.exit(1);
}

const isCI = process.env.CI;
const githubRef = process.env.GITHUB_REF;
const gitTag = getGithubTag();
const githubEventName = process.env.GITHUB_EVENT_NAME;
const repoName = process.env.GITHUB_REPOSITORY;

console.log({ gitTag, repoName, githubRef, githubEventName });
console.log({ gitTag, isCI, repoName, githubRef, githubEventName });

const isReleaseCommit = TEST_BUILD || gitTag && repoName === 'UltimateHackingKeyboard/agent';
const isReleaseCommit = TEST_BUILD || isCI && repoName === 'UltimateHackingKeyboard/agent';

if (!isReleaseCommit) {
console.log('It is not a release task. Skipping publish.');
Expand Down Expand Up @@ -65,62 +65,55 @@ if (process.platform === 'darwin' && process.env.CI) {
exec('openssl aes-256-cbc -K %CERT_KEY% -iv %CERT_IV% -in scripts/certs/windows-cert.p12.enc -out scripts/certs/windows-cert.p12 -d')
}

if (TEST_BUILD || gitTag) {
const rootJson = require('../package.json');
update2ndPackageJson(rootJson);

// Add firmware to extra resources
const extractedFirmwareDir = path.join(__dirname, '../tmp/packages');
extraResources.push({ from: extractedFirmwareDir, to: 'packages/' });
extraResources.push({ from: path.join(__dirname, '../tmp/smart-macro-docs'), to: 'smart-macro-docs/' });

builder.build({
dir: DIR,
targets: target,
config: {
afterPack,
directories: {
app: electron_build_folder
},
appId: 'com.ultimategadgetlabs.agent',
productName: 'UHK Agent',
mac: {
category: 'public.app-category.utilities',
extraResources,
identity: 'CMXCBCFHDG',
cscLink: path.join(__dirname, 'certs/mac-cert.p12'),
hardenedRuntime: true,
gatekeeperAssess: false,
entitlements: path.join(__dirname, 'entitlements.mac.plist'),
entitlementsInherit: path.join(__dirname, 'entitlements.mac.plist')
},
win: {
extraResources,
publisherName: 'Ultimate Gadget Laboratories Kft.',
certificateFile: path.join(__dirname, 'certs/windows-cert.p12')
},
linux: {
extraResources
},
publish: 'github',
artifactName,
files: [
'**/*'
]
const rootJson = require('../package.json');
update2ndPackageJson(rootJson);

// Add firmware to extra resources
const extractedFirmwareDir = path.join(__dirname, '../tmp/packages');
extraResources.push({ from: extractedFirmwareDir, to: 'packages/' });
extraResources.push({ from: path.join(__dirname, '../tmp/smart-macro-docs'), to: 'smart-macro-docs/' });

builder.build({
targets: target,
config: {
afterPack,
directories: {
app: electron_build_folder
},
appId: 'com.ultimategadgetlabs.agent',
productName: 'UHK Agent',
mac: {
category: 'public.app-category.utilities',
extraResources,
identity: 'CMXCBCFHDG',
cscLink: path.join(__dirname, 'certs/mac-cert.p12'),
hardenedRuntime: true,
gatekeeperAssess: false,
entitlements: path.join(__dirname, 'entitlements.mac.plist'),
entitlementsInherit: path.join(__dirname, 'entitlements.mac.plist')
},
win: {
extraResources,
publisherName: 'Ultimate Gadget Laboratories Kft.',
certificateFile: path.join(__dirname, 'certs/windows-cert.p12')
},
linux: {
extraResources
},
publish: 'github',
artifactName,
files: [
'**/*'
]
},
})
.then(() => {
console.log('Packing success.');
})
.catch((error) => {
console.error(error);
process.exit(1);
})
.then(() => {
console.log('Packing success.');
})
.catch((error) => {
console.error(error);
process.exit(1);
})
} else {
console.log('No git tag');
// TODO: Need it?
process.exit(1);
}

function update2ndPackageJson(rootJson) {
const jsonPath = path.join(__dirname, '../packages/uhk-agent/dist/package.json');
Expand Down

0 comments on commit 5c4c430

Please sign in to comment.