Skip to content

Commit 40bdfe1

Browse files
committedDec 23, 2022
Add a new workflow to build binaries for macOS architectres on GitHub Actions
1 parent 4efada7 commit 40bdfe1

File tree

4 files changed

+73
-6
lines changed

4 files changed

+73
-6
lines changed
 

‎.github/workflows/release.yml

+56
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 "action@github.com"
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

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,6 @@
77
"hooks": {
88
"before:bump": "yarn declarations; yarn build:schemas",
99
"after:bump": "yarn package:x64; yarn package:arm64",
10-
"after:release": "VERSION=${version} scripts/create-homebrew-tap-pr.sh"
10+
"after:release": "export VERSION=${version}; echo 'VERSION=${version}' >> $GITHUB_ENV"
1111
}
1212
}

‎package.json

+1
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@
6464
"build:pretty-types": "yarn prettier --write distribution/danger.d.ts; yarn prettier --parser flow distribution/danger.js.flow --write",
6565
"build:watch": "tsc -w",
6666
"link": "yarn run build && chmod +x distribution/commands/danger.js && yarn link",
67+
"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",
6768
"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",
6869
"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",
6970
"declarations": "ts-node ./scripts/create-danger-dts.ts",

‎scripts/create-homebrew-tap-pr.sh

+15-5
Original file line numberDiff line numberDiff line change
@@ -19,14 +19,22 @@ echo "SHA_X64=$SHA_X64"
1919
SHA_ARM64=$(shasum -a 256 ${FILE_ARM64} | cut -f 1 -d " ")
2020
echo "SHA_ARM64=$SHA_ARM64"
2121

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 danger@users.noreply.github.com
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 git@github.com
32+
2233
# Clone tap repo
2334
HOMEBREW_TAP_TMPDIR=$(mktemp -d)
24-
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"
2536
cd "$HOMEBREW_TAP_TMPDIR" || exit 1
2637

27-
# git config user.name danger
28-
# git config user.email danger@users.noreply.github.com
29-
3038
# Write formula
3139
echo "class DangerJs < Formula" > danger-js.rb
3240
echo " homepage \"https://github.com/danger/danger-js\"" >> danger-js.rb
@@ -53,4 +61,6 @@ echo "end" >> danger-js.rb
5361
# Commit changes
5462
git add danger-js.rb
5563
git commit -m "Releasing danger-js version ${VERSION}"
56-
git push origin master
64+
git remote rm origin
65+
git remote add origin git@github.com:danger/homebrew-tap.git
66+
git push origin master

0 commit comments

Comments
 (0)
Please sign in to comment.