Update build_and_upload workflow to use specific dirs for artifacts b… #52
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# .github/workflows/build_and_upload.yml | |
name: Build and Upload | |
on: [push] | |
jobs: | |
build: | |
strategy: | |
matrix: | |
include: | |
- os: ubuntu-latest | |
target: x86_64-unknown-linux-musl | |
dir: musl | |
- os: windows-latest | |
target: x86_64-pc-windows-msvc | |
dir: windows | |
- os: macos-latest | |
target: x86_64-apple-darwin | |
dir: macos | |
runs-on: ${{ matrix.os }} | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v2 | |
# Install prerequisites | |
- name: Install musl-tools (Linux) | |
if: matrix.os == 'ubuntu-latest' | |
run: sudo apt-get install -y musl-tools | |
# Setup Rust | |
- name: Install Rust | |
uses: actions-rs/toolchain@v1 | |
with: | |
profile: minimal | |
toolchain: stable | |
override: true | |
target: ${{ matrix.target }} | |
# Caching | |
- name: Cache cargo registry | |
uses: actions/cache@v2 | |
with: | |
path: ~/.cargo/registry | |
key: ${{ runner.os }}-cargo-registry | |
- name: Cache cargo index | |
uses: actions/cache@v2 | |
with: | |
path: ~/.cargo/git | |
key: ${{ runner.os }}-cargo-git | |
- name: Cache cargo build | |
uses: actions/cache@v2 | |
with: | |
path: target | |
key: ${{ runner.os }}-cargo-build-target | |
# Build steps for each specific application, including conditions for OS | |
- name: Build geph5-client (Linux) | |
if: matrix.os == 'ubuntu-latest' | |
run: cargo build --locked --release --target x86_64-unknown-linux-musl --manifest-path binaries/geph5-client/Cargo.toml | |
- name: Build geph5-client (Windows) | |
if: matrix.os == 'windows-latest' | |
run: cargo build --locked --release --target x86_64-pc-windows-msvc --manifest-path binaries/geph5-client/Cargo.toml | |
- name: Build geph5-client (macOS) | |
if: matrix.os == 'macos-latest' | |
run: cargo build --locked --release --target x86_64-apple-darwin --manifest-path binaries/geph5-client/Cargo.toml | |
- name: Move binaries | |
run: | | |
mkdir artifacts | |
if [ "${{ matrix.os }}" = "ubuntu-latest" ]; then mv target/x86_64-unknown-linux-musl/release/geph5-client artifacts; fi | |
if [ "${{ matrix.os }}" = "windows-latest" ]; then mv target/x86_64-pc-windows-msvc/release/geph5-client.exe artifacts; fi | |
if [ "${{ matrix.os }}" = "macos-latest" ]; then mv target/x86_64-apple-darwin/release/geph5-client artifacts; fi | |
shell: bash | |
# Upload to Cloudflare R2 | |
- name: Upload to Cloudflare R2 | |
uses: ryand56/[email protected] | |
with: | |
r2-account-id: ${{ secrets.R2_ACCOUNT_ID }} | |
r2-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} | |
r2-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} | |
r2-bucket: geph5 | |
source-dir: ./artifacts/ | |
# Use a more dynamic destination directory naming based on the runner OS | |
destination-dir: ./${{ matrix.dir }}-latest/ |