This repository was archived by the owner on Sep 12, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 17
204 lines (176 loc) · 6.29 KB
/
build-release-binary.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
name: "Attach binaries to GitHub release"
on:
release:
types: [created]
jobs:
build_binaries:
name: Build and attach release binary
strategy:
matrix:
include:
- bin: taker
target: x86_64-unknown-linux-gnu
os: ubuntu-latest
archive_ext: tar
- bin: taker
target: aarch64-unknown-linux-gnu
os: ubuntu-latest
archive_ext: tar
- bin: taker
target: x86_64-apple-darwin
os: macos-latest
archive_ext: tar
- bin: maker
target: x86_64-unknown-linux-gnu
os: ubuntu-latest
archive_ext: tar
- bin: maker
target: aarch64-unknown-linux-gnu
os: ubuntu-latest
archive_ext: tar
- bin: maker
target: x86_64-apple-darwin
os: macos-latest
archive_ext: tar
runs-on: ${{ matrix.os }}
steps:
- name: Checkout tagged commit
uses: actions/checkout@v3
with:
fetch-depth: 0
ref: ${{ github.event.release.target_commitish }}
token: ${{ secrets.ITCHY_GITHUB_TOKEN }}
- name: Fetch all tags (workaround for https://github.com/actions/checkout/issues/290)
run: git fetch --tags --force
- uses: ./.github/actions/build-release-binary
id: build
with:
target: ${{ matrix.target }}
gh_token: ${{ secrets.ITCHY_GITHUB_TOKEN }}
binary: ${{ matrix.bin }}
# Remove once python 3 is the default
- uses: actions/setup-python@v4
with:
python-version: "3.x"
- id: create-archive-name
shell: python # Use python to have a prettier name for the archive.
run: |
import platform
os_info = platform.uname()
arch = os_info.machine
triple = "${{ matrix.target }}".split("-")
arch = triple[0]
archive_name=f'${{ matrix.bin }}_${{ github.event.release.tag_name }}_{os_info.system}_{arch}.${{ matrix.archive_ext }}'
print(f'::set-output name=archive::{archive_name}')
- name: Pack macos archive
if: matrix.os == 'macos-latest'
shell: bash
run: gtar -C ./target/${{ matrix.target }}/release --create --file=${{ steps.create-archive-name.outputs.archive }} ${{ matrix.bin }}
- name: Pack linux archive
if: matrix.os == 'ubuntu-latest'
shell: bash
run: tar -C ./target/${{ matrix.target }}/release --create --file=${{ steps.create-archive-name.outputs.archive }} ${{ matrix.bin }}
- name: Upload archive
uses: actions/[email protected]
env:
GITHUB_TOKEN: ${{ secrets.ITCHY_GITHUB_TOKEN }}
with:
upload_url: ${{ github.event.release.upload_url }}
asset_path: ./${{ steps.create-archive-name.outputs.archive }}
asset_name: ${{ steps.create-archive-name.outputs.archive }}
asset_content_type: application/gzip
publish_electron_binaries:
continue-on-error: true
runs-on: ${{ matrix.os }}
strategy:
matrix:
include:
- os: macos-latest
package_arg: --mac --arm64
arch: arm64
target: aarch64-apple-darwin
- os: macos-latest
package_arg: --mac
target: x86_64-apple-darwin
arch: x64
- os: windows-latest
package_arg: --win --x64
target: x86_64-pc-windows-msvc
arch: x64
defaults:
run:
working-directory: "crates/taker-electron"
steps:
- name: Checkout tagged commit
uses: actions/checkout@v3
with:
fetch-depth: 0
token: ${{ secrets.ITCHY_GITHUB_TOKEN }}
- name: Fetch all tags (workaround for https://github.com/actions/checkout/issues/290)
run: git fetch --tags --force
- name: Setup rust toolchain
working-directory: "./"
run: rustup show
- uses: Swatinem/[email protected]
- name: Install Protoc for Windows
if: matrix.os == 'windows-latest'
uses: arduino/setup-protoc@v1
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}
- name: Setup rust targets for aarch64-apple-darwin
if: matrix.target == 'aarch64-apple-darwin'
run: rustup target add aarch64-apple-darwin
- name: Install Node and Yarn
uses: actions/setup-node@v3
with:
node-version: 16
cache: yarn
cache-dependency-path: |
taker-frontend/yarn.lock
crates/taker-electron/package-lock.json
- name: Build taker frontend
working-directory: taker-frontend
shell: bash
run: |
yarn
yarn build
- name: Bump version in package.json to ${{ github.event.release.tag_name }}
uses: jaywcjlove/github-action-package@main
with:
path: crates/taker-electron/release/app/package.json
data: |
{
"version": "${{ github.event.release.tag_name }}"
}
- name: Install
run: |
yarn install
- name: Install-app-deps
run: |
yarn run build:dll
- name: Build dll
run: |
yarn electron-builder -- install-app-deps --arch=${{matrix.arch}}
yarn run build:dll
- name: Build rust files ${{matrix.target}}
run: |
yarn run build:rust --release --target=${{matrix.target}}
- name: Build electron files main
run: |
yarn run build:main
- name: Build electron files rendered
run: |
yarn run build:renderer
- name: Publish releases
env:
# These values are used for auto updates signing
APPLE_ID: ${{ secrets.APPLE_ID }}
APPLE_ID_PASS: ${{ secrets.APPLE_ID_PASS }}
CSC_LINK: ${{ secrets.CSC_LINK }}
CSC_KEY_PASSWORD: ${{ secrets.CSC_KEY_PASSWORD }}
# This is used for uploading release assets to github
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# Enforce that electron-builder does not skip publication if the release was created more than two hours ago
EP_GH_IGNORE_TIME: true
run: |
yarn electron-builder -- --publish always ${{matrix.package_arg}}