-
-
Notifications
You must be signed in to change notification settings - Fork 0
105 lines (91 loc) · 2.92 KB
/
Copy pathrelease.yml
File metadata and controls
105 lines (91 loc) · 2.92 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
92
93
94
95
96
97
98
99
100
101
102
103
104
105
name: Release
on:
push:
tags:
- 'v*'
branches:
- main
workflow_dispatch:
inputs:
version:
description: 'Release version (e.g., v1.0.0)'
required: true
type: string
permissions:
contents: write
jobs:
release:
name: Build and Release
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '20.x'
cache: 'npm'
- name: Install dependencies
run: npm ci
- name: Build project
run: npm run build
- name: Build Electron app (Ubuntu)
if: matrix.os == 'ubuntu-latest'
run: npm run electron:build:linux
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Build Electron app (Windows)
if: matrix.os == 'windows-latest'
run: npm run electron:build:win
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Build Electron app (macOS)
if: matrix.os == 'macos-latest'
run: npm run electron:build:mac
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Get release version
id: get_version
shell: bash
run: |
if [ "${{ github.event_name }}" == "workflow_dispatch" ]; then
echo "VERSION=${{ inputs.version }}" >> $GITHUB_OUTPUT
elif [ "${{ github.ref }}" == "refs/heads/main" ]; then
if [ ! -f package.json ]; then
echo "Error: package.json not found"
exit 1
fi
VERSION="v$(node -p "require('./package.json').version" 2>/dev/null)"
if [ -z "$VERSION" ] || [ "$VERSION" = "v" ] || [ "$VERSION" = "vundefined" ] || [ "$VERSION" = "vnull" ]; then
echo "Error: Unable to extract valid version from package.json"
exit 1
fi
echo "VERSION=$VERSION" >> $GITHUB_OUTPUT
else
echo "VERSION=${GITHUB_REF#refs/tags/}" >> $GITHUB_OUTPUT
fi
- name: Upload artifacts
uses: actions/upload-artifact@v4
with:
name: ${{ matrix.os }}-release
path: |
release/**/*
retention-days: 30
- name: Create Release
uses: softprops/action-gh-release@v1
if: startsWith(github.ref, 'refs/tags/') || github.ref == 'refs/heads/main'
with:
tag_name: ${{ steps.get_version.outputs.VERSION }}
files: |
release/**/*.exe
release/**/*.dmg
release/**/*.AppImage
release/**/*.deb
draft: false
prerelease: false
generate_release_notes: true
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}