mirror of
https://github.com/geekgeekrun/geekgeekrun.git
synced 2026-06-06 08:00:32 +08:00
add release ci
This commit is contained in:
@@ -32,17 +32,22 @@ jobs:
|
||||
build:
|
||||
# The type of runner that the job will run on
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
env:
|
||||
PUPPETEER_SKIP_DOWNLOAD: 'true'
|
||||
# Steps represent a sequence of tasks that will be executed as part of the job
|
||||
steps:
|
||||
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
|
||||
- uses: actions/checkout@v2
|
||||
|
||||
- name: Install & Build
|
||||
- name: Install dependencies
|
||||
run: |
|
||||
sudo apt update
|
||||
sudo apt install rpm -y
|
||||
npm i pnpm -g
|
||||
npm i pnpm@^8.6.9 -g
|
||||
cd packages/ui
|
||||
pnpm i --force
|
||||
pnpm run build:linux
|
||||
|
||||
- name: Build
|
||||
run: |
|
||||
cd packages/ui
|
||||
node ./scripts/github-ci-build.mjs
|
||||
54
.github/workflows/release-ui.yml
vendored
Normal file
54
.github/workflows/release-ui.yml
vendored
Normal file
@@ -0,0 +1,54 @@
|
||||
name: Release UI
|
||||
|
||||
on:
|
||||
push:
|
||||
# Sequence of patterns matched against refs/tags
|
||||
tags:
|
||||
- "ui-v*" # Push events to matching v*, i.e. v1.0, v20.15.10
|
||||
|
||||
jobs:
|
||||
build:
|
||||
env:
|
||||
PUPPETEER_SKIP_DOWNLOAD: 'true'
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
# Steps represent a sequence of tasks that will be executed as part of the job
|
||||
steps:
|
||||
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
|
||||
- name: Checkout source
|
||||
uses: actions/checkout@v2
|
||||
|
||||
- name: Install dependencies
|
||||
run: |
|
||||
sudo apt update
|
||||
sudo apt install rpm -y
|
||||
npm i pnpm@^8.6.9 -g
|
||||
cd packages/ui
|
||||
pnpm i --force
|
||||
|
||||
- name: Build
|
||||
run: |
|
||||
cd packages/ui
|
||||
node ./scripts/github-ci-build.mjs
|
||||
|
||||
- name: Create Release
|
||||
id: create_release
|
||||
uses: actions/create-release@v1
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
with:
|
||||
tag_name: ${{ github.ref }}
|
||||
release_name: Release ${{ github.ref }}
|
||||
body: TODO New Release.
|
||||
draft: false
|
||||
prerelease: false
|
||||
|
||||
- name: Upload Release Asset
|
||||
uses: actions/upload-release-asset@v1
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
with:
|
||||
upload_url: ${{ steps.create_release.outputs.upload_url }}
|
||||
asset_path: ./${{ secrets.ReleaseZipName }}.zip
|
||||
asset_name: ${{ secrets.ReleaseZipName }}.zip
|
||||
asset_content_type: application/zip
|
||||
@@ -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)
|
||||
}
|
||||
3
packages/ui/scripts/github-ci-build.mjs
Normal file
3
packages/ui/scripts/github-ci-build.mjs
Normal file
@@ -0,0 +1,3 @@
|
||||
import build from './steps/build.mjs'
|
||||
|
||||
build()
|
||||
8
packages/ui/scripts/release-new-version.mjs
Normal file
8
packages/ui/scripts/release-new-version.mjs
Normal file
@@ -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()
|
||||
})()
|
||||
50
packages/ui/scripts/steps/build.mjs
Normal file
50
packages/ui/scripts/steps/build.mjs
Normal file
@@ -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)
|
||||
}
|
||||
}
|
||||
32
packages/ui/scripts/steps/increase-package-version.mjs
Normal file
32
packages/ui/scripts/steps/increase-package-version.mjs
Normal file
@@ -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))
|
||||
}
|
||||
11
packages/ui/scripts/steps/release-version.mjs
Normal file
11
packages/ui/scripts/steps/release-version.mjs
Normal file
@@ -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