-
Notifications
You must be signed in to change notification settings - Fork 4
178 lines (147 loc) · 4.94 KB
/
build.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
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
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
name: Release
permissions:
contents: write
pages: write
id-token: write
on:
workflow_dispatch:
push:
branches:
- main
paths-ignore:
- '**.md'
- '**.spec.js'
- '.idea'
- '.gitignore'
- '.github/**'
- '!.github/workflows/release.yml'
concurrency:
group: release-${{ github.ref }}
cancel-in-progress: true
defaults:
run:
shell: 'bash'
env:
NODE_NO_WARNINGS: 1
npm_config_audit: false
npm_config_fund: false
jobs:
draft:
runs-on: ubuntu-latest
outputs:
release-note: ${{ steps.release-note.outputs.release-note }}
version: ${{ steps.version.outputs.build-version }}
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- uses: actions/setup-node@v3
with:
node-version: 20
cache: 'npm'
- name: Get last git tag
id: tag
run: echo "last-tag=$(git describe --tags --abbrev=0 || git rev-list --max-parents=0 ${{github.ref}})" >> $GITHUB_OUTPUT
- name: Generate release notes
id: release-note
run: |
RELEASE_NOTES=$(git log $(git describe --tags --abbrev=0)..HEAD --oneline)
RELEASE_NOTES="${RELEASE_NOTES//'%'/'%25'}"
RELEASE_NOTES="${RELEASE_NOTES//$'\n'/'%0A'}"
RELEASE_NOTES="${RELEASE_NOTES//$'\r'/'%0D'}"
echo "release-note=$RELEASE_NOTES" >> $GITHUB_OUTPUT
- name: Get version from current date
id: version
run: |
VERSION=$(node -e "console.log(require('./package.json').version)")
echo "build-version=$VERSION" >> $GITHUB_OUTPUT
- name: Waiting on All checks
uses: lewagon/[email protected]
with:
ref: ${{ github.ref }}
repo-token: ${{ secrets.GITHUB_TOKEN }}
running-workflow-name: 'draft'
- name: Delete outdated drafts
uses: hugo19941994/[email protected]
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Create Release Draft
uses: softprops/action-gh-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
prerelease: true
draft: true
tag_name: v${{ steps.version.outputs.build-version }}
name: v${{ steps.version.outputs.build-version }}
body: "Release v${{ steps.version.outputs.build-version }}"
upload_artifacts:
needs: [draft]
if: ${{ !contains(github.event.head_commit.message, '[skip]') }}
strategy:
matrix:
os: [windows-latest, macos-latest]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: 20
cache: 'npm'
- name: Install dependencies
run: npm install
# The easiest way to transfer release notes to a compiled application is create `release-notes.md` in the build resources.
# See https://github.com/electron-userland/electron-builder/issues/1511#issuecomment-310160119
- name: Create build resources directory
run: mkdir -p resources
- name: Prepare release notes
env:
RELEASE_NOTE: ${{ needs.draft.outputs.release-note }}
run: echo "$RELEASE_NOTE" >> ./resources/release-notes.md
# If building a release for macos, need to do notarization.
# - name: Prepare for app notarization
# if: startsWith(matrix.os, 'macos')
# # Import Apple API key for app notarization on macOS
# run: |
# mkdir -p ~/private_keys/
# echo '${{ secrets.apple_api_key }}' > ~/private_keys/AuthKey_${{ secrets.api_key_id }}.p8
# If releasing Linux app to Snapcraft, install and sign in.
# - name: Install Snapcraft
# uses: samuelmeuli/action-snapcraft@v1
# # Only install Snapcraft on Ubuntu
# if: startsWith(matrix.os, 'ubuntu')
# with:
# # Log in to Snap Store
# snapcraft_token: ${{ secrets.snapcraft_token }}
# Compile app and upload artifacts
- name: Compile & release Electron app
uses: samuelmeuli/action-electron-builder@v1
env:
VITE_APP_VERSION: ${{ needs.draft.outputs.version }}
with:
build_script_name: build
args: --config electron-builder.yml
github_token: ${{ secrets.GITHUB_TOKEN }}
release: true
max_attempts: 3
build_web:
needs: [draft]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: 20
cache: 'npm'
- name: Install dependencies
run: npm install
- name: Build web target
run: npm run build:web
- name: Deploy to GitHub Pages
uses: JamesIves/github-pages-deploy-action@v4
with:
branch: build
folder: dist/web
clean: true
single-commit: true
token: ${{ secrets.GITHUB_TOKEN }}