Some checks failed
Build and Publish / Build and Test (push) Failing after 6m19s
103 lines
2.9 KiB
YAML
103 lines
2.9 KiB
YAML
name: Build and Publish
|
|
|
|
on:
|
|
push:
|
|
branches: [ main ]
|
|
|
|
env:
|
|
CARGO_TERM_COLOR: always
|
|
RUST_BINARY_NAME: toggl-bridge
|
|
|
|
jobs:
|
|
build:
|
|
name: Build and Test
|
|
runs-on: ubuntu-latest
|
|
container: catthehacker/ubuntu:act-latest
|
|
|
|
steps:
|
|
- uses: actions/checkout@v3
|
|
|
|
- name: Install Rust
|
|
uses: actions-rs/toolchain@v1
|
|
with:
|
|
toolchain: stable
|
|
profile: minimal
|
|
override: true
|
|
components: rustfmt, clippy
|
|
|
|
- name: Add ARM64 target
|
|
run: rustup target add aarch64-unknown-linux-musl
|
|
|
|
- name: Install ARM64 toolchain
|
|
run: |
|
|
apt-get update
|
|
apt-get install -y gcc-aarch64-linux-gnu build-essential musl-tools
|
|
|
|
- name: Cache dependencies
|
|
uses: actions/cache@v3
|
|
with:
|
|
path: |
|
|
~/.cargo
|
|
target/
|
|
key: "${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}"
|
|
restore-keys: |
|
|
${{ runner.os }}-cargo-
|
|
|
|
- name: Build (x86_64)
|
|
uses: actions-rs/cargo@v1
|
|
with:
|
|
command: build
|
|
args: --release --all-features
|
|
|
|
- name: Build (ARM64)
|
|
uses: actions-rs/cargo@v1
|
|
with:
|
|
command: build
|
|
args: --release --all-features --target aarch64-unknown-linux-musl
|
|
env:
|
|
CARGO_TARGET_AARCH64_UNKNOWN_LINUX_MUSL_LINKER: aarch64-linux-gnu-gcc
|
|
|
|
- name: Set up QEMU
|
|
uses: docker/setup-qemu-action@v2
|
|
|
|
- name: Set up Docker Buildx
|
|
uses: docker/setup-buildx-action@v2
|
|
|
|
- name: Login to DockerHub
|
|
uses: docker/login-action@v2
|
|
with:
|
|
registry: git.joshuacoles.me
|
|
username: ${{ secrets.DOCKER_USERNAME }}
|
|
password: ${{ secrets.DOCKER_PASSWORD }}
|
|
|
|
- name: Upload artifacts
|
|
uses: actions/upload-artifact@v3
|
|
with:
|
|
name: binaries
|
|
path: |
|
|
target/release/${{ env.RUST_BINARY_NAME }}
|
|
target/aarch64-unknown-linux-musl/release/${{ env.RUST_BINARY_NAME }}
|
|
|
|
# The target directory is kept in the .dockerignore file, so allow these to be copied in we need to move them to a
|
|
# new directory.
|
|
- run: mv target docker-target
|
|
|
|
- name: Build and push multi-arch Docker image
|
|
uses: docker/build-push-action@v4
|
|
with:
|
|
context: .
|
|
file: ./Dockerfile
|
|
platforms: linux/amd64,linux/arm64
|
|
push: true
|
|
tags: git.joshuacoles.me/${{ github.repository }}:${{ github.sha }},git.joshuacoles.me/${{ github.repository }}:latest
|
|
build-args: |
|
|
BINARY_NAME=${{ env.RUST_BINARY_NAME }}
|
|
|
|
- uses: robiningelbrecht/ntfy-action@v1.0.0
|
|
name: Notify via ntfy.sh
|
|
if: always()
|
|
with:
|
|
url: ${{ secrets.NTFY_URL }}
|
|
topic: ${{ secrets.NTFY_TOPIC }}
|
|
job_status: ${{ job.status }}
|