Skip to content

Commit

Permalink
chore(ci): update cd workflows for arm64 (#1838)
Browse files Browse the repository at this point in the history
## Problem

Currently we only deploy amd64 badger CLI tool builds. We would like
arm64 builds too.

## Solution

Use an arm64 self-hosted runner to build arm64 badger CLI tool.
  • Loading branch information
joshua-goldstein authored Dec 15, 2022
1 parent 1d0ae37 commit a717126
Show file tree
Hide file tree
Showing 3 changed files with 92 additions and 1 deletion.
43 changes: 42 additions & 1 deletion .github/workflows/cd-badger.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name: cd-badger
on: workflow_dispatch
jobs:
badger-build:
badger-build-amd64:
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v3
Expand Down Expand Up @@ -42,3 +42,44 @@ jobs:
path: |
badger/badger-checksum-linux-amd64.sha256
badger/badger-linux-amd64.tar.gz
badger-build-arm64:
runs-on: [self-hosted, ARM64]
steps:
- uses: actions/checkout@v3
- name: Get Go Version
run: |
#!/bin/bash
GOVERSION=$({ [ -f .go-version ] && cat .go-version; })
echo "GOVERSION=$GOVERSION" >> $GITHUB_ENV
- name: Set up Go
uses: actions/setup-go@v3
with:
go-version: ${{ env.GOVERSION }}
- name: Set Badger Release Version
run: |
#!/bin/bash
GIT_BRANCH_NAME=$(git rev-parse --abbrev-ref HEAD)
if [[ "$GIT_BRANCH_NAME" == "release/v"* ]];
then
echo "this is a release branch"
else
echo "this is NOT a release branch"
exit 1
fi
BADGER_RELEASE_VERSION=$(git rev-parse --abbrev-ref HEAD | sed 's/release\///')
echo "making a new release for "$BADGER_RELEASE_VERSION
echo "BADGER_RELEASE_VERSION=$BADGER_RELEASE_VERSION" >> $GITHUB_ENV
- name: Fetch dependencies
run: sudo apt-get -y install build-essential
- name: Build badger linux/arm64
run: make badger
- name: Generate SHA for Linux Build
run: cd badger && sha256sum badger-linux-arm64 | cut -c-64 > badger-checksum-linux-arm64.sha256
- name: Tar Archive for Linux Build
run: cd badger && tar -zcvf badger-linux-arm64.tar.gz badger-linux-arm64
- name: Upload Badger Binary Build Artifacts
uses: actions/upload-artifact@v3
with:
path: |
badger/badger-checksum-linux-arm64.sha256
badger/badger-linux-arm64.tar.gz
18 changes: 18 additions & 0 deletions contrib/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# GH Actions Runner

How to bake an AWS Virtual Machine for GH Actions?

1. Get a Github Actions Runner Token from the UI
```
export TOKEN=<GITHUB ACTIONS RUNNER TOKEN>
```
2. Download the setup script onto the machine
```
wget https://raw.githubusercontent.com/dgraph-io/badger/main/contrib/gh-runner/gh-runner.sh
```
3. Run the script to attach this machine to Github Actions Runner Pool
```
sh gh-runner.sh
```
NOTE: This script is based on a similar [script](https://github.com/dgraph-io/dgraph/tree/main/contrib/gh-runner) located in the dgraph repository.

32 changes: 32 additions & 0 deletions contrib/gh-runner.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
#!/bin/bash
# Machine Setup
sudo apt-get update
sudo apt-get -y upgrade
sudo apt-get -y install build-essential #Libc packages
# Install & Setup GH Actions Runner
mkdir actions-runner && cd actions-runner
if [ "$(uname -m)" = "aarch64" ]; then
echo "Detected arm64 architecture"
# Download the latest runner package
curl -o actions-runner-linux-arm64-2.299.1.tar.gz -L https://github.com/actions/runner/releases/download/v2.299.1/actions-runner-linux-arm64-2.299.1.tar.gz
# Optional: Validate the hash
echo "debe1cc9656963000a4fbdbb004f475ace5b84360ace2f7a191c1ccca6a16c00 actions-runner-linux-arm64-2.299.1.tar.gz" | shasum -a 256 -c
# Extract the installer
tar xzf ./actions-runner-linux-arm64-2.299.1.tar.gz
elif [ "$(uname -m)" = "x86_64" ]; then
echo "Detected amd64 architecture"
# Download the latest runner package
curl -o actions-runner-linux-x64-2.299.1.tar.gz -L https://github.com/actions/runner/releases/download/v2.299.1/actions-runner-linux-x64-2.299.1.tar.gz
# Optional: Validate the hash
echo "147c14700c6cb997421b9a239c012197f11ea9854cd901ee88ead6fe73a72c74 actions-runner-linux-x64-2.299.1.tar.gz" | shasum -a 256 -c
# Extract the installer
tar xzf ./actions-runner-linux-x64-2.299.1.tar.gz
else
echo "Unrecognized architecture"
exit 1
fi
# Create the runner and start the configuration experience
./config.sh --url https://github.com/dgraph-io/badger --token $TOKEN
# Start GH Actions
sudo ./svc.sh install
sudo ./svc.sh start

0 comments on commit a717126

Please sign in to comment.