From fdf7ba3d9b2ee98a6eb0e5f5b8a4e7e44212369e Mon Sep 17 00:00:00 2001 From: Daniel Perez Date: Sat, 13 Jul 2024 22:59:19 +0200 Subject: [PATCH] Add CD workflow --- .github/workflows/cd.yml | 59 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 59 insertions(+) create mode 100644 .github/workflows/cd.yml diff --git a/.github/workflows/cd.yml b/.github/workflows/cd.yml new file mode 100644 index 0000000..a2f84cb --- /dev/null +++ b/.github/workflows/cd.yml @@ -0,0 +1,59 @@ +name: Upload binary to S3 + +on: + push: + branches: + - main + +env: + PROJECT_NAME: eclair + +jobs: + upload: + runs-on: ${{ matrix.runner }} + + strategy: + matrix: + include: + - name: linux-amd64 + runner: ubuntu-latest + target: x86_64-unknown-linux-gnu + - name: win-amd64 + runner: windows-latest + target: x86_64-pc-windows-msvc + - name: macos-amd64 + runner: macos-latest + target: x86_64-apple-darwin + - name: macos-arm64 + runner: macos-latest + target: aarch64-apple-darwin + + steps: + - name: Checkout + uses: actions/checkout@v3 + + - name: Install Rust + uses: dtolnay/rust-toolchain@stable + with: + targets: "${{ matrix.target }}" + + - name: Setup Cache + uses: Swatinem/rust-cache@v2 + + - name: Build Binary + run: cargo build --verbose --locked --release --target ${{ matrix.target }} + + - name: Release Binary + env: + AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} + AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} + shell: bash + run: | + BIN_SUFFIX="" + if [[ "${{ matrix.runner }}" == "windows-latest" ]]; then + BIN_SUFFIX=".exe" + fi + + BIN_OUTPUT="target/${{ matrix.target }}/release/${PROJECT_NAME}${BIN_SUFFIX}" + + aws s3 cp $BIN_OUTPUT s3://eclair-releases/${{ matrix.target }}/${PROJECT_NAME}${BIN_SUFFIX}"