forked from berty/berty
-
Notifications
You must be signed in to change notification settings - Fork 0
170 lines (151 loc) · 5.3 KB
/
mac.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
name: macOS Release
on:
push:
tags:
- v*
branches:
- master
paths:
- "go/**"
- "!go/**.md"
- ".goreleaser"
- "go.*"
- "**.go"
- ".github/workflows/go.yml"
- "js/**"
- "config/**"
- ".github/workflows/js.yml"
pull_request:
paths:
- "go/**"
- "!go/**.md"
- ".goreleaser"
- "go.*"
- "**.go"
- ".github/workflows/go.yml"
- "js/**"
- "config/**"
- ".github/workflows/js.yml"
jobs:
mac_runner_matrix_builder:
name: macOS matrix builder
runs-on: ubuntu-latest
outputs:
matrix: ${{ steps.set-matrix.outputs.matrix }}
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 1
- id: set-matrix
run: |
# usage: node .github/workflows/mac-runner-matrix-builder.js STRATEGY
#
# STRATEGY
# self-hosted pick the self-hosted runner configuration
# github pick the github runner configuration
# optimized pick a dc4 runner if available or fallback on github one
#
node .github/workflows/utils/mac-runner-matrix-builder.js optimized
build-macos-app:
name: Build Electron app (macOS)
needs: mac_runner_matrix_builder
runs-on: ${{ matrix.runner }}
env:
CACHE_DIRS: js/android/.gomobile-cache; js/ios/.gomobile-cache; js/ios/.xcodegen-cache
strategy:
fail-fast: false
matrix: ${{fromJson(needs.mac_runner_matrix_builder.outputs.matrix)}}
steps:
- name: Pre-checkout cleanup
if: ${{ matrix.selfhosted }}
run: |
cache_dirs=(${CACHE_DIRS//;/ })
for cache_dir in ${cache_dirs[@]}; do
if [ -d "$cache_dir" ]; then
mkdir -p "$RUNNER_TEMP/$cache_dir"
rm -rf "$RUNNER_TEMP/$cache_dir"
mv "$cache_dir" "$RUNNER_TEMP/$cache_dir"
fi
done
- name: Checkout
uses: actions/checkout@v3
- name: Post-checkout cleanup
if: ${{ matrix.selfhosted }}
run: |
cache_dirs=(${CACHE_DIRS//;/ })
for cache_dir in ${cache_dirs[@]}; do
if [ -d "$RUNNER_TEMP/$cache_dir" ]; then
mv "$RUNNER_TEMP/$cache_dir" "$cache_dir"
fi
done
- name: Load variables from file
uses: antifree/[email protected]
with:
filename: .github/workflows/utils/variables.json
- name: Setup asdf
if: ${{ !matrix.selfhosted }}
uses: asdf-vm/actions/setup@v1
- name: Setup go
run: |
asdf plugin add golang || ${{ matrix.selfhosted }}
asdf install golang
echo "go_version=$(asdf current golang | xargs | cut -d ' ' -f 2)" >> $GITHUB_ENV
- name: Setup node
run: |
asdf plugin add nodejs || ${{ matrix.selfhosted }}
asdf install nodejs
echo "node_version=$(asdf current nodejs | xargs | cut -d ' ' -f 2)" >> $GITHUB_ENV
- name: Setup yarn
run: |
asdf plugin add yarn || ${{ matrix.selfhosted }}
asdf install yarn
- name: Cache go modules
uses: actions/[email protected]
with:
path: ~/go/pkg/mod
key: ${{ runner.os }}-go-${{ env.go_version }}-${{ env.json_cache-versions_go }}-${{ hashFiles('go/**/go.sum') }}
restore-keys: ${{ runner.os }}-go-${{ env.go_version }}-${{ env.json_cache-versions_go }}-
- name: Cache node modules
uses: actions/[email protected]
with:
path: js/node_modules
key: ${{ runner.OS }}-node-${{ env.node_version }}-${{ env.json_cache-versions_node }}-${{ hashFiles('js/yarn.lock') }}
restore-keys: ${{ runner.OS }}-node-${{ env.node_version }}-${{ env.json_cache-versions_node }}-
- name: Cache web node modules
uses: actions/[email protected]
with:
path: js/web/node_modules
key: ${{ runner.OS }}-nodeweb-${{ env.node_version }}-${{ env.json_cache-versions_nodeweb }}-${{ hashFiles('js/web/yarn.lock') }}
restore-keys: ${{ runner.OS }}-nodeweb-${{ env.node_version }}-${{ env.json_cache-versions_nodeweb }}-
- name: Build berty binary
working-directory: go
run: |
touch gen.sum # avoid triggering make generate
make go.install
- name: Check go.mod and go.sum
run: |
go mod tidy -v
git --no-pager diff go.mod go.sum
git --no-pager diff --quiet go.mod go.sum
- name: Fetch node modules
working-directory: js
run: make node_modules web/node_modules
- name: Build the app (PR)
if: github.event_name == 'pull_request'
env:
CSC_IDENTITY_AUTO_DISCOVERY: false
working-directory: js
run: make electron.mac
- name: Build the app (Merge)
if: github.event_name != 'pull_request'
env:
CSC_LINK: ${{ secrets.MAC_APP_CSC_LINK }}
CSC_KEY_PASSWORD: ${{ secrets.MAC_APP_CSC_KEY_PASSWORD }}
working-directory: js
run: make electron.mac
- name: Upload the Archive
uses: actions/upload-artifact@v3
with:
path: js/web/dist/Berty.dmg
name: berty-yolo-${{github.sha}}.unsigned-dmg
if-no-files-found: error