Skip to content

Commit

Permalink
DRY build/pubish jobs
Browse files Browse the repository at this point in the history
  • Loading branch information
jgreat committed Oct 10, 2024
1 parent b787a66 commit 1aa90e9
Show file tree
Hide file tree
Showing 7 changed files with 316 additions and 343 deletions.
24 changes: 24 additions & 0 deletions .github/actions/bootstrap-macos/action.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
name: Bootstrap MacOS Rust
description: Bootstrap MacOS environment for Rust build

runs:
using: composite
steps:
- name: Bootstrap macOS
shell: bash
run: |
echo "-- install brew dependencies"
rm -rf "$(brew --prefix)/var/homebrew/locks"
brew bundle --quiet
echo "-- install rust toolchain"
rm -rf /Users/runner/.cargo
rm -rf /Users/runner/.rustup
rustup toolchain install "$(cat rust-toolchain)"
echo "-- add cargo to path"
rustup_cargo=$(rustup which cargo)
echo "CARGO_HOME=${HOME}/.cargo" >> "${GITHUB_ENV}"
echo "RUSTUP_HOME=${HOME}/.rustup" >> "${GITHUB_ENV}"
echo "${HOME}/.cargo/bin" >> "${GITHUB_PATH}"
echo "$(dirname "${rustup_cargo}")" >> "${GITHUB_PATH}"
40 changes: 40 additions & 0 deletions .github/actions/build-publish-charts/action.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
name: Build and Publish Docker
description: Build docker containers

inputs:
version:
description: "version of the build"
required: true
repo:
description: "chart repo to publish to"
required: false
default: "https://harbor.mobilecoin.com/chartrepo/mobilecoinofficial-public"


runs:
using: composite
steps:
- name: Checkout
uses: mobilecoinofficial/gh-actions/checkout@v0

- name: Publish helm chart full-service
uses: mobilecoinofficial/gha-k8s-toolbox@v1
with:
action: helm-publish
chart_app_version: ${{ inputs.version }}
chart_path: .internal-ci/helm/full-service
chart_repo: ${{ inputs.repo }}
chart_repo_password: ${{ secrets.HARBOR_PASSWORD }}
chart_repo_username: ${{ secrets.HARBOR_USERNAME }}
chart_version: ${{ inputs.version }}

- name: Publish helm chart full-service-mirror
uses: mobilecoinofficial/gha-k8s-toolbox@v1
with:
action: helm-publish
chart_app_version: ${{ inputs.version }}
chart_path: .internal-ci/helm/full-service-mirror
chart_repo: ${{ inputs.repo }}
chart_repo_password: ${{ secrets.HARBOR_PASSWORD }}
chart_repo_username: ${{ secrets.HARBOR_USERNAME }}
chart_version: ${{ inputs.version }}
65 changes: 65 additions & 0 deletions .github/actions/build-publish-docker/action.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
name: Build and Publish Docker
description: Build docker containers

inputs:
network:
description: "network to download sigstruct from main|test"
required: true
version:
description: "version of the build"
required: true

runs:
using: composite
steps:
- name: Setup ENV
shell: bash
run: |
# Set the MobileCoin network details for "batteries included" builds.
if [[ "${{ inputs.network }}" == "main" ]]; then
MC_PEER=mc://node1.prod.mobilecoinww.com/,mc://node2.prod.mobilecoinww.co
MC_TX_SOURCE_URL=https://ledger.mobilecoinww.com/node1.prod.mobilecoinww.com/,https://ledger.mobilecoinww.com/node2.prod.mobilecoinww.com
else
MC_PEER=mc://node1.test.mobilecoin.com/,mc://node2.test.mobilecoin.com/
MC_TX_SOURCE_URL=https://s3-us-west-1.amazonaws.com/mobilecoin.chain/node1.test.mobilecoin.com/,https://s3-us-west-1.amazonaws.com/mobilecoin.chain/node2.test.mobilecoin.com
fi
ARTIFACT_NAME="full-service-${{ inputs.network }}net-${{ runner.os }}-${{ runner.arch }}-${{ version }}"
echo "MC_PEER=${MC_PEER}" >> "${GITHUB_ENV}"
echo "MC_TX_SOURCE_URL=${MC_TX_SOURCE_URL}" >> "${GITHUB_ENV}"
echo "ARTIFACT_NAME=${ARTIFACT_NAME}" >> "${GITHUB_ENV}"
echo "RUST_BIN_PATH=build-artifacts/${ARTIFACT_NAME}" >> "${GITHUB_ENV}"
- name: Checkout
uses: mobilecoinofficial/gh-actions/checkout@v0

- name: Restore Artifacts
uses: mobilecoinofficial/gh-actions/download-artifact@v0
with:
name: ${{ env.ARTIFACT_NAME }}
path: build-artifacts

- name: check artifacts
shell: bash
run: |
ls -alR build-artifacts
# fix mirror binaries path
cp ${RUST_BIN_PATH}/mirror/* ${RUST_BIN_PATH}
- name: Docker - build and publish full-service
uses: mobilecoinofficial/gh-actions/docker@v0
with:
dockerfile: .internal-ci/docker/Dockerfile.full-service
images: mobilecoin/full-service
build_args: |
RUST_BIN_PATH=${{ env.RUST_BIN_PATH }}
MC_CHAIN_ID=${{ inputs.network }}
MC_PEER=${{ env.MC_PEER }}
MC_TX_SOURCE_URL=${{ env.MC_TX_SOURCE_URL }}
flavor: |
latest=false
tags: |
${{ inputs.version}}
password: ${{ secrets.DOCKERHUB_TOKEN }}
username: ${{ secrets.DOCKERHUB_USERNAME }}
15 changes: 8 additions & 7 deletions .github/actions/build-rust/action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,16 @@ inputs:
network:
description: "network to download sigstruct from main|test"
required: true
version:
description: "version of the build"
required: true

runs:
using: composite
steps:
- name: Setup ENV
shell: bash
run: |
set -e -o pipefail
echo "GH_SHORT_SHA=sha-$(echo "${GITHUB_SHA}" | cut -c1-7)" >> "${GITHUB_ENV}"
echo "RUST_BACKTRACE=full" >> "${GITHUB_ENV}"
echo "SGX_MODE=HW" >> "${GITHUB_ENV}"
echo "CONSENSUS_ENCLAVE_CSS=/var/tmp/consensus-enclave.css" >> "${GITHUB_ENV}"
echo "INGEST_ENCLAVE_CSS=/var/tmp/ingest-enclave.css" >> "${GITHUB_ENV}"
Expand All @@ -36,13 +34,16 @@ runs:

- name: Cargo Build
shell: bash
env:
RUST_BACKTRACE: full
SGX_MODE: HW
run: |
cargo build --release --locked
- name: Copy binaries to artifact directory
shell: bash
run: |
ARTIFACT_DIR="build_artifacts/full-service-${{ inputs.network }}net-${{ runner.os }}-${{ runner.arch }}-${GH_SHORT_SHA}"
ARTIFACT_DIR="build_artifacts/full-service-${{ inputs.network }}net-${{ runner.os }}-${{ runner.arch }}-${{ inputs.version }}"
mkdir -p "${ARTIFACT_DIR}/mirror"
cp "${INGEST_ENCLAVE_CSS}" "${ARTIFACT_DIR}"
Expand All @@ -59,5 +60,5 @@ runs:
- name: Upload artifacts
uses: mobilecoinofficial/gh-actions/upload-artifact@v0
with:
name: full-service-${{ inputs.network }}net-${{ runner.os }}-${{ runner.arch }}-${{ env.GH_SHORT_SHA }}
name: full-service-${{ inputs.network }}net-${{ runner.os }}-${{ runner.arch }}-${{ inputs.version }}
path: build_artifacts
35 changes: 0 additions & 35 deletions .github/actions/mobilecoin-cache-cargo-package/action.yaml

This file was deleted.

33 changes: 0 additions & 33 deletions .github/actions/mobilecoin-cache-rust-binaries/action.yaml

This file was deleted.

Loading

0 comments on commit 1aa90e9

Please sign in to comment.