release #26
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: release | |
on: | |
workflow_dispatch: | |
push: | |
tags: | |
- "v*.*.*" | |
jobs: | |
build: | |
name: Build Release | |
runs-on: windows-latest | |
permissions: | |
contents: write | |
env: | |
# msbuild_path: C:\Program Files\Microsoft Visual Studio\2022\Enterprise\MSBuild\Current\Bin\MSBuild.exe | |
msvs_version: 2022 | |
ELECTRON_CACHE: ${{ github.workspace }}/.cache/electron | |
ELECTRON_BUILDER_CACHE: ${{ github.workspace }}/.cache/electron-builder | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
# 为了获取标签 | |
fetch-depth: 0 | |
fetch-tags: true | |
show-progress: false | |
- name: Use Node.js | |
uses: actions/setup-node@v4 | |
with: | |
node-version: 18 | |
cache: npm | |
- name: Cache Electron | |
uses: actions/cache@v3 | |
with: | |
path: ${{ github.workspace }}/.cache/electron | |
key: ${{ runner.os }}-electron-cache-${{ hashFiles(format('{0}{1}', github.workspace, '/package-lock.json')) }} | |
restore-keys: | | |
${{ runner.os }}-electron-cache- | |
- name: Cache Electron-Builder | |
uses: actions/cache@v3 | |
with: | |
path: ${{ github.workspace }}/.cache/electron-builder | |
key: ${{ runner.os }}-electron-builder-cache-${{ hashFiles(format('{0}{1}', github.workspace, '/package-lock.json')) }} | |
restore-keys: | | |
${{ runner.os }}-electron-builder-cache- | |
# npm ci 的支持缓存版本,减少在本就性能不佳的 windows runner 上的编译时间 | |
- uses: AnnAngela/cached_node-modules@v2 | |
id: cached_node-modules | |
with: | |
customVariable: :patches@${{ hashFiles('patches/**') }} | |
- name: Build the native modules | |
if: steps.cached_node-modules.outputs.cache-hit != 'true' | |
run: npm run rebuild | |
- name: Build the app | |
run: npm run build | |
- name: Get the version | |
id: appVersion | |
shell: bash | |
run: echo "appVersion=$(git describe --abbrev=0 --tags)" >> $GITHUB_OUTPUT && cat $GITHUB_OUTPUT | |
- name: Show the result | |
run: Get-ChildItem -Path release/ -Recurse -Force | |
- uses: ncipollo/release-action@v1 | |
with: | |
tag: v${{ steps.appVersion.outputs.appVersion }} | |
allowUpdates: true | |
artifacts: "release/${{ steps.appVersion.outputs.appVersion }}/Joi-Windows-${{ steps.appVersion.outputs.appVersion }}-Setup.exe" | |
token: ${{ secrets.GH_TOKEN }} |