-
Notifications
You must be signed in to change notification settings - Fork 0
91 lines (77 loc) · 2.57 KB
/
Copy pathrelease.yml
File metadata and controls
91 lines (77 loc) · 2.57 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
name: Release
on:
push:
branches:
- main
tags:
- 'v*'
workflow_dispatch:
inputs:
tag:
description: Release tag, for example v26.07.02
required: true
type: string
permissions:
contents: write
jobs:
windows-release:
name: Build Windows exe and publish release
runs-on: windows-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: 24
- name: Set up pnpm
run: |
corepack enable
corepack prepare pnpm@11.7.0 --activate
- name: Install dependencies
run: pnpm install --frozen-lockfile
- name: Run tests
run: pnpm test
- name: Build desktop executable
env:
CSC_IDENTITY_AUTO_DISCOVERY: false
run: pnpm run release:desktop
- name: Resolve release tag
id: release
shell: pwsh
env:
EVENT_NAME: ${{ github.event_name }}
INPUT_TAG: ${{ inputs.tag }}
REF_TYPE: ${{ github.ref_type }}
REF_NAME: ${{ github.ref_name }}
run: |
$package = Get-Content package.json -Raw | ConvertFrom-Json
if ($env:EVENT_NAME -eq 'workflow_dispatch' -and $env:INPUT_TAG) {
$tag = $env:INPUT_TAG
} elseif ($env:REF_TYPE -eq 'tag') {
$tag = $env:REF_NAME
} else {
$tag = "v$($package.releaseVersion)"
}
if (-not $tag.StartsWith('v')) {
$tag = "v$tag"
}
"tag=$tag" | Out-File -FilePath $env:GITHUB_OUTPUT -Append
"title=文件整理 $tag" | Out-File -FilePath $env:GITHUB_OUTPUT -Append
"assetName=文件整理-$tag.exe" | Out-File -FilePath $env:GITHUB_OUTPUT -Append
- name: Create or update GitHub release
shell: pwsh
env:
GH_TOKEN: ${{ github.token }}
RELEASE_TAG: ${{ steps.release.outputs.tag }}
RELEASE_TITLE: ${{ steps.release.outputs.title }}
ASSET_NAME: ${{ steps.release.outputs.assetName }}
run: |
$asset = "dist/$env:ASSET_NAME#$env:ASSET_NAME"
gh release view "$env:RELEASE_TAG" *> $null
if ($LASTEXITCODE -eq 0) {
gh release upload "$env:RELEASE_TAG" "$asset" --clobber
gh release edit "$env:RELEASE_TAG" --title "$env:RELEASE_TITLE"
} else {
gh release create "$env:RELEASE_TAG" "$asset" --title "$env:RELEASE_TITLE" --generate-notes --target "${{ github.sha }}"
}