Skip to content

Commit 3924ed6

Browse files
committed
chore: update
1 parent 9293cc4 commit 3924ed6

File tree

1 file changed

+278
-0
lines changed

1 file changed

+278
-0
lines changed
Lines changed: 278 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,278 @@
1+
name: Package Neuron for Test
2+
3+
on:
4+
issue_comment:
5+
types: [created]
6+
push:
7+
8+
jobs:
9+
packaging:
10+
if: ${{ (github.event_name == 'issue_comment' && github.event.issue.pull_request && startsWith(github.event.comment.body, '/package') && contains(fromJSON('["OWNER", "COLLABORATOR"]'), github.event.comment.author_association)) || github.event_name == 'push' }}
11+
12+
strategy:
13+
matrix:
14+
node: [22]
15+
os:
16+
- ubuntu-latest
17+
18+
runs-on: ${{ matrix.os }}
19+
permissions:
20+
contents: read
21+
pull-requests: read
22+
23+
name: ${{ matrix.os }}(Node.js ${{ matrix.node }})
24+
25+
env:
26+
MAC_SHOULD_CODE_SIGN: ${{ github.event_name != 'pull_request' && secrets.APPLE_ID != '' }}
27+
WIN_CERTIFICATE_BASE64: ${{ secrets.WIN_CERTIFICATE_BASE64 }}
28+
29+
steps:
30+
- name: Set git to use LF
31+
run: |
32+
git config --global core.autocrlf false
33+
git config --global core.eol lf
34+
35+
- name: Checkout for push
36+
uses: actions/checkout@v4
37+
if: ${{ github.event_name == 'push' }}
38+
39+
- name: Checkout for PR
40+
uses: actions/checkout@v4
41+
if: ${{ github.event_name == 'issue_comment' }}
42+
with:
43+
ref: refs/pull/${{ github.event.issue.number }}/merge
44+
45+
- name: Ensure no more commits after the triggering comment
46+
uses: actions/github-script@v7
47+
if: ${{ github.event_name == 'issue_comment' }}
48+
env:
49+
ISSUE_NUMBER: ${{github.event.issue.number}}
50+
COMMENT_ID: ${{ github.event.comment.id }}
51+
with:
52+
script: |
53+
const { ISSUE_NUMBER, COMMENT_ID } = process.env
54+
let page = 1
55+
let hasFoundComment = false
56+
while(true) {
57+
const { data: timelines } = await github.rest.issues.listEventsForTimeline({
58+
owner: context.repo.owner,
59+
repo: context.repo.repo,
60+
issue_number: ISSUE_NUMBER,
61+
page,
62+
per_page: 100,
63+
})
64+
if (timelines.some(v => {
65+
hasFoundComment = hasFoundComment || (v.event === 'commented' && `${v.id}` === `${COMMENT_ID}`)
66+
return hasFoundComment && v.event === 'committed'
67+
})) {
68+
throw new Error('The last commit comes after the comment, please comment and package after last commit')
69+
}
70+
if (timelines.length === 0) {
71+
return
72+
}
73+
page += 1
74+
}
75+
76+
- name: Setup Node
77+
uses: actions/setup-node@v4
78+
with:
79+
node-version: ${{ matrix.node }}
80+
cache: "yarn"
81+
82+
- name: Restore
83+
uses: actions/cache@v4
84+
with:
85+
path: |
86+
node_modules
87+
*/*/node_modules
88+
key: 2022-12-21-${{ runner.os }}-${{ hashFiles('**/yarn.lock')}}
89+
90+
- name: Add msbuild to PATH
91+
if: runner.os == 'Windows'
92+
uses: microsoft/setup-msbuild@v2
93+
env:
94+
ACTIONS_ALLOW_UNSECURE_COMMANDS: "true"
95+
96+
- name: Setup Certificate
97+
if: runner.os == 'Windows'
98+
run: |
99+
echo "${{ secrets.SM_CLIENT_CERT_FILE_BASE64 }}" | base64 --decode > /d/Certificate_pkcs12.p12
100+
shell: bash
101+
102+
- name: Set variables
103+
if: runner.os == 'Windows'
104+
run: |
105+
echo "SM_KEYPAIR_NAME=${{ secrets.SM_KEYPAIR_ALIAS }}" >> "$GITHUB_ENV"
106+
echo "SM_HOST=${{ secrets.SM_HOST }}" >> "$GITHUB_ENV"
107+
echo "SM_API_KEY=${{ secrets.SM_API_KEY }}" >> "$GITHUB_ENV"
108+
echo "SM_CLIENT_CERT_FILE=D:\\Certificate_pkcs12.p12" >> "$GITHUB_ENV"
109+
echo "SM_CLIENT_CERT_PASSWORD=${{ secrets.SM_CLIENT_CERT_PASSWORD }}" >> "$GITHUB_ENV"
110+
echo "C:\Program Files (x86)\Windows Kits\10\App Certification Kit" >> $GITHUB_PATH
111+
echo "C:\Program Files (x86)\Microsoft SDKs\Windows\v10.0A\bin\NETFX 4.8 Tools" >> $GITHUB_PATH
112+
echo "C:\Program Files\DigiCert\DigiCert One Signing Manager Tools" >> $GITHUB_PATH
113+
shell: bash
114+
115+
- name: Setting up the client tools
116+
if: ${{ runner.os == 'Windows' && env.SM_API_KEY != '' }}
117+
run: |
118+
curl -X GET https://one.digicert.com/signingmanager/api-ui/v1/releases/smtools-windows-x64.msi/download -H "x-api-key:%SM_API_KEY%" -o smtools-windows-x64.msi
119+
msiexec /i smtools-windows-x64.msi /quiet /qn
120+
C:\Windows\System32\certutil.exe -csp "DigiCert Signing Manager KSP" -key -user
121+
shell: cmd
122+
123+
- name: Certificates Sync
124+
if: ${{ runner.os == 'Windows' && env.SM_API_KEY != '' }}
125+
run: |
126+
smctl windows certsync
127+
smctl kp ls
128+
smctl cert ls
129+
shell: cmd
130+
131+
- name: Install Linux Dependencies
132+
if: runner.os == 'Linux'
133+
run: |
134+
sudo apt-get update
135+
sudo apt-get install -y libudev-dev libusb-1.0-0-dev
136+
137+
- name: Install Lerna
138+
run: yarn global add lerna
139+
140+
- name: Bootstrap
141+
run: |
142+
yarn
143+
env:
144+
CI: false
145+
146+
- name: Write electron-build Test yml
147+
uses: actions/github-script@v7
148+
with:
149+
script: |
150+
const fs = require('node:fs')
151+
const ympPath = 'packages/neuron-wallet/electron-builder.yml'
152+
fs.writeFileSync(ympPath, fs.readFileSync(ympPath).toString().replace('asar: true', 'asar: false'))
153+
154+
- name: Package for MacOS
155+
if: ${{ runner.os == 'macOS' && env.MAC_SHOULD_CODE_SIGN == 'true' }}
156+
run: |
157+
./scripts/download-ckb.sh mac
158+
yarn package:test mac
159+
env:
160+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
161+
APPLE_ID: ${{ secrets.APPLE_ID }}
162+
APPLE_ID_PASSWORD: ${{ secrets.APPLE_ID_PASSWORD }}
163+
CSC_LINK: ${{ secrets.MAC_CERTIFICATE_BASE64 }}
164+
CSC_KEY_PASSWORD: ${{ secrets.MAC_CERTIFICATE_PASSWORD }}
165+
TEAM_ID: ${{ secrets.TEAM_ID }}
166+
USE_HARD_LINKS: false
167+
168+
- name: Package for MacOS for skip code sign
169+
if: ${{ runner.os == 'macOS' && env.MAC_SHOULD_CODE_SIGN == 'false' }}
170+
run: |
171+
export CSC_IDENTITY_AUTO_DISCOVERY=false
172+
./scripts/download-ckb.sh mac
173+
yarn package:test mac
174+
env:
175+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
176+
SKIP_NOTARIZE: true
177+
USE_HARD_LINKS: false
178+
179+
- name: Package for Windows
180+
if: runner.os == 'Windows'
181+
run: |
182+
bash ./scripts/download-ckb.sh win
183+
yarn build
184+
bash ./scripts/copy-ui-files.sh
185+
bash ./scripts/package-for-test.sh win
186+
env:
187+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
188+
189+
- name: Package for Linux
190+
if: runner.os == 'Linux'
191+
run: |
192+
./scripts/download-ckb.sh
193+
yarn package:test linux
194+
env:
195+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
196+
USE_HARD_LINKS: false
197+
198+
- name: Upload Neuron App Zip
199+
if: runner.os == 'macOS'
200+
uses: actions/upload-artifact@v4
201+
with:
202+
name: Neuron-Mac-x64
203+
path: release/Neuron-*-mac-x64.zip
204+
205+
- name: Upload Neuron App Zip(arm64)
206+
if: runner.os == 'macOS'
207+
uses: actions/upload-artifact@v4
208+
with:
209+
name: Neuron-Mac-arm64
210+
path: release/Neuron-*-mac-arm64.zip
211+
212+
- name: Upload Neuron Dmg
213+
if: runner.os == 'macOS'
214+
uses: actions/upload-artifact@v4
215+
with:
216+
name: Neuron-Dmg-x64
217+
path: release/Neuron-*-x64.dmg
218+
219+
- name: Upload Neuron Dmg(arm64)
220+
if: runner.os == 'macOS'
221+
uses: actions/upload-artifact@v4
222+
with:
223+
name: Neuron-Dmg-arm64
224+
path: release/Neuron-*-arm64.dmg
225+
226+
- name: Upload Neuron Win
227+
if: runner.os == 'Windows'
228+
uses: actions/upload-artifact@v4
229+
with:
230+
name: Neuron-Win
231+
path: release/Neuron-*-setup.exe
232+
233+
- name: Upload Neuron Linux
234+
if: runner.os == 'Linux'
235+
uses: actions/upload-artifact@v4
236+
with:
237+
name: Neuron-Linux
238+
path: release/Neuron-*.AppImage
239+
240+
comment_when_package_success:
241+
needs: [packaging]
242+
name: Append links to the Pull Request
243+
runs-on: ubuntu-latest
244+
permissions:
245+
pull-requests: write
246+
contents: write
247+
steps:
248+
- name: Comment by push event
249+
if: ${{ github.event_name == 'push' }}
250+
uses: peter-evans/commit-comment@v3
251+
with:
252+
body: |
253+
Packaging for test is done in [${{ github.run_id }}](https://github.com/${{github.repository}}/actions/runs/${{github.run_id}})
254+
255+
- name: Comment by pull request comment event
256+
if: ${{ github.event_name == 'issue_comment' }}
257+
uses: peter-evans/create-or-update-comment@v4
258+
with:
259+
comment-id: ${{ github.event.comment.id }}
260+
body: |
261+
Packaging for test is done in [${{ github.run_id }}](https://github.com/${{github.repository}}/actions/runs/${{github.run_id}}). @${{ github.event.comment.user.login }}
262+
edit-mode: append
263+
264+
comment_when_package_failed:
265+
needs: [packaging]
266+
if: ${{ always() && needs.packaging.result == 'failure' }}
267+
name: Append failed comment to the comment
268+
runs-on: ubuntu-latest
269+
permissions:
270+
pull-requests: write
271+
steps:
272+
- name: Comment by pull request comment event when package failed
273+
if: ${{ github.event_name == 'issue_comment' }}
274+
uses: peter-evans/create-or-update-comment@v4
275+
with:
276+
comment-id: ${{ github.event.comment.id }}
277+
body: Packageing failed in [${{ github.run_id }}](https://github.com/${{github.repository}}/actions/runs/${{github.run_id}}). @${{ github.event.comment.user.login }}
278+
edit-mode: append

0 commit comments

Comments
 (0)