Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Package by pr comment and update @electron/notarize to 2.0.0 #2750

Merged
merged 3 commits into from
Jun 30, 2023
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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:
Keith-CY marked this conversation as resolved.
Show resolved Hide resolved

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
10 changes: 6 additions & 4 deletions packages/neuron-wallet/scripts/notarize.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,10 @@ exports.default = async function notarizing(context) {

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)
}

Expand All @@ -27,8 +28,9 @@ exports.default = async function notarizing(context) {
await notarize({
appBundleId: 'com.nervos.neuron',
appPath: `${appOutDir}/${appName}.app`,
appleId: appleId,
appleIdPassword: appleIdPassword,
appleId,
appleIdPassword,
teamId,
})
console.info("Notarization finished")
} catch (err) {
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
Loading