Skip to content

Commit

Permalink
Add a new workflow to build binaries for macOS architectres on GitHub…
Browse files Browse the repository at this point in the history
… Actions
  • Loading branch information
pepix committed Dec 23, 2022
1 parent 4efada7 commit 40bdfe1
Show file tree
Hide file tree
Showing 4 changed files with 73 additions and 6 deletions.
56 changes: 56 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
name: Release executable files for macOS

on:
workflow_dispatch:
inputs:
version_digit:
description: 'Version digit (major | minor | patch)'
required: true
default: 'patch'
type: choice
options:
- major
- minor
- patch

jobs:
release:
runs-on: ubuntu-latest
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
HOMEBREW_TAP_DEPLOY_SECRET_KEY: ${{ secrets.HOMEBREW_TAP_DEPLOY_SECRET_KEY }}
permissions: write-all
steps:
- name: Set up QEMU
uses: docker/setup-qemu-action@v2

- name: Install ldid
uses: MOZGIII/install-ldid-action@v1
with:
tag: v2.1.5-procursus6

- name: Check out repository code
uses: actions/checkout@v3

- name: Use node
uses: actions/setup-node@v3
with:
node-version: "14"

- name: Install dependencies
run: npm install

- name: Build
run: npm run build

- name: Package
run: |
git config --global user.email "[email protected]"
git config --global user.name "GitHub Action"
npm run release -- ${{ github.event.inputs.version_digit }} --ci
- name: Update homebrew/tap repo for new release
shell: bash
run: scripts/create-homebrew-tap-pr.sh
env:
VERSION: ${{ env.VERSION }}
2 changes: 1 addition & 1 deletion .release-it.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@
"hooks": {
"before:bump": "yarn declarations; yarn build:schemas",
"after:bump": "yarn package:x64; yarn package:arm64",
"after:release": "VERSION=${version} scripts/create-homebrew-tap-pr.sh"
"after:release": "export VERSION=${version}; echo 'VERSION=${version}' >> $GITHUB_ENV"
}
}
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@
"build:pretty-types": "yarn prettier --write distribution/danger.d.ts; yarn prettier --parser flow distribution/danger.js.flow --write",
"build:watch": "tsc -w",
"link": "yarn run build && chmod +x distribution/commands/danger.js && yarn link",
"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",
"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",
"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",
"declarations": "ts-node ./scripts/create-danger-dts.ts",
Expand Down
20 changes: 15 additions & 5 deletions scripts/create-homebrew-tap-pr.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,22 @@ echo "SHA_X64=$SHA_X64"
SHA_ARM64=$(shasum -a 256 ${FILE_ARM64} | cut -f 1 -d " ")
echo "SHA_ARM64=$SHA_ARM64"

# Set up SSH
mkdir -p ~/.ssh
echo "${HOMEBREW_TAP_DEPLOY_SECRET_KEY}" > ~/.ssh/id_rsa
chmod 600 ~/.ssh/id_rsa
git config --global user.name danger
git config --global user.email [email protected]
eval "$(ssh-agent -s)"
ssh-add ~/.ssh/id_rsa
ssh-keyscan -H github.com >> ~/.ssh/known_hosts
ssh -o StrictHostKeyChecking=no -F /dev/null -vT [email protected]

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

# git config user.name danger
# git config user.email [email protected]

# Write formula
echo "class DangerJs < Formula" > danger-js.rb
echo " homepage \"https://github.com/danger/danger-js\"" >> danger-js.rb
Expand All @@ -53,4 +61,6 @@ echo "end" >> danger-js.rb
# Commit changes
git add danger-js.rb
git commit -m "Releasing danger-js version ${VERSION}"
git push origin master
git remote rm origin
git remote add origin [email protected]:danger/homebrew-tap.git
git push origin master

0 comments on commit 40bdfe1

Please sign in to comment.