Skip to content

Commit 0f48d32

Browse files
authored
Merge pull request #1342 from pepix/support-arm64-target
Support arm64 binary generation
2 parents 64d9833 + 40bdfe1 commit 0f48d32

File tree

6 files changed

+108
-19
lines changed

6 files changed

+108
-19
lines changed

.github/workflows/release.yml

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
name: Release executable files for macOS
2+
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
version_digit:
7+
description: 'Version digit (major | minor | patch)'
8+
required: true
9+
default: 'patch'
10+
type: choice
11+
options:
12+
- major
13+
- minor
14+
- patch
15+
16+
jobs:
17+
release:
18+
runs-on: ubuntu-latest
19+
env:
20+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
21+
HOMEBREW_TAP_DEPLOY_SECRET_KEY: ${{ secrets.HOMEBREW_TAP_DEPLOY_SECRET_KEY }}
22+
permissions: write-all
23+
steps:
24+
- name: Set up QEMU
25+
uses: docker/setup-qemu-action@v2
26+
27+
- name: Install ldid
28+
uses: MOZGIII/install-ldid-action@v1
29+
with:
30+
tag: v2.1.5-procursus6
31+
32+
- name: Check out repository code
33+
uses: actions/checkout@v3
34+
35+
- name: Use node
36+
uses: actions/setup-node@v3
37+
with:
38+
node-version: "14"
39+
40+
- name: Install dependencies
41+
run: npm install
42+
43+
- name: Build
44+
run: npm run build
45+
46+
- name: Package
47+
run: |
48+
git config --global user.email "[email protected]"
49+
git config --global user.name "GitHub Action"
50+
npm run release -- ${{ github.event.inputs.version_digit }} --ci
51+
52+
- name: Update homebrew/tap repo for new release
53+
shell: bash
54+
run: scripts/create-homebrew-tap-pr.sh
55+
env:
56+
VERSION: ${{ env.VERSION }}

.release-it.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@
33
"release": true,
44
"assets": "brew-distribution/*.zip"
55
},
6-
"buildCommand": "yarn package",
6+
"buildCommand": "yarn package:x64; yarn package:arm64",
77
"hooks": {
88
"before:bump": "yarn declarations; yarn build:schemas",
9-
"after:bump": "yarn package",
10-
"after:release": "VERSION=${version} scripts/create-homebrew-tap-pr.sh"
9+
"after:bump": "yarn package:x64; yarn package:arm64",
10+
"after:release": "export VERSION=${version}; echo 'VERSION=${version}' >> $GITHUB_ENV"
1111
}
1212
}

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@
1616

1717
<!-- Your comment below this -->
1818

19+
- Support arm64 binary generation for Apple silicon users [#1342](https://github.com/danger/danger-js/pull/1342) [@pepix]
20+
1921
<!-- Your comment above this -->
2022

2123
## 11.2.0

CONTRIBUTING.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,8 @@ Following [this commit](https://github.com/danger/danger-js/commit/a26ac3b3bd4f0
4040
- Modify `changelog.md`, adding a new `### 0.21.0` heading under the `### Main` heading at the top of the file.
4141
- Commit both changes with the commit message **Version bump**.
4242
- Tag this commit - `git tag 0.21.0`.
43-
- Push the commit and tag to master - `git push origin main --follow-tags`. Travis CI will build the tagged commit and
44-
publish that tagged version to NPM.
43+
- Push the commit and tag to master - `git push origin main --follow-tags`. GitHub Actions will build the tagged commit
44+
and publish that tagged version to NPM.
4545

4646
:ship:
4747

package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,8 @@
6565
"build:watch": "tsc -w",
6666
"link": "yarn run build && chmod +x distribution/commands/danger.js && yarn link",
6767
"package": "yarn run pkg . --output brew-distribution/danger; zip -j brew-distribution/danger-macos.zip brew-distribution/danger; shasum -a 256 brew-distribution/danger-macos.zip",
68+
"package:x64": "yarn run pkg . --output brew-distribution/danger-x64 --targets node16-macos-x64; zip -j brew-distribution/danger-macos-x64.zip brew-distribution/danger-x64; shasum -a 256 brew-distribution/danger-macos-x64.zip",
69+
"package:arm64": "yarn run pkg . --output brew-distribution/danger-arm64 --targets node16-macos-arm64; zip -j brew-distribution/danger-macos-arm64.zip brew-distribution/danger-arm64; shasum -a 256 brew-distribution/danger-macos-arm64.zip",
6870
"declarations": "ts-node ./scripts/create-danger-dts.ts",
6971
"docs:cp_defs": "mkdir docs/docs_generate; cp source/danger.d.ts docs/docs_generate; cp node_modules/@octokit/rest/index.d.ts docs/docs_generate/github.d.ts",
7072
"docs": "yarn run docs:cp_defs; yarn typedoc --ignoreCompilerErrors --mode modules --json docs/js_ref_dsl_docs.json --includeDeclarations source",

scripts/create-homebrew-tap-pr.sh

Lines changed: 43 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2,36 +2,65 @@
22

33
[ -z ${VERSION+x} ] && { echo "VERSION is missing"; exit 1; }
44

5-
FILE=brew-distribution/danger-macos.zip
5+
FILE_X64=brew-distribution/danger-macos-x64.zip
6+
FILE_ARM64=brew-distribution/danger-macos-arm64.zip
67

7-
if [ ! -f ${FILE} ]; then
8-
echo ${FILE} not found!
8+
if [ ! -f ${FILE_X64} ]; then
9+
echo ${FILE_X64} not found!
10+
exit 1
11+
fi
12+
if [ ! -f ${FILE_ARM64} ]; then
13+
echo ${FILE_ARM64} not found!
914
exit 1
1015
fi
1116

12-
SHA=$(shasum -a 256 ${FILE} | cut -f 1 -d " ")
13-
echo "$SHA"
17+
SHA_X64=$(shasum -a 256 ${FILE_X64} | cut -f 1 -d " ")
18+
echo "SHA_X64=$SHA_X64"
19+
SHA_ARM64=$(shasum -a 256 ${FILE_ARM64} | cut -f 1 -d " ")
20+
echo "SHA_ARM64=$SHA_ARM64"
21+
22+
# Set up SSH
23+
mkdir -p ~/.ssh
24+
echo "${HOMEBREW_TAP_DEPLOY_SECRET_KEY}" > ~/.ssh/id_rsa
25+
chmod 600 ~/.ssh/id_rsa
26+
git config --global user.name danger
27+
git config --global user.email [email protected]
28+
eval "$(ssh-agent -s)"
29+
ssh-add ~/.ssh/id_rsa
30+
ssh-keyscan -H github.com >> ~/.ssh/known_hosts
31+
ssh -o StrictHostKeyChecking=no -F /dev/null -vT [email protected]
1432

1533
# Clone tap repo
1634
HOMEBREW_TAP_TMPDIR=$(mktemp -d)
17-
git clone --depth 1 https://github.com/danger/homebrew-tap.git "$HOMEBREW_TAP_TMPDIR"
35+
git clone --depth 1 git@github.com:danger/homebrew-tap.git "$HOMEBREW_TAP_TMPDIR"
1836
cd "$HOMEBREW_TAP_TMPDIR" || exit 1
1937

20-
# git config user.name danger
21-
# git config user.email [email protected]
22-
2338
# Write formula
2439
echo "class DangerJs < Formula" > danger-js.rb
2540
echo " homepage \"https://github.com/danger/danger-js\"" >> danger-js.rb
26-
echo " url \"https://github.com/danger/danger-js/releases/download/${VERSION}/danger-macos.zip\"" >> danger-js.rb
27-
echo " sha256 \"${SHA}\"" >> danger-js.rb
2841
echo >> danger-js.rb
29-
echo " def install" >> danger-js.rb
30-
echo " bin.install \"danger\"" >> danger-js.rb
42+
echo " if Hardware::CPU.intel?" >> danger-js.rb
43+
echo " url \"https://github.com/danger/danger-js/releases/download/${VERSION}/danger-macos-x64.zip\"" >> danger-js.rb
44+
echo " sha256 \"${SHA_X64}\"" >> danger-js.rb
45+
echo >> danger-js.rb
46+
echo " def install" >> danger-js.rb
47+
echo " bin.install \"danger-x64\" => \"danger\"" >> danger-js.rb
48+
echo " end" >> danger-js.rb
49+
echo " end" >> danger-js.rb
50+
echo >> danger-js.rb
51+
echo " if Hardware::CPU.arm?" >> danger-js.rb
52+
echo " url \"https://github.com/danger/danger-js/releases/download/${VERSION}/danger-macos-arm64.zip\"" >> danger-js.rb
53+
echo " sha256 \"${SHA_ARM64}\"" >> danger-js.rb
54+
echo >> danger-js.rb
55+
echo " def install" >> danger-js.rb
56+
echo " bin.install \"danger-arm64\" => \"danger\"" >> danger-js.rb
57+
echo " end" >> danger-js.rb
3158
echo " end" >> danger-js.rb
3259
echo "end" >> danger-js.rb
3360

3461
# Commit changes
3562
git add danger-js.rb
3663
git commit -m "Releasing danger-js version ${VERSION}"
37-
git push origin master
64+
git remote rm origin
65+
git remote add origin [email protected]:danger/homebrew-tap.git
66+
git push origin master

0 commit comments

Comments
 (0)