Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update github actions to consolidate duplicated code for building #510

Merged
merged 22 commits into from
Oct 12, 2022
Merged
178 changes: 21 additions & 157 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,181 +7,45 @@ env:
CONSENSUS_ENCLAVE_CSS: /var/tmp/consensus-enclave.css
INGEST_ENCLAVE_CSS: /var/tmp/ingest-enclave.css

# only perform these build steps on pre-release
# only perform these build steps on pre-release or forced dev build
on:
push:
tags:
- 'v*-pre.*'
- '*.dev-build.*'

jobs:
macos-x64:
runs-on: [self-hosted, macOS, X64, cargo]
build-and-pre-release:
permissions:
contents: write
strategy:
matrix:
runner-tags: [[self-hosted, macOS, X64, cargo], [self-hosted, macOS, ARM64, cargo], [self-hosted, Linux, large]]
namespace: [test, prod]
include:
- runner-tags: [self-hosted, macOS, X64, cargo]
container: null
- runner-tags: [self-hosted, macOS, ARM64, cargo]
container: null
- runner-tags: [self-hosted, Linux, large]
container: mobilecoin/rust-sgx-base:latest
- namespace: test
network: testnet
- namespace: prod
network: mainnet

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

- name: Brew Bundle
run: |
brew bundle

- name: Git Submodule
run: |
git submodule update --checkout --init --recursive

- name: Consensus SigStruct
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: Ingest SigStruct
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
run: |
cargo build --release

- name: Copy binaries to cache folder
run: |
mkdir -pv build_artifacts/${{ matrix.network }}/bin
cp /var/tmp/*.css build_artifacts/${{ matrix.network }}
cp target/release/mc-full-service build_artifacts/${{ matrix.network }}/bin/
cp target/release/mc-transaction-signer build_artifacts/${{ matrix.network }}/bin/
cp target/release/mc-validator-service build_artifacts/${{ matrix.network }}/bin/
runs-on: ${{ matrix.runner-tags }}
container: ${{ matrix.container }}

- 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 Prerelease
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 Prerelease
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, cargo]
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
if: runner.os == 'macOS'
run: |
brew bundle

- name: Git Submodule
run: |
git submodule update --checkout --init --recursive

- name: Consensus SigStruct
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: Ingest SigStruct
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
run: |
cargo build --release

- name: Copy binaries to cache folder
run: |
mkdir -pv build_artifacts/${{ matrix.network }}/bin
cp /var/tmp/*.css build_artifacts/${{ matrix.network }}
cp target/release/mc-full-service build_artifacts/${{ matrix.network }}/bin/
cp target/release/mc-transaction-signer build_artifacts/${{ matrix.network }}/bin/
cp target/release/mc-validator-service build_artifacts/${{ matrix.network }}/bin/

- name: Create Artifact
run: |
mkdir -pv artifact
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 }}_arm64
path: artifact/${{ github.sha }}-${{ runner.os }}-arm64-${{ matrix.network }}.tar.gz

- name: Create Prerelease
if: startsWith(github.ref, 'refs/tags/v')
run: |
mkdir -pv release
cd release && tar -czvf ${{ github.ref_name }}-${{ runner.os }}-arm64-${{ matrix.network }}.tar.gz -C ../build_artifacts/${{ matrix.network }}/ .

- name: Upload Prerelease
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 }}-arm64-${{ matrix.network }}.tar.gz

linux:
runs-on: [self-hosted, Linux, large]
permissions:
contents: write
container:
image: mobilecoin/rust-sgx-base:latest
strategy:
matrix:
include:
- namespace: test
network: testnet
- namespace: prod
network: mainnet

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

- name: Consensus SigStruct
run: |
Expand All @@ -201,26 +65,26 @@ jobs:
run: |
mkdir -pv build_artifacts/${{ matrix.network }}/bin
cp /var/tmp/*.css build_artifacts/${{ matrix.network }}
cp target/release/mc-full-service build_artifacts/${{ matrix.network }}/bin/
cp target/release/mc-transaction-signer build_artifacts/${{ matrix.network }}/bin/
cp target/release/mc-validator-service build_artifacts/${{ matrix.network }}/bin/
cp target/release/mc-full-service build_artifacts/${{ matrix.network }}
cp target/release/mc-transaction-signer build_artifacts/${{ matrix.network }}
cp target/release/mc-validator-service build_artifacts/${{ matrix.network }}

- 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 }}-${{ runner.arch }}-${{ 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 }}-${{ runner.arch }}-${{ matrix.network }}
path: artifact/${{ github.sha }}-${{ runner.os }}-${{ runner.arch }}-${{ matrix.network }}.tar.gz

- name: Create Prerelease
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 }}/ .
cd release && tar -czvf ${{ github.ref_name }}-${{ runner.os }}-${{ runner.arch }}-${{ matrix.network }}.tar.gz -C ../build_artifacts/${{ matrix.network }}/ .

- name: Upload Prerelease
if: startsWith(github.ref, 'refs/tags/v')
Expand All @@ -229,4 +93,4 @@ jobs:
draft: true
prerelease: true
files: |
release/${{ github.ref_name }}-${{ runner.os }}-${{ matrix.network }}.tar.gz
release/${{ github.ref_name }}-${{ runner.os }}-${{ runner.arch }}-${{ matrix.network }}.tar.gz
50 changes: 25 additions & 25 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ on:

jobs:
release:
runs-on: [self-hosted, Linux, large]
runs-on: [self-hosted, Linux-X64, large]
# Needs write permission for publishing release
permissions:
contents: write
Expand All @@ -30,41 +30,41 @@ jobs:
with:
tag: ${{ steps.current_release.outputs.tag_name }}
files: |
${{ 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
${{ steps.current_release.outputs.tag_name }}-Linux-X64-testnet.tar.gz
${{ steps.current_release.outputs.tag_name }}-Linux-X64-mainnet.tar.gz
${{ steps.current_release.outputs.tag_name }}-macOS-X64-testnet.tar.gz
${{ steps.current_release.outputs.tag_name }}-macOS-X64-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
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
mkdir -pv build_artifacts/Linux-X64-testnet
mkdir -pv build_artifacts/Linux-X64-mainnet
mkdir -pv build_artifacts/macOS-X64-testnet
mkdir -pv build_artifacts/macOS-X64-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-X64-testnet.tar.gz -C build_artifacts/Linux-X64-testnet
tar xzvf /var/tmp/${{ steps.current_release.outputs.tag_name }}-Linux-X64-mainnet.tar.gz -C build_artifacts/Linux-X64-mainnet
tar xzvf /var/tmp/${{ steps.current_release.outputs.tag_name }}-macOS-X64-testnet.tar.gz -C build_artifacts/macOS-X64-testnet
tar xzvf /var/tmp/${{ steps.current_release.outputs.tag_name }}-macOS-X64-mainnet.tar.gz -C build_artifacts/macOS-X64-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 }}-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/ .
tar -czvf ${{ github.ref_name }}-Linux-X64-testnet.tar.gz -C ../build_artifacts/Linux-X64-testnet/ .
tar -czvf ${{ github.ref_name }}-Linux-X64-mainnet.tar.gz -C ../build_artifacts/Linux-X64-mainnet/ .
tar -czvf ${{ github.ref_name }}-macOS-X64-testnet.tar.gz -C ../build_artifacts/macOS-X64-testnet/ .
tar -czvf ${{ github.ref_name }}-macOS-X64-mainnet.tar.gz -C ../build_artifacts/macOS-X64-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 Down