-
Notifications
You must be signed in to change notification settings - Fork 2
160 lines (142 loc) · 4.85 KB
/
Copy pathrelease.yml
File metadata and controls
160 lines (142 loc) · 4.85 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
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
name: Manual Cross Platform Release
on:
workflow_dispatch:
inputs:
version_bump:
description: 'Version bump type'
required: true
default: 'patch'
type: choice
options:
- patch
- minor
- major
publish:
description: Publish artifacts to GitHub release
required: true
default: true
type: boolean
jobs:
prepare:
name: Bump version
runs-on: ubuntu-latest
permissions:
contents: write
outputs:
new_version: ${{ steps.bump.outputs.new_version }}
sha: ${{ steps.commit.outputs.sha }}
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Bump version
id: bump
run: |
NEW_VERSION=$(npm version ${{ github.event.inputs.version_bump }} --no-git-tag-version | sed 's/^v//')
echo "new_version=${NEW_VERSION}" >> "$GITHUB_OUTPUT"
- name: Commit version bump
id: commit
run: |
git config --local user.email "action@github.com"
git config --local user.name "GitHub Action"
git add package.json
git commit -m "Bump version to ${{ steps.bump.outputs.new_version }}"
git push origin HEAD:${{ github.ref_name }}
echo "sha=$(git rev-parse HEAD)" >> "$GITHUB_OUTPUT"
build:
name: Build ${{ matrix.platform }} on ${{ matrix.os }}
needs: prepare
strategy:
fail-fast: false
matrix:
include:
- os: windows-latest
platform: win
build_command: pnpm exec electron-builder --win --x64 --publish never
- os: macos-latest
platform: mac
build_command: pnpm exec electron-builder --mac --publish never
runs-on: ${{ matrix.os }}
steps:
- name: Checkout
uses: actions/checkout@v4
with:
ref: ${{ needs.prepare.outputs.sha }}
- name: Setup pnpm
uses: pnpm/action-setup@v4
- name: Setup Node
uses: actions/setup-node@v4
with:
node-version: 22
cache: pnpm
- name: Install dependencies
run: pnpm install --frozen-lockfile
- name: Build Electron main process
run: pnpm run electron:build-main
- name: Build renderer assets
run: pnpm run build
- name: Build release packages
# No signing certificate yet: mac.identity "-" in package.json forces ad-hoc signing so
# Apple Silicon builds launch. electron-builder only consults CSC_IDENTITY_AUTO_DISCOVERY
# when identity is unset, so it has no effect here - left unset for clarity, not because
# it changes this build.
run: ${{ matrix.build_command }}
shell: bash
# The mac job packages x64 and arm64 from one node_modules, and pnpm only materialises
# the runner's own architecture, so a missing native binary is invisible until a user
# launches the artifact. Fail the release here instead.
- name: Verify packaged native dependencies
run: node test/verify-packaged-sharp.mjs release
shell: bash
- name: Upload build artifacts
uses: actions/upload-artifact@v4
with:
name: release-${{ matrix.platform }}
path: |
release/*.exe
release/*.dmg
release/*.zip
release/*.yml
release/*.yaml
release/*.blockmap
if-no-files-found: error
publish:
if: ${{ inputs.publish }}
name: Publish GitHub Release
needs: [prepare, build]
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Checkout
uses: actions/checkout@v4
with:
ref: ${{ needs.prepare.outputs.sha }}
- name: Download artifacts
uses: actions/download-artifact@v4
with:
path: release-artifacts
- name: Tag and publish release
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
VERSION="${{ needs.prepare.outputs.new_version }}"
TAG="v${VERSION}"
git config --local user.email "action@github.com"
git config --local user.name "GitHub Action"
git tag "$TAG"
git push origin "$TAG"
sed "s/VERSION_PLACEHOLDER/${VERSION}/g" .github/release_notes_template.md > release_notes.md
gh release create "$TAG" \
--title "Release ${TAG}" \
--notes-file release_notes.md
while IFS= read -r -d '' file; do
echo "Uploading $(basename "$file")"
gh release upload "$TAG" "$file" --clobber
done < <(
find release-artifacts -type f \
\( -name '*.exe' -o -name '*.dmg' -o -name '*.zip' \
-o -name '*.yml' -o -name '*.yaml' -o -name '*.blockmap' \) \
-print0
)