mirror of
https://github.com/geekgeekrun/geekgeekrun.git
synced 2026-09-05 23:47:54 +08:00
add release ci
This commit is contained in:
@@ -24,7 +24,8 @@
|
||||
"build:win": "npm run build && electron-builder --win",
|
||||
"build:mac": "npm run build && electron-builder --mac",
|
||||
"build:linux": "npm run build && electron-builder --linux",
|
||||
"install": "cd ./external-node-runtime-dependencies && cross-env PUPPETEER_SKIP_DOWNLOAD=1 npm install --omit=dev"
|
||||
"install": "cd ./external-node-runtime-dependencies && cross-env PUPPETEER_SKIP_DOWNLOAD=1 npm install --omit=dev",
|
||||
"release": "node ./scripts/release-new-version.mjs"
|
||||
},
|
||||
"dependencies": {
|
||||
"@electron-toolkit/preload": "^3.0.0",
|
||||
|
||||
@@ -1,26 +0,0 @@
|
||||
import childProcess from "node:child_process"
|
||||
import fs from "node:fs"
|
||||
import path from "node:path"
|
||||
import os from "node:os"
|
||||
import url from 'node:url'
|
||||
|
||||
const rawCwd = process.cwd()
|
||||
const __dirname = url.fileURLToPath(new URL('.', import.meta.url))
|
||||
|
||||
const sqlitePluginDirPath = path.join(__dirname, '../../sqlite-plugin')
|
||||
process.chdir(sqlitePluginDirPath)
|
||||
try {
|
||||
const sqlitePluginBuildProcess = childProcess.spawnSync('pnpm run build', {
|
||||
stdio: ['inherit', 'inherit', 'inherit'],
|
||||
shell: true
|
||||
})
|
||||
process.chdir(rawCwd)
|
||||
if (sqlitePluginBuildProcess.error) {
|
||||
throw sqlitePluginBuildProcess.error
|
||||
}
|
||||
} catch(error) {
|
||||
process.chdir(rawCwd)
|
||||
console.error('error encouter when build sqlite plugin:')
|
||||
console.error(error)
|
||||
process.exit(1)
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
import build from './steps/build.mjs'
|
||||
|
||||
build()
|
||||
@@ -0,0 +1,8 @@
|
||||
import build from './steps/build.mjs'
|
||||
import increasePackageVersion from './steps/increase-package-version.mjs'
|
||||
import releaseVersion from './steps/release-version.mjs'
|
||||
;(async () => {
|
||||
await increasePackageVersion()
|
||||
await build()
|
||||
await releaseVersion()
|
||||
})()
|
||||
@@ -0,0 +1,50 @@
|
||||
import childProcess from 'node:child_process'
|
||||
import path from 'node:path'
|
||||
import os from 'node:os'
|
||||
import url from 'node:url'
|
||||
|
||||
const currentOsPlatform = os.platform()
|
||||
const osPlatformToBuildCommandMap = {
|
||||
darwin: 'mac',
|
||||
linux: 'linux',
|
||||
win32: 'win'
|
||||
}
|
||||
|
||||
export default function build() {
|
||||
const rawCwd = process.cwd()
|
||||
const __dirname = url.fileURLToPath(new URL('.', import.meta.url))
|
||||
|
||||
const sqlitePluginDirPath = path.join(__dirname, '../../sqlite-plugin')
|
||||
process.chdir(sqlitePluginDirPath)
|
||||
try {
|
||||
const sqlitePluginBuildProcess = childProcess.spawnSync('pnpm run build', {
|
||||
stdio: ['inherit', 'inherit', 'inherit'],
|
||||
shell: true
|
||||
})
|
||||
process.chdir(rawCwd)
|
||||
if (sqlitePluginBuildProcess.error) {
|
||||
throw sqlitePluginBuildProcess.error
|
||||
}
|
||||
} catch (error) {
|
||||
process.chdir(rawCwd)
|
||||
console.error('error encounter when build sqlite plugin:')
|
||||
console.error(error)
|
||||
process.exit(1)
|
||||
}
|
||||
try {
|
||||
const uiBuildProcess = childProcess.spawnSync(
|
||||
`pnpm run build:${osPlatformToBuildCommandMap[currentOsPlatform]}`,
|
||||
{
|
||||
stdio: ['inherit', 'inherit', 'inherit'],
|
||||
shell: true
|
||||
}
|
||||
)
|
||||
if (uiBuildProcess.error) {
|
||||
throw uiBuildProcess.error
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('error encounter when build ui:')
|
||||
console.error(error)
|
||||
process.exit(1)
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
import path from 'path'
|
||||
import fs from 'fs'
|
||||
import { execSync } from 'child_process'
|
||||
import * as url from 'url'
|
||||
import semver from 'semver'
|
||||
|
||||
const __dirname = url.fileURLToPath(new URL('.', import.meta.url))
|
||||
|
||||
export const PATH_TO_PACKAGE_JSON = path.join(__dirname, '../package.json')
|
||||
export const PATH_TO_BUILD_INFO_JSON = path.join(__dirname, '../src/common/build-info.json')
|
||||
|
||||
export const getPackageInfo = () => fs.readFileSync(PATH_TO_PACKAGE_JSON)
|
||||
export const getRuntimeConfig = () => fs.readFileSync(PATH_TO_BUILD_INFO_JSON)
|
||||
|
||||
/**
|
||||
* @param {semver.ReleaseType} releaseType
|
||||
*/
|
||||
export default async function increasePackageVersion(releaseType = 'patch') {
|
||||
const runtimeConfig = JSON.parse(getRuntimeConfig().toString('utf-8'))
|
||||
const packageInfo = JSON.parse(getPackageInfo().toString('utf-8'))
|
||||
packageInfo.version = semver.inc(packageInfo.version, releaseType)
|
||||
|
||||
fs.writeFileSync(PATH_TO_PACKAGE_JSON, JSON.stringify(packageInfo, null, 2))
|
||||
|
||||
runtimeConfig.name = packageInfo.name
|
||||
runtimeConfig.version = packageInfo.version
|
||||
runtimeConfig.buildVersion =
|
||||
typeof runtimeConfig.buildVersion === 'number' ? runtimeConfig.buildVersion + 1 : 1
|
||||
runtimeConfig.buildTime = Number(new Date())
|
||||
runtimeConfig.buildHash = execSync('git rev-parse HEAD').toString().trim()
|
||||
fs.writeFileSync(PATH_TO_BUILD_INFO_JSON, JSON.stringify(runtimeConfig, null, 2))
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
import { execSync } from 'child_process'
|
||||
import { getPackageInfo } from './increase-package-version.mjs'
|
||||
|
||||
export default async function releaseVersion() {
|
||||
execSync(`git add -A`)
|
||||
const packageInfo = JSON.parse(getPackageInfo().toString('utf-8'))
|
||||
const tagName = `ui-v${packageInfo.version}`
|
||||
execSync(`git commit -m ${tagName}`, { stdio: ['inherit', 'inherit', 'inherit'] })
|
||||
execSync(`git tag ${tagName}`, { stdio: ['inherit', 'inherit', 'inherit'] })
|
||||
execSync(`git push origin ${tagName}`, { stdio: ['inherit', 'inherit', 'inherit'] })
|
||||
}
|
||||
Reference in New Issue
Block a user