-
Notifications
You must be signed in to change notification settings - Fork 2
134 lines (113 loc) · 5.28 KB
/
Copy pathdeploy.yml
File metadata and controls
134 lines (113 loc) · 5.28 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
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
# .github/workflows/release.yml
name: Bump Version, Build & Release Electron App
on:
push:
branches:
- master # Or 'main'
workflow_dispatch:
permissions:
contents: write # NEEDED for standard-version to commit/tag & electron-builder to release
actions: write
# pages: write # Add back if deploying pages in same workflow
# id-token: write # Add back if deploying pages in same workflow
jobs:
release:
# Prevent multiple concurrent release builds for the same ref
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
runs-on: ubuntu-latest # Run versioning/tagging/committing on one OS (Linux is fine)
steps:
# 1. Checkout code (fetch all history for standard-version)
- name: Check out Git repository
uses: actions/checkout@v4
with:
fetch-depth: 0 # Fetch all history for standard-version to analyze commits
lfs: true
# Use a token with write access if needed for pushing commit/tag
# token: ${{ secrets.YOUR_PAT_OR_APP_TOKEN }} # OPTIONAL: Use if default GITHUB_TOKEN lacks push rights
# 2. Install Git LFS
- name: Install Git LFS
run: |
git lfs install
git lfs pull
# 3. Setup Node.js
- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: 20
cache: 'npm'
# 4. Install All Dependencies (including devDeps for standard-version)
- name: Install Dependencies
run: npm ci
# --- Configure Git ---
# Needed for standard-version to commit the version bump
- name: Configure Git User
run: |
git config user.name "GitHub Action Bot"
git config user.email "action-bot@github.com" # Or a no-reply email
# --- Version Bump & Changelog ---
# Run standard-version: bumps version, updates CHANGELOG, commits, tags
# It will automatically detect the next version based on conventional commits.
# It only runs if there are feat/fix/BREAKING commits since the last tag.
- name: Bump version and create changelog
run: npx standard-version --commit-all --release-as patch # Use patch | minor | major or let it detect based on commits
# OR simply: npx standard-version # To let it auto-detect bump level
# Add --skip.changelog=true if you don't want CHANGELOG.md updated
env:
# Use default token which *should* have push rights for commits/tags
# If branch protection prevents this, use a PAT/App token via secrets
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# --- Push Changes & Tag ---
# Push the commit created by standard-version and the new tag
- name: Push changes and tag
run: git push --follow-tags origin ${{ github.ref }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Use token for push rights
# --- Build & Release Electron App using electron-builder ---
# Use a separate job for multi-platform builds, triggered after versioning
# OR build directly here if only targeting one platform or using cross-compilation setup
build_and_publish:
needs: release # Run after versioning/tagging/pushing is done
strategy:
matrix:
os: [macos-latest, ubuntu-latest, windows-latest] # Build on all platforms
runs-on: ${{ matrix.os }}
steps:
# Checkout the specific commit/tag created by standard-version (or just the latest)
- name: Check out Git repository
uses: actions/checkout@v4
with:
lfs: true
# No need to fetch full depth here usually
- name: Install Git LFS
run: |
git lfs install
git lfs pull
- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: 20
cache: 'npm'
- name: Install Dependencies
run: npm ci
# Build the portable web content needed for Electron
- name: Build Portable Web App Content
run: npm run build:portable
# Build and Publish the Electron App for the current matrix OS
- name: Build and Publish Electron Application
run: npm run release:electron # This runs 'electron-builder --publish always'
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed by electron-builder to upload assets
# Important Note: By default, electron-builder running on multiple OS in parallel
# might try to create the *same* GitHub release tag/name multiple times, causing errors.
# Solutions:
# 1) (Recommended) Use a tool/action like `ncipollo/release-action` AFTER all builds
# to create ONE release and upload all artifacts to it.
# 2) Configure electron-builder cleverly (e.g., use draft releases and only publish the final one).
# 3) Build on ONE OS and rely on electron-builder's cross-compilation (less reliable).
#
# For simplicity NOW, this workflow lets each OS job try to publish. The FIRST one
# will create the release, subsequent ones might fail to create the release but should
# still succeed in uploading their platform-specific asset to the *existing* release
# created by the first job. Check electron-builder logs if issues arise.