diff --git a/.github/workflows/build-and-deploy.yml b/.github/workflows/build-and-deploy.yml new file mode 100644 index 00000000..c354324c --- /dev/null +++ b/.github/workflows/build-and-deploy.yml @@ -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 }} \ No newline at end of file diff --git a/.github/workflows/lint-and-test-cli.yml b/.github/workflows/lint-and-test-cli.yml index ee83ea7a..65f33c7a 100644 --- a/.github/workflows/lint-and-test-cli.yml +++ b/.github/workflows/lint-and-test-cli.yml @@ -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 @@ -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 diff --git a/.github/workflows/release-cli-version.yml b/.github/workflows/release-cli-version.yml index 183033ab..cfc27770 100644 --- a/.github/workflows/release-cli-version.yml +++ b/.github/workflows/release-cli-version.yml @@ -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" + diff --git a/Cargo.lock b/Cargo.lock index c3599e8b..8d62ebfb 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -936,7 +936,7 @@ dependencies = [ [[package]] name = "ev-cage" -version = "0.0.0-dev" +version = "1.0.0-dev" dependencies = [ "async-stream", "async-trait", diff --git a/Cargo.toml b/Cargo.toml index 5c3f8a2f..7694e1ae 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -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