Skip to content

Commit

Permalink
Update actions to include ARM64 build (M1 Mac) (#351)
Browse files Browse the repository at this point in the history
  • Loading branch information
briancorbin authored Jun 6, 2022
1 parent ab4a7dd commit e06f490
Show file tree
Hide file tree
Showing 3 changed files with 144 additions and 71 deletions.
24 changes: 24 additions & 0 deletions .github/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# .github/release.yml

changelog:
exclude:
labels:
- ignore for release
authors:
- octocat
categories:
- title: Breaking Changes 🛠
labels:
- Semver-Major
- breaking change
- title: Exciting New Features ✨
labels:
- Semver-Minor
- enhancement
- title: Bug Fixes 🐛
labels:
- Semver-Patch
- bug
- title: Other Changes
labels:
- "*"
133 changes: 91 additions & 42 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@ on:
push:
tags:
- 'v*-pre.*'
- '*-force-build'
- '*-force-build*'

jobs:
macos:
runs-on: [self-hosted, macOS]
macos-x64:
runs-on: [self-hosted, macOS, X64]
permissions:
contents: write
strategy:
Expand Down Expand Up @@ -49,20 +49,94 @@ jobs:
with:
path: |
build_artifacts
key: ${{ runner.os }}-${{ matrix.network }}-${{ secrets.CACHE_VERSION }}-build-cargo-artifacts-${{ hashFiles('**/*.rs', '**/*.proto', '**/Cargo.toml')}}
key: ${{ runner.os }}-x86-${{ matrix.network }}-${{ secrets.CACHE_VERSION }}-build-cargo-artifacts-${{ hashFiles('**/*.rs', '**/*.proto', '**/Cargo.toml')}}

- name: Consensus SigStruct
if: steps.artifact_cache.outputs.cache-hit != 'true'
run: |
CONSENSUS_SIGSTRUCT_URI=$(curl -s https://enclave-distribution.${{ matrix.namespace }}.mobilecoin.com/production.json | grep consensus-enclave.css | awk '{print $2}' | tr -d \" | tr -d ,)
(cd /var/tmp && curl -O https://enclave-distribution.${{ matrix.namespace }}.mobilecoin.com/${CONSENSUS_SIGSTRUCT_URI})
- name: Cache Cargo
- name: Ingest SigStruct
if: steps.artifact_cache.outputs.cache-hit != 'true'
id: cargo_cache
run: |
INGEST_SIGSTRUCT_URI=$(curl -s https://enclave-distribution.${{ matrix.namespace }}.mobilecoin.com/production.json | grep ingest-enclave.css | awk '{print $2}' | tr -d \" | tr -d ,)
(cd /var/tmp && curl -O https://enclave-distribution.${{ matrix.namespace }}.mobilecoin.com/${INGEST_SIGSTRUCT_URI})
- name: Cargo Build
if: steps.artifact_cache.outputs.cache-hit != 'true'
run: |
cargo build --release
- name: Copy binaries to cache folder
if: steps.artifact_cache.outputs.cache-hit != 'true'
run: |
mkdir -pv build_artifacts/${{ matrix.network }}/bin
cp /var/tmp/*.css build_artifacts/${{ matrix.network }}
cp target/release/full-service build_artifacts/${{ matrix.network }}/bin/
cp target/release/transaction-signer build_artifacts/${{ matrix.network }}/bin/
- name: Create Artifact
run: |
mkdir -pv artifact
cd artifact && tar -czvf ${{ github.sha }}-${{ runner.os }}-x86-${{ matrix.network }}.tar.gz -C ../build_artifacts/${{ matrix.network }}/ .
- name: Upload Artifact
uses: actions/upload-artifact@v3
with:
name: full-service_${{ runner.os }}_${{ matrix.network }}_x86
path: artifact/${{ github.sha }}-${{ runner.os }}-x86-${{ matrix.network }}.tar.gz

- name: Create Release
if: startsWith(github.ref, 'refs/tags/v')
run: |
mkdir -pv release
cd release && tar -czvf ${{ github.ref_name }}-${{ runner.os }}-x86-${{ matrix.network }}.tar.gz -C ../build_artifacts/${{ matrix.network }}/ .
- name: Upload Release
if: startsWith(github.ref, 'refs/tags/v')
uses: softprops/action-gh-release@v1
with:
draft: true
prerelease: true
files: |
release/${{ github.ref_name }}-${{ runner.os }}-x86-${{ matrix.network }}.tar.gz
macos-arm64:
runs-on: [self-hosted, macOS, ARM64]
permissions:
contents: write
strategy:
matrix:
include:
- namespace: test
network: testnet
- namespace: prod
network: mainnet

steps:
- name: Checkout
uses: actions/checkout@v3
with:
submodules: recursive

- name: Brew Bundle
run: |
brew update --preinstall
brew bundle --no-upgrade
- name: Git Submodule
run: |
git submodule update --checkout --init --recursive
# CACHE_VERSION secret is 'date --iso-8601=minutes' and is used to invalidate cache if needed
- name: Cache Build Binaries
id: artifact_cache
uses: actions/cache@v3
with:
path: |
/opt/cargo/bin/
/opt/cargo/registry/index/
/opt/cargo/registry/cache/
/opt/cargo/git/db/
target/
key: ${{ runner.os }}-${{ secrets.CACHE_VERSION }}-cargo-${{ hashFiles('**/Cargo.lock') }}
build_artifacts
key: ${{ runner.os }}-arm64-${{ matrix.network }}-${{ secrets.CACHE_VERSION }}-build-cargo-artifacts-${{ hashFiles('**/*.rs', '**/*.proto', '**/Cargo.toml')}}

- name: Consensus SigStruct
if: steps.artifact_cache.outputs.cache-hit != 'true'
Expand Down Expand Up @@ -92,24 +166,19 @@ jobs:
- name: Create Artifact
run: |
mkdir -pv artifact
cd artifact && tar -czvf ${{ github.sha }}-${{ runner.os }}-${{ matrix.network }}.tar.gz -C ../build_artifacts/${{ matrix.network }}/ .
cd artifact && tar -czvf ${{ github.sha }}-${{ runner.os }}-arm64-${{ matrix.network }}.tar.gz -C ../build_artifacts/${{ matrix.network }}/ .
- name: Upload Artifact
uses: actions/upload-artifact@v3
with:
name: full-service_${{ runner.os }}_${{ matrix.network }}
path: artifact/${{ github.sha }}-${{ runner.os }}-${{ matrix.network }}.tar.gz
name: full-service_${{ runner.os }}_${{ matrix.network }}_arm64
path: artifact/${{ github.sha }}-${{ runner.os }}-arm64-${{ matrix.network }}.tar.gz

- name: Create Release
if: startsWith(github.ref, 'refs/tags/v')
run: |
mkdir -pv release
cd release && tar -czvf ${{ github.ref_name }}-${{ runner.os }}-${{ matrix.network }}.tar.gz -C ../build_artifacts/${{ matrix.network }}/ .
- name: Generate MD5
if: startsWith(github.ref, 'refs/tags/v')
run: |
cd release && md5sum ${{ github.ref_name }}-${{ runner.os }}-${{ matrix.network }}.tar.gz > ${{ github.ref_name }}-${{ runner.os }}-${{ matrix.network }}.md5
cd release && tar -czvf ${{ github.ref_name }}-${{ runner.os }}-arm64-${{ matrix.network }}.tar.gz -C ../build_artifacts/${{ matrix.network }}/ .
- name: Upload Release
if: startsWith(github.ref, 'refs/tags/v')
Expand All @@ -118,8 +187,7 @@ jobs:
draft: true
prerelease: true
files: |
release/${{ github.ref_name }}-${{ runner.os }}-${{ matrix.network }}.tar.gz
release/${{ github.ref_name }}-${{ runner.os }}-${{ matrix.network }}.md5
release/${{ github.ref_name }}-${{ runner.os }}-arm64-${{ matrix.network }}.tar.gz
linux:
runs-on: [self-hosted, Linux, large]
Expand Down Expand Up @@ -150,19 +218,6 @@ jobs:
build_artifacts
key: ${{ runner.os }}-${{ matrix.network }}-${{ secrets.CACHE_VERSION }}-build-cargo-artifacts-${{ hashFiles('**/*.rs', '**/*.proto', '**/Cargo.toml')}}

- name: Cache Cargo
if: steps.artifact_cache.outputs.cache-hit != 'true'
id: cargo_cache
uses: actions/cache@v3
with:
path: |
/opt/cargo/bin/
/opt/cargo/registry/index/
/opt/cargo/registry/cache/
/opt/cargo/git/db/
target/
key: ${{ runner.os }}-${{ secrets.CACHE_VERSION }}-cargo-${{ hashFiles('**/Cargo.lock') }}

- name: Consensus SigStruct
if: steps.artifact_cache.outputs.cache-hit != 'true'
run: |
Expand Down Expand Up @@ -205,11 +260,6 @@ jobs:
mkdir -pv release
cd release && tar -czvf ${{ github.ref_name }}-${{ runner.os }}-${{ matrix.network }}.tar.gz -C ../build_artifacts/${{ matrix.network }}/ .
- name: Generate MD5
if: startsWith(github.ref, 'refs/tags/v')
run: |
cd release && md5sum ${{ github.ref_name }}-${{ runner.os }}-${{ matrix.network }}.tar.gz > ${{ github.ref_name }}-${{ runner.os }}-${{ matrix.network }}.md5
- name: Upload Release
if: startsWith(github.ref, 'refs/tags/v')
uses: softprops/action-gh-release@v1
Expand All @@ -218,4 +268,3 @@ jobs:
prerelease: true
files: |
release/${{ github.ref_name }}-${{ runner.os }}-${{ matrix.network }}.tar.gz
release/${{ github.ref_name }}-${{ runner.os }}-${{ matrix.network }}.md5
58 changes: 29 additions & 29 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,29 +6,14 @@ on:
tags:
- 'v*'
- '!v*-pre*'
- '*-force-release'
- '*-force-release*'

jobs:
release:
runs-on: [self-hosted, Linux, large]
# Needs write permission for publishing release
permissions:
contents: write
strategy:
matrix:
include:
- namespace: test
network: testnet
os: Linux
- namespace: prod
network: mainnet
os: Linux
- namespace: prod
network: testnet
os: macOS
- namespace: prod
network: mainnet
os: macOS

steps:
- name: Get Current Pre-Release
Expand All @@ -46,25 +31,41 @@ jobs:
with:
tag: ${{ steps.current_release.outputs.tag_name }}
files: |
${{ steps.current_release.outputs.tag_name }}-${{ matrix.os }}-${{ matrix.network }}.tar.gz
target: /var/tmp/${{ steps.current_release.outputs.tag_name }}-${{ matrix.os }}-${{ matrix.network }}.tar.gz
${{ steps.current_release.outputs.tag_name }}-Linux-testnet.tar.gz
${{ steps.current_release.outputs.tag_name }}-Linux-mainnet.tar.gz
${{ steps.current_release.outputs.tag_name }}-macOS-x86-testnet.tar.gz
${{ steps.current_release.outputs.tag_name }}-macOS-x86-mainnet.tar.gz
${{ steps.current_release.outputs.tag_name }}-macOS-arm64-testnet.tar.gz
${{ steps.current_release.outputs.tag_name }}-macOS-arm64-mainnet.tar.gz
target: /var/tmp/

- name: Extract Release
run: |
rm -rfv build_artifacts/${{ matrix.network }}
mkdir -pv build_artifacts/${{ matrix.network }}
tar xzvf /var/tmp/${{ steps.current_release.outputs.tag_name }}-${{ matrix.os }}-${{ matrix.network }}.tar.gz -C build_artifacts/${{ matrix.network }}
rm -rfv build_artifacts
mkdir -pv build_artifacts/Linux-testnet
mkdir -pv build_artifacts/Linux-mainnet
mkdir -pv build_artifacts/macOS-x86-testnet
mkdir -pv build_artifacts/macOS-x86-mainnet
mkdir -pv build_artifacts/macOS-arm64-testnet
mkdir -pv build_artifacts/macOS-arm64-mainnet
tar xzvf /var/tmp/${{ steps.current_release.outputs.tag_name }}-Linux-testnet.tar.gz -C build_artifacts/Linux-testnet
tar xzvf /var/tmp/${{ steps.current_release.outputs.tag_name }}-Linux-mainnet.tar.gz -C build_artifacts/Linux-mainnet
tar xzvf /var/tmp/${{ steps.current_release.outputs.tag_name }}-macOS-x86-testnet.tar.gz -C build_artifacts/macOS-x86-testnet
tar xzvf /var/tmp/${{ steps.current_release.outputs.tag_name }}-macOS-x86-mainnet.tar.gz -C build_artifacts/macOS-x86-mainnet
tar xzvf /var/tmp/${{ steps.current_release.outputs.tag_name }}-macOS-arm64-testnet.tar.gz -C build_artifacts/macOS-arm64-testnet
tar xzvf /var/tmp/${{ steps.current_release.outputs.tag_name }}-macOS-arm64-mainnet.tar.gz -C build_artifacts/macOS-arm64-mainnet
- name: Create Release
if: startsWith(github.ref, 'refs/tags/v')
run: |
mkdir -pv release
cd release && tar -czvf ${{ github.ref_name }}-${{ matrix.os }}-${{ matrix.network }}.tar.gz -C ../build_artifacts/${{ matrix.network }}/ .
- name: Generate MD5
if: startsWith(github.ref, 'refs/tags/v')
run: |
cd release && md5sum ${{ github.ref_name }}-${{ matrix.os }}-${{ matrix.network }}.tar.gz > ${{ github.ref_name }}-${{ matrix.os }}-${{ matrix.network }}.md5
cd release
tar -czvf ${{ github.ref_name }}-Linux-testnet.tar.gz -C ../build_artifacts/Linux-testnet/ .
tar -czvf ${{ github.ref_name }}-Linux-mainnet.tar.gz -C ../build_artifacts/Linux-mainnet/ .
tar -czvf ${{ github.ref_name }}-macOS-x86-testnet.tar.gz -C ../build_artifacts/macOS-x86-testnet/ .
tar -czvf ${{ github.ref_name }}-macOS-x86-mainnet.tar.gz -C ../build_artifacts/macOS-x86-mainnet/ .
tar -czvf ${{ github.ref_name }}-macOS-arm64-testnet.tar.gz -C ../build_artifacts/macOS-arm64-testnet/ .
tar -czvf ${{ github.ref_name }}-macOS-arm64-mainnet.tar.gz -C ../build_artifacts/macOS-arm64-mainnet/ .
- name: Upload Release
if: startsWith(github.ref, 'refs/tags/v')
Expand All @@ -73,5 +74,4 @@ jobs:
draft: true
prerelease: ${{ steps.prerelease.outputs.value }}
files: |
release/${{ github.ref_name }}-${{ matrix.os }}-${{ matrix.network }}.tar.gz
release/${{ github.ref_name }}-${{ matrix.os }}-${{ matrix.network }}.md5
release/*

0 comments on commit e06f490

Please sign in to comment.