-
Notifications
You must be signed in to change notification settings - Fork 0
269 lines (239 loc) · 10.4 KB
/
push.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
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
name: ⚓ Push
run-name: Release ${{ inputs.version }}
on:
workflow_dispatch:
inputs:
version:
description: version(optional)
type: string
default:
ref:
type: string
default: dev
workflow_call:
inputs:
version:
description: version(optional)
type: string
required: false
ref:
type: string
description: The branch or tag to checkout
default: dev
required: false
secrets:
GH_TOKEN:
required: true
S3_ACCESS_KEY_ID:
required: true
S3_ACCESS_KEY_SECRET:
required: true
GO_BUILD_CERTIFICATE_BASE64:
required: true
GO_P12_PASSWORD:
required: true
GO_BUILD_PROVISION_PROFILE_BASE64:
required: true
GO_KEYCHAIN_PASSWORD:
required: true
APPLE_ID:
required: true
APPLE_PASSWORD:
required: true
APPLE_TEAM_ID:
required: true
jobs:
build-binary:
name: BuildBinary
permissions:
id-token: write
contents: write
attestations: write
strategy:
fail-fast: true
matrix:
os: [windows-latest, macos-latest]
runs-on: ${{ matrix.os }}
timeout-minutes: 30
steps:
- uses: actions/checkout@v4
with:
repository: dream-num/univer-desktop
ref: ${{ inputs.ref }}
token: ${{ secrets.GH_TOKEN }}
submodules: true
- name: Setup pnpm
uses: pnpm/action-setup@v4
- uses: actions/setup-node@v4
with:
node-version: '22'
- name: Set version
id: set_version
shell: bash
run: |
if [ -z "${{ inputs.version }}" ]; then
cd app
APP_VERSION=$(node -e 'console.log(require("./package.json").version)')
if [ "${{ github.repository }}" = "dream-num/univer-go" ]; then
echo "version=${APP_VERSION}" >> $GITHUB_OUTPUT
else
COMMIT_HASH=$(git rev-parse --short=7 HEAD)
# get dev release count
DEV_RELEASES=$(gh release list -R ${{ github.repository }} --limit 100 | grep "${APP_VERSION}-dev" | wc -l || true)
BUILD_NUMBER=$((DEV_RELEASES + 1))
echo "version=${APP_VERSION}-dev.${BUILD_NUMBER}-${COMMIT_HASH}" >> $GITHUB_OUTPUT
fi
else
echo "version=${{ inputs.version }}" >> $GITHUB_OUTPUT
fi
env:
GH_TOKEN: ${{ secrets.GH_TOKEN }}
- name: Determine version type
id: version_type
shell: bash
run: |
VERSION="${{ steps.set_version.outputs.version }}"
if [[ $VERSION == *"-dev"* ]]; then
echo "is_dev=true" >> $GITHUB_OUTPUT
echo "is_stable=false" >> $GITHUB_OUTPUT
elif [[ $VERSION =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
echo "is_dev=false" >> $GITHUB_OUTPUT
echo "is_stable=true" >> $GITHUB_OUTPUT
else
echo "is_dev=false" >> $GITHUB_OUTPUT
echo "is_stable=false" >> $GITHUB_OUTPUT
fi
- name: Check version
if: ${{ github.repository == 'dream-num/univer-go' }}
shell: bash
run: |
if [ ${{ steps.version_type.outputs.is_dev }} = "true" ]; then
exit 1
fi
- name: Determine release channel
id: release_channel
shell: bash
run: |
if [ "${{ steps.version_type.outputs.is_dev }}" = "true" ]; then
echo "channel=development" >> $GITHUB_OUTPUT
else
echo "channel=production" >> $GITHUB_OUTPUT
fi
- name: init dest
id: init_dest
shell: bash
run: |
if [ ${{ steps.release_channel.outputs.channel }} = "development" ]; then
echo "dest=test/staging/" >> $GITHUB_OUTPUT
else
echo "dest=univer-go/latest/" >> $GITHUB_OUTPUT
fi
- name: Print Release Info
shell: bash
run: |
echo "Version: ${{ steps.set_version.outputs.version }}"
echo "Is Dev: ${{ steps.version_type.outputs.is_dev }}"
echo "Is Stable: ${{ steps.version_type.outputs.is_stable }}"
echo "Dest: ${{ steps.init_dest.outputs.dest }}"
echo "RELEASE_CHANNEL: ${{ steps.release_channel.outputs.channel }}"
- name: Install Python setuptools
if: matrix.os == 'macos-latest'
run: brew install python-setuptools
- name: Install appdmg
if: matrix.os == 'macos-latest'
run: pnpm add -g appdmg
- name: Install the Apple certificate and provisioning profile
if: runner.os == 'macOS'
env:
BUILD_CERTIFICATE_BASE64: ${{ secrets.GO_BUILD_CERTIFICATE_BASE64 }}
P12_PASSWORD: ${{ secrets.GO_P12_PASSWORD }}
BUILD_PROVISION_PROFILE_BASE64: ${{ secrets.GO_BUILD_PROVISION_PROFILE_BASE64 }}
KEYCHAIN_PASSWORD: ${{ secrets.GO_KEYCHAIN_PASSWORD }}
run: |
# create variables
CERTIFICATE_PATH=$RUNNER_TEMP/build_certificate.p12
PP_PATH=$RUNNER_TEMP/build_pp.provisionprofile
KEYCHAIN_PATH=$RUNNER_TEMP/app-signing.keychain-db
# import certificate and provisioning profile from secrets
echo -n "$BUILD_CERTIFICATE_BASE64" | base64 --decode > $CERTIFICATE_PATH
echo -n "$BUILD_PROVISION_PROFILE_BASE64" | base64 --decode > $PP_PATH
# create temporary keychain
security create-keychain -p "$KEYCHAIN_PASSWORD" $KEYCHAIN_PATH
security set-keychain-settings -lut 21600 $KEYCHAIN_PATH
security unlock-keychain -p "$KEYCHAIN_PASSWORD" $KEYCHAIN_PATH
# import certificate to keychain
security import $CERTIFICATE_PATH -P "$P12_PASSWORD" -A -t cert -f pkcs12 -k $KEYCHAIN_PATH
security set-key-partition-list -S apple-tool:,apple: -k "$KEYCHAIN_PASSWORD" $KEYCHAIN_PATH
security list-keychain -d user -s $KEYCHAIN_PATH
# apply provisioning profile
mkdir -p ~/Library/MobileDevice/Provisioning\ Profiles
cp $PP_PATH ~/Library/MobileDevice/Provisioning\ Profiles
- name: fix npm error
shell: bash
run: git config --global url.https://${{ secrets.GH_TOKEN }}@github.com/.insteadOf https://github.com/
- run: pnpm i
shell: bash
- run: |
cd app
pnpm version ${{ steps.set_version.outputs.version }} --allow-same-version --no-git-tag-version
- name: Make (macOS)
if: matrix.os == 'macos-latest'
env:
APPLE_ID: ${{ secrets.APPLE_ID }}
APPLE_PASSWORD: ${{ secrets.APPLE_PASSWORD }}
APPLE_TEAM_ID: ${{ secrets.APPLE_TEAM_ID }}
KEYCHAIN_PATH: ${{ runner.temp }}/app-signing.keychain-db
shell: bash
run: |
RELEASE_CHANNEL=${{ steps.release_channel.outputs.channel }} pnpm make
- name: Make
if: matrix.os != 'macos-latest'
shell: bash
run: |
RELEASE_CHANNEL=${{ steps.release_channel.outputs.channel }} pnpm make
- uses: hexf00/upload-to-oss@v2
with:
files: |
app/out/make/**/*.dmg
app/out/make/**/*.zip
app/out/make/**/*.exe
app/out/make/**/*.AppImage
dest: ${{ steps.init_dest.outputs.dest }}
bucket: release-univer
region: oss-cn-shenzhen
accessKeyId: ${{secrets.S3_ACCESS_KEY_ID}}
accessKeySecret: ${{secrets.S3_ACCESS_KEY_SECRET}}
timeout: 1200s
- uses: hexf00/upload-to-oss@v2
if: ${{ steps.version_type.outputs.is_stable == 'true' }}
continue-on-error: true
with:
files: |
app/out/make/**/*.yml
dest: ${{ steps.init_dest.outputs.dest }}
bucket: release-univer
region: oss-cn-shenzhen
accessKeyId: ${{secrets.S3_ACCESS_KEY_ID}}
accessKeySecret: ${{secrets.S3_ACCESS_KEY_SECRET}}
timeout: 1200s
- name: Create Release (stable)
uses: softprops/action-gh-release@v2
if: ${{ steps.version_type.outputs.is_stable == 'true' }}
with:
name: Release ${{ steps.set_version.outputs.version }}
draft: false
prerelease: ${{ steps.version_type.outputs.is_stable == 'false' }}
tag_name: ${{ steps.set_version.outputs.version }}
files: |
app/out/make/**/*.dmg
app/out/make/**/*.zip
app/out/make/**/*.exe
app/out/make/**/*.AppImage
app/out/make/**/*.yml
body: |
${{ !steps.version_type.outputs.is_stable && 'This is an automated nightly release for testing purposes.' || '' }}
Version: ${{ steps.set_version.outputs.version }}
Version Info:
- is_stable: ${{ steps.version_type.outputs.is_stable }}
- is_dev: ${{ steps.version_type.outputs.is_dev }}
${{ !steps.version_type.outputs.is_stable && '**Warning:** This build may be unstable and is not recommended for production use.' || '' }}