Skip to content

Commit

Permalink
Publish staging CLI on push
Browse files Browse the repository at this point in the history
  • Loading branch information
hanneary committed Dec 4, 2023
1 parent f8456ce commit 0f81271
Show file tree
Hide file tree
Showing 5 changed files with 187 additions and 13 deletions.
173 changes: 173 additions & 0 deletions .github/workflows/build-and-deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,173 @@
name: "Build and publish CLI"
description: "Builds and pushes the CLI artifacts"

on:
workflow_call:
inputs:
STAGE:
required: true
default: 'staging'
VERSION:
required: true
default: '0.0.0'
secrets: inherit
env:
RUST_BACKTRACE: 1
WINDOWS_TARGET: x86_64-pc-windows-msvc
MACOS_TARGET: x86_64-apple-darwin
LINUX_TARGET: x86_64-unknown-linux-musl
BIN_DIR: bin
RELEASE_DIR: release
jobs:
compile-ubuntu:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2

- name: Install musl-tools
run: sudo apt-get install musl-tools

- name: Set up Rust
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: nightly-2023-09-13
override: true
target: ${{ env.LINUX_TARGET }}

- name: Download cached dependencies
uses: Swatinem/rust-cache@v2
with:
shared-key: "linux-cross-builds"

- name: Install cross
run: cargo install cross

- name: Inject Version
run: |
sh ./scripts/insert-cli-version.sh ${{ needs.get-version.outputs.full_version }}
- name: Build and Compress cli
run: |
mkdir ${{ env.BIN_DIR }}
mkdir ${{ env.RELEASE_DIR }}
cross build --release --all-features --target ${{ env.LINUX_TARGET }} -Z registry-auth
mv ./target/${{ env.LINUX_TARGET }}/release/ev-cage ./${{ env.BIN_DIR }}/ev-cage
7z a -ttar -so -an ./${{ env.BIN_DIR }} | 7z a -si ./${{ env.RELEASE_DIR }}/ev-cage-${{ env.LINUX_TARGET }}-${{ needs.get-version.outputs.full_version }}.tar.gz
env:
CARGO_REGISTRIES_EVERVAULT_RUST_LIBRARIES_INDEX: ${{ secrets.RUST_CRYPTO_REGISTRY }}
CARGO_REGISTRIES_EVERVAULT_RUST_LIBRARIES_TOKEN: ${{ secrets.CARGO_REGISTRIES_EVERVAULT_RUST_LIBRARIES_TOKEN }}
CARGO_HOME: ${{ github.workspace }}/.cargo

- name: Upload as artifact
uses: actions/upload-artifact@v2
with:
name: linux
path: ./${{ env.RELEASE_DIR }}

compile-macos:
runs-on: macos-latest
needs: get-version
steps:
- uses: actions/checkout@v2

- name: Inject Version
run: |
sh ./scripts/insert-cli-version.sh ${{ needs.get-version.outputs.full_version }}
- uses: actions-rs/toolchain@v1
with:
toolchain: nightly-2023-09-13
target: ${{ env.MACOS_TARGET }}
override: true

- name: Download cached dependencies
uses: Swatinem/rust-cache@v2
with:
shared-key: "macos-cross-builds"

- name: Build CLI MacOs Target
run: |
cargo install cross
cross build --release --all-features --target ${{ env.MACOS_TARGET }} -Z registry-auth
env:
CARGO_REGISTRIES_EVERVAULT_RUST_LIBRARIES_INDEX: ${{ secrets.RUST_CRYPTO_REGISTRY }}
CARGO_REGISTRIES_EVERVAULT_RUST_LIBRARIES_TOKEN: ${{ secrets.CARGO_REGISTRIES_EVERVAULT_RUST_LIBRARIES_TOKEN }}

- name: Install 7z cli
run: brew install p7zip

- name: Setup directories
run: |
mkdir ${{ env.BIN_DIR }}
mkdir ${{ env.RELEASE_DIR }}
- name: Compress binary
run: |
mv target/${{env.MACOS_TARGET}}/release/ev-cage ${{ env.BIN_DIR }}/ev-cage
7z a -ttar -so -an ./${{ env.BIN_DIR }} | 7z a -si ${{ env.RELEASE_DIR }}/ev-cage-${{ env.MACOS_TARGET }}-${{ needs.get-version.outputs.full_version }}.tar.gz
- name: Upload as artifact
uses: actions/upload-artifact@v2
with:
name: macos
path: ./${{ env.RELEASE_DIR }}


compile-windows:
runs-on: windows-latest
needs: get-version
env:
VCPKGRS_DYNAMIC: 1
steps:
- uses: actions/checkout@v2

- name: Install Rust
run: rustup update --no-self-update stable && rustup default stable

- uses: actions-rs/toolchain@v1
with:
toolchain: nightly-2023-09-13
target: ${{ env.WINDOWS_TARGET }}
override: true

- name: Inject Version
run: |
sh ./scripts/insert-cli-version.sh ${{ needs.get-version.outputs.full_version }}
- name: Download cached dependencies
uses: Swatinem/rust-cache@v2
with:
shared-key: "windows-cross-builds"

- name: Fetch dependencies
run: cargo fetch -Z registry-auth
env:
CARGO_REGISTRIES_EVERVAULT_RUST_LIBRARIES_INDEX: ${{ secrets.RUST_CRYPTO_REGISTRY }}
CARGO_REGISTRIES_EVERVAULT_RUST_LIBRARIES_TOKEN: ${{ secrets.CARGO_REGISTRIES_EVERVAULT_RUST_LIBRARIES_TOKEN }}

- name: Build CLI for Windows
run: |
cargo install cross
cross build --release --all-features --target ${{ env.WINDOWS_TARGET }} -Z registry-auth
env:
CARGO_REGISTRIES_EVERVAULT_RUST_LIBRARIES_INDEX: ${{ secrets.RUST_CRYPTO_REGISTRY }}
CARGO_REGISTRIES_EVERVAULT_RUST_LIBRARIES_TOKEN: ${{ secrets.CARGO_REGISTRIES_EVERVAULT_RUST_LIBRARIES_TOKEN }}

- name: Setup directories
shell: bash
run: |
mkdir ${{ env.BIN_DIR }}
mkdir ${{ env.RELEASE_DIR }}
- name: Compress
shell: bash
run: |
mv target/${{ env.WINDOWS_TARGET }}/release/ev-cage.exe ${{ env.BIN_DIR }}/ev-cage.exe
7z a -ttar -so -an ./${{ env.BIN_DIR }} | 7z a -si ./${{ env.RELEASE_DIR }}/ev-cage-${{ env.WINDOWS_TARGET }}-${{ needs.get-version.outputs.full_version }}.tar.gz
- name: Upload as artifact
uses: actions/upload-artifact@v2
with:
name: windows
path: ./${{ env.RELEASE_DIR }}
18 changes: 10 additions & 8 deletions .github/workflows/lint-and-test-cli.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,5 @@
on:
push:
paths:
- src/**
- tests/**
- .github/workflows/lint-and-test-cli.yml
- Cargo.toml
name: Lint and Test CLI
on: [push]

jobs:
clippy_check_cli:
runs-on: ubuntu-latest
Expand Down Expand Up @@ -36,3 +30,11 @@ jobs:
run: cargo clippy
env:
CARGO_REGISTRIES_EVERVAULT_RUST_LIBRARIES_INDEX: ${{ secrets.RUST_CRYPTO_REGISTRY }}

build-and-deploy-staging:
needs: clippy_check_cli
uses: ./.github/workflows/build-and-deploy.yml
with:
STAGE: 'staging'
VERSION: '1.0.0'
secrets: inherit
5 changes: 2 additions & 3 deletions .github/workflows/release-cli-version.yml
Original file line number Diff line number Diff line change
Expand Up @@ -299,6 +299,5 @@ jobs:
aws s3 cp scripts/version s3://cage-build-assets-${{ env.STAGE }}/cli/${{needs.get-version.outputs.major_version}}/version
aws s3 cp scripts/version s3://cage-build-assets-${{ env.STAGE }}/cli/version
aws s3 cp scripts/versions s3://cage-build-assets-${{ env.STAGE }}/cli/versions
aws cloudfront create-invalidation --distribution-id ${{ secrets.CLOUDFRONT_DISTRIBUTION_ID }} --paths "/cli/install"
aws cloudfront create-invalidation --distribution-id ${{ secrets.CLOUDFRONT_DISTRIBUTION_ID }} --paths "/cli/version"
aws cloudfront create-invalidation --distribution-id ${{ secrets.CLOUDFRONT_DISTRIBUTION_ID }} --paths "/cli/versions"
aws cloudfront create-invalidation --distribution-id ${{ secrets.CLOUDFRONT_DISTRIBUTION_ID }} --paths "/cli/install" "/cli/version" "/cli/versions"
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "ev-cage"
version = "0.0.0-dev"
version = "1.0.0-dev"
edition = "2021"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
Expand Down

0 comments on commit 0f81271

Please sign in to comment.