-
Notifications
You must be signed in to change notification settings - Fork 0
75 lines (63 loc) · 2 KB
/
build-and-release.yml
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
name: Build and Release
on:
push:
branches:
- main
jobs:
release:
runs-on: windows-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 2
- name: Check if package.json changed
id: check_version
run: |
git diff --name-only HEAD~1 HEAD | grep 'package.json'
if [ $? -eq 0 ]; then
echo "VERSION_CHANGED=true" >> $GITHUB_ENV
else
echo "VERSION_CHANGED=false" >> $GITHUB_ENV
fi
shell: bash
continue-on-error: true
- name: Setup Node.js
if: env.VERSION_CHANGED == 'true'
uses: actions/setup-node@v4
with:
node-version: 20
- name: Install dependencies
if: env.VERSION_CHANGED == 'true'
run: npm install
- name: Build Electron App
if: env.VERSION_CHANGED == 'true'
run: npm run build
- name: Check if gh is already installed
id: check_gh
run: |
if gh --version; then
echo "GH_INSTALLED=true" >> $GITHUB_ENV
else
echo "GH_INSTALLED=false" >> $GITHUB_ENV
fi
shell: bash
- name: Install GitHub CLI
if: env.GH_INSTALLED == 'false'
run: choco install gh --install-arguments="'/l*v c:\gh_msi_install.log'"
- name: Create GitHub Release and Upload Artifacts
if: env.VERSION_CHANGED == 'true'
run: |
$newVersion = $(node -p "require('./package.json').version")
$changelogContent = Get-Content -Raw -Path ./changelog.md
$releaseFiles = Get-ChildItem -Path .\dist\ -Include *.exe,latest.yml -Recurse | Where-Object { $_.Name -ne 'elevate.exe' }
$filePathsArray = @()
foreach ($file in $releaseFiles) {
$filePathsArray += $file.FullName
}
$ghArgs = @('release', 'create', "v$newVersion", '--title', "v$newVersion", '--notes', "$changelogContent")
$ghArgs += $filePathsArray
gh @ghArgs
shell: pwsh
env:
GH_TOKEN: ${{ secrets.GH_TOKEN }}