-
Notifications
You must be signed in to change notification settings - Fork 7
171 lines (142 loc) · 5.88 KB
/
ci.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
name: Build release
on:
pull_request:
types:
- closed
jobs:
build-macos:
runs-on: macos-latest
if: github.event.pull_request.merged == true
env:
CERTIFICATE: ${{ secrets.PROD_MACOS_CERTIFICATE }}
CERTIFICATE_PWD: ${{ secrets.PROD_MACOS_CERTIFICATE_PWD }}
CERTIFICATE_CHECKSUM: ${{ secrets.PROD_MACOS_CERTIFICATE_CHECKSUM }}
KEYCHAIN_NAME: "build.keychain"
KEYCHAIN_PATH: "/Users/runner/Library/Keychains/"
KEYCHAIN_PWD: ${{ secrets.PROD_MACOS_CI_KEYCHAIN_PWD }}
APPLE_ID: ${{ secrets.PROD_MACOS_NOTARIZATION_APPLE_ID }}
APPLE_TEAM_ID: ${{ secrets.PROD_MACOS_NOTARIZATION_TEAM_ID }}
APPLE_APP_SPECIFIC_PASSWORD: ${{ secrets.PROD_MACOS_NOTARIZATION_PWD }}
NOTARYTOOL_PROFILE: "notarytool-profile"
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Setup Node.js
uses: actions/setup-node@v2
with:
node-version: '18.14.0'
- name: Install dependencies
run: npm install
- name: Test ubuntu
if: ${{ matrix.os }} == 'ubuntu-latest'
run: |
echo "I am running only on ${{ matrix.os }}"
- name: Decode Apple Developer certificate
run: |
echo ${{ env.CERTIFICATE }} | base64 --decode > certificate.p12
ls -la certificate*
diff <( printf '%s\n' "${{ env.CERTIFICATE_CHECKSUM }}" ) <( printf '%s\n' "$(md5 -q certificate.p12)")
[ $? -eq 0 ] && (echo "File is identical" && exit 0) || (echo "File is different" && exit 1)
- name: Create keychain storage
run: |
security create-keychain -p "${{ env.KEYCHAIN_PWD }}" ${{env.KEYCHAIN_NAME}}
security default-keychain -s ${{ env.KEYCHAIN_NAME }}
security unlock-keychain -p "${{ env.KEYCHAIN_PWD }}" ${{ env.KEYCHAIN_NAME }}
security import certificate.p12 -k ${{ env.KEYCHAIN_NAME }} -P "${{ env.CERTIFICATE_PWD }}" -T /usr/bin/codesign
security set-key-partition-list -S apple-tool:,apple:,codesign: -s -k "${{ env.KEYCHAIN_PWD }}" ${{ env.KEYCHAIN_NAME }}
- name: Create keychain profile for notarytool
run: |
security unlock-keychain -p "${{ env.KEYCHAIN_PWD }}" ${{ env.KEYCHAIN_NAME }}
xcrun notarytool store-credentials ${{ env.NOTARYTOOL_PROFILE }} \
--apple-id ${{ env.APPLE_ID }} \
--team-id ${{ env.APPLE_TEAM_ID }} \
--password "${{ env.APPLE_APP_SPECIFIC_PASSWORD }}" \
--keychain "${{ env.KEYCHAIN_PATH }}${{ env.KEYCHAIN_NAME }}-db"
- name: Build the artifacts and upload them on Github
env:
KEYCHAIN: "${{ env.KEYCHAIN_PATH }}${{ env.KEYCHAIN_NAME }}-db"
KEYCHAIN_PROFILE: ${{ env.NOTARYTOOL_PROFILE }}
GH_TOKEN: ${{ github.token }}
run: |
npm run ship -- --mac --universal
build-windows:
runs-on: windows-latest
if: github.event.pull_request.merged == true
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Setup Node.js
uses: actions/setup-node@v2
with:
node-version: '18.14.0'
- name: Install dependencies
run: npm install
- name: Build the artifacts and upload them on Github
env:
GH_TOKEN: ${{ github.token }}
run: |
npm run ship -- --windows
build-linux:
runs-on: ubuntu-latest
if: github.event.pull_request.merged == true
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Setup Node.js
uses: actions/setup-node@v2
with:
node-version: '18.14.0'
- name: Install dependencies
run: npm install
- name: Build the artifacts and upload them on Github
env:
GH_TOKEN: ${{ github.token }}
run: |
npm run ship -- --linux
clean-release:
needs: [build-macos, build-windows, build-linux]
runs-on: ubuntu-latest
steps:
- name: Get the release data
id: releases_data
env:
HOST: "https://api.github.com"
ENDPOINT: "/repos/${{ github.event.repository.owner.name }}/${{ github.event.repository.name }}/releases"
run: |
data=$(
curl -X GET -s \
-H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \
"${HOST}${ENDPOINT}"
)
data=$(echo "${data}" | jq '.[0] | {name, id, assets: (.assets | map({name, id}))} | tostring')
echo "release_data=${data}" >> $GITHUB_OUTPUT
- name: Read the output
run: |
echo ${{ steps.releases_data.outputs.release_data }} | jq '.'
- name: Filter requested data
id: jq_filter
run: |
blockmaps=$(
echo '${{ steps.releases_data.outputs.release_data }}' | jq -r \
'fromjson | .assets | map(select(.name | endswith(".blockmap"))) | map(.id | tostring) | join(" ")'
)
echo "( ${blockmaps} )"
echo "blockmap_list=( ${blockmaps} )" >> $GITHUB_OUTPUT
- name: Remove the blockmap files
env:
HOST: "https://api.github.com"
ENDPOINT: "/repos/${{ github.event.repository.owner.name }}/${{ github.event.repository.name }}/releases/assets/"
run: |
assets_array="${{ steps.jq_filter.outputs.blockmap_list }}"
assets_array="${assets_array#(}"
assets_array="${assets_array%)}"
# Convert the array string to an actual array
IFS=', ' read -ra assets <<< "$assets_array"
# Iterate over the array elements
echo "Iterating over the assets:"
for asset_id in "${assets[@]}"; do
echo "Deleting asset with ID: $asset_id"
curl -X DELETE -s \
-H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \
"${HOST}${ENDPOINT}$asset_id"
done