Skip to content

Commit

Permalink
Package by pr comment and update @electron/notarize to 2.0.0 (#2750)
Browse files Browse the repository at this point in the history
* chore(CI): Use comment command to package

* feat: update notarize to 2.0.0

* chore: prettier notarize.js
  • Loading branch information
yanguoyu authored Jun 30, 2023
1 parent 6e00509 commit b4f7de2
Show file tree
Hide file tree
Showing 5 changed files with 74 additions and 83 deletions.
43 changes: 0 additions & 43 deletions .github/workflows/comment_for_pr_package.yml

This file was deleted.

84 changes: 58 additions & 26 deletions .github/workflows/package_for_test.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,31 @@
name: Package Neuron for Test

on:
pull_request:
on:
issue_comment:
types: [created, edited]
push:

jobs:
check_command:
runs-on: ubuntu-latest
## skip if trigger by issue comment but not pr comment
if: ${{ (github.event_name == 'issue_comment' && github.event.issue.pull_request) || github.event_name == 'push' }}
permissions:
pull-requests: write
steps:
- name: Check for package command
uses: xt0rted/slash-command-action@v1
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}
command: package
reaction: "true"
reaction-type: "eyes"
allow-edits: "true"
permission-level: write

packaging:
needs: [check_command]

strategy:
matrix:
node:
Expand All @@ -18,6 +38,7 @@ jobs:
runs-on: ${{ matrix.os }}

name: ${{ matrix.os }}(Node.js ${{ matrix.node }})

env:
MAC_SHOULD_CODE_SIGN: ${{ github.event_name != 'pull_request' && secrets.APPLE_ID != '' }}
WIN_CERTIFICATE_BASE64: ${{ secrets.WIN_CERTIFICATE_BASE64 }}
Expand All @@ -28,8 +49,17 @@ jobs:
git config --global core.autocrlf false
git config --global core.eol lf
- name: Get PR Branch
if: github.event_name == 'issue_comment'
id: comment-branch
uses: xt0rted/pull-request-comment-branch@v1
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}

- name: Checkout
uses: actions/checkout@v3
with:
ref: ${{ steps.comment-branch.outputs.ref }}

- name: Setup Node
uses: actions/setup-node@v3
Expand Down Expand Up @@ -160,35 +190,37 @@ jobs:
name: Neuron-Linux
path: release/Neuron-*.AppImage

cache-package-info:
comment_when_package_success:
needs: [packaging]
if: ${{ github.event_name == 'pull_request' }}
name: Append links to the Pull Request
runs-on: ubuntu-latest
steps:
- name: Save PR number and run id
env:
PR_NUMBER: ${{ github.event.number }}
RUN_ID: ${{ github.run_id }}
SHA: ${{ github.event.pull_request.head.sha }}
run: |
mkdir -p ./package_info
echo $PR_NUMBER > ./package_info/pr_number
echo $RUN_ID > ./package_info/run_id
echo $SHA > ./package_info/sha
- uses: actions/upload-artifact@v3
- name: Comment by push event
if: ${{ github.event_name == 'push' }}
uses: peter-evans/commit-comment@v2
with:
body: |
Packaging for test is done in [${{ github.run_id }}](https://github.com/${{github.repository}}/actions/runs/${{github.run_id}})
- name: Comment by pull request comment event
if: ${{ github.event_name == 'issue_comment' }}
uses: peter-evans/create-or-update-comment@v3
with:
name: package_info
path: package_info/
retention-days: 3
comment:
comment-id: ${{ github.event.comment.id }}
body: |
Packaging for test is done in [${{ github.run_id }}](https://github.com/${{github.repository}}/actions/runs/${{github.run_id}}). @${{ github.event.comment.user.login }}
edit-mode: append

comment_when_package_failed:
needs: [packaging]
# During a pull_request event triggered by a forked repository, actions have no write access to GitHub resources and will fail on any attempt.
# ref https://github.com/peter-evans/create-pull-request/blob/main/docs/concepts-guidelines.md#restrictions-on-repository-forks
if: ${{ github.event_name == 'push' }}
name: Append links to the Pull Request
if: ${{ always() && needs.packaging.result == 'failure' }}
name: Append failed comment to the comment
runs-on: ubuntu-latest
steps:
- uses: peter-evans/commit-comment@v2
- name: Comment by pull request comment event when package failed
if: ${{ github.event_name == 'issue_comment' }}
uses: peter-evans/create-or-update-comment@v3
with:
body: |
Packaging for test is done in [${{ github.run_id }}](https://github.com/${{github.repository}}/actions/runs/${{github.run_id}})
comment-id: ${{ github.event.comment.id }}
body: Packageing failed in [${{ github.run_id }}](https://github.com/${{github.repository}}/actions/runs/${{github.run_id}}). @${{ github.event.comment.user.login }}
edit-mode: append
2 changes: 1 addition & 1 deletion packages/neuron-wallet/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@
"uuid": "8.3.2"
},
"devDependencies": {
"@electron/notarize": "1.2.4",
"@electron/notarize": "2.0.0",
"@nervosnetwork/ckb-types": "0.109.0",
"@types/archiver": "3.1.1",
"@types/async": "3.2.20",
Expand Down
20 changes: 11 additions & 9 deletions packages/neuron-wallet/scripts/notarize.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
const { notarize } = require('@electron/notarize')

exports.default = async function notarizing(context) {
const { electronPlatformName, appOutDir } = context;
const { electronPlatformName, appOutDir } = context
if (electronPlatformName !== 'darwin') {
return
}
Expand All @@ -11,26 +11,28 @@ exports.default = async function notarizing(context) {
return Promise.resolve('skip')
}

const appleId = process.env.APPLE_ID;
const appleIdPassword = process.env.APPLE_ID_PASSWORD;
const appleId = process.env.APPLE_ID
const appleIdPassword = process.env.APPLE_ID_PASSWORD
const teamId = process.env.TEAM_ID

if (!appleId || !appleIdPassword) {
console.warn(`${appleId ? "Apple id password" : "Apple id"} is not found`)
if (!appleId || !appleIdPassword || !teamId) {
console.warn(`${appleId ? (appleIdPassword ? 'Team id' : 'Apple id password') : 'Apple id'} is not found`)
process.exit(1)
}

const appName = context.packager.appInfo.productFilename

console.info("Notarization started")
console.info('Notarization started')

try {
await notarize({
appBundleId: 'com.nervos.neuron',
appPath: `${appOutDir}/${appName}.app`,
appleId: appleId,
appleIdPassword: appleIdPassword,
appleId,
appleIdPassword,
teamId,
})
console.info("Notarization finished")
console.info('Notarization finished')
} catch (err) {
console.error(err)
process.exit(1)
Expand Down
8 changes: 4 additions & 4 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1650,10 +1650,10 @@
optionalDependencies:
global-agent "^3.0.0"

"@electron/notarize@1.2.4":
version "1.2.4"
resolved "https://registry.yarnpkg.com/@electron/notarize/-/notarize-1.2.4.tgz#a7d38773f4cad40df111a5edc64037e5d768ea1e"
integrity sha512-W5GQhJEosFNafewnS28d3bpQ37/s91CDWqxVchHfmv2dQSTWpOzNlUVQwYzC1ay5bChRV/A9BTL68yj0Pa+TSg==
"@electron/notarize@2.0.0":
version "2.0.0"
resolved "https://registry.yarnpkg.com/@electron/notarize/-/notarize-2.0.0.tgz#4df39e817264746aa9bd779e0091b6c441715b72"
integrity sha512-dqDpd2YCgl6PHJgXEuKGYH3+L4GIGV7ZbKYJjJv66ed+hVPxZA+GAL5JH8/hCnoyQa8WzJTzqd+qhiL5Oxr+SA==
dependencies:
debug "^4.1.1"
fs-extra "^9.0.1"
Expand Down

0 comments on commit b4f7de2

Please sign in to comment.