This commit is contained in:
parent
d8430587b8
commit
a27aeb0f10
45
.github/workflows/build.yml
vendored
45
.github/workflows/build.yml
vendored
@ -1,13 +1,12 @@
|
|||||||
name: Rust CI
|
name: Build and Publish
|
||||||
|
|
||||||
on:
|
on:
|
||||||
push:
|
push:
|
||||||
branches: [ main ]
|
branches: [ main ]
|
||||||
pull_request:
|
|
||||||
branches: [ main ]
|
|
||||||
|
|
||||||
env:
|
env:
|
||||||
CARGO_TERM_COLOR: always
|
CARGO_TERM_COLOR: always
|
||||||
|
RUST_BINARY_NAME: toggl-bridge
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
build:
|
build:
|
||||||
@ -27,12 +26,12 @@ jobs:
|
|||||||
components: rustfmt, clippy
|
components: rustfmt, clippy
|
||||||
|
|
||||||
- name: Add ARM64 target
|
- name: Add ARM64 target
|
||||||
run: rustup target add aarch64-unknown-linux-gnu
|
run: rustup target add aarch64-unknown-linux-musl
|
||||||
|
|
||||||
- name: Install ARM64 toolchain
|
- name: Install ARM64 toolchain
|
||||||
run: |
|
run: |
|
||||||
apt-get update
|
apt-get update
|
||||||
apt-get install -y gcc-aarch64-linux-gnu
|
apt-get install -y gcc-aarch64-linux-gnu build-essential musl-tools
|
||||||
|
|
||||||
- name: Cache dependencies
|
- name: Cache dependencies
|
||||||
uses: actions/cache@v3
|
uses: actions/cache@v3
|
||||||
@ -42,7 +41,7 @@ jobs:
|
|||||||
target/
|
target/
|
||||||
key: "${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}"
|
key: "${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}"
|
||||||
restore-keys: |
|
restore-keys: |
|
||||||
${{ runner.os }}-cargo-
|
${{ runner.os }}-cargo-
|
||||||
|
|
||||||
- name: Build (x86_64)
|
- name: Build (x86_64)
|
||||||
uses: actions-rs/cargo@v1
|
uses: actions-rs/cargo@v1
|
||||||
@ -54,23 +53,9 @@ jobs:
|
|||||||
uses: actions-rs/cargo@v1
|
uses: actions-rs/cargo@v1
|
||||||
with:
|
with:
|
||||||
command: build
|
command: build
|
||||||
args: --release --all-features --target aarch64-unknown-linux-gnu
|
args: --release --all-features --target aarch64-unknown-linux-musl
|
||||||
env:
|
env:
|
||||||
CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_LINKER: aarch64-linux-gnu-gcc
|
CARGO_TARGET_AARCH64_UNKNOWN_LINUX_MUSL_LINKER: aarch64-linux-gnu-gcc
|
||||||
|
|
||||||
- name: Run tests
|
|
||||||
uses: actions-rs/cargo@v1
|
|
||||||
with:
|
|
||||||
command: test
|
|
||||||
args: --all-features
|
|
||||||
|
|
||||||
- name: Upload artifacts
|
|
||||||
uses: actions/upload-artifact@v3
|
|
||||||
with:
|
|
||||||
name: binaries
|
|
||||||
path: |
|
|
||||||
target/release/${{ github.event.repository.name }}
|
|
||||||
target/aarch64-unknown-linux-gnu/release/${{ github.event.repository.name }}
|
|
||||||
|
|
||||||
- name: Set up QEMU
|
- name: Set up QEMU
|
||||||
uses: docker/setup-qemu-action@v2
|
uses: docker/setup-qemu-action@v2
|
||||||
@ -85,6 +70,18 @@ jobs:
|
|||||||
username: ${{ secrets.DOCKER_USERNAME }}
|
username: ${{ secrets.DOCKER_USERNAME }}
|
||||||
password: ${{ secrets.DOCKER_PASSWORD }}
|
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
|
- name: Build and push multi-arch Docker image
|
||||||
uses: docker/build-push-action@v4
|
uses: docker/build-push-action@v4
|
||||||
with:
|
with:
|
||||||
@ -92,7 +89,9 @@ jobs:
|
|||||||
file: ./Dockerfile
|
file: ./Dockerfile
|
||||||
platforms: linux/amd64,linux/arm64
|
platforms: linux/amd64,linux/arm64
|
||||||
push: true
|
push: true
|
||||||
tags: git.joshuacoles.me/${{ github.repository }}:latest,git.joshuacoles.me/${{ github.repository }}:${{ github.sha }}
|
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
|
- uses: robiningelbrecht/ntfy-action@v1.0.0
|
||||||
name: Notify via ntfy.sh
|
name: Notify via ntfy.sh
|
||||||
|
|||||||
@ -1,7 +1,7 @@
|
|||||||
FROM --platform=$BUILDPLATFORM debian:bullseye-slim AS builder
|
FROM --platform=$BUILDPLATFORM debian:bullseye-slim AS builder
|
||||||
ARG TARGETPLATFORM
|
ARG TARGETPLATFORM
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
COPY . .
|
COPY docker-target target
|
||||||
RUN case "$TARGETPLATFORM" in \
|
RUN case "$TARGETPLATFORM" in \
|
||||||
"linux/amd64") BINARY_PATH="target/release/toggl-bridge" ;; \
|
"linux/amd64") BINARY_PATH="target/release/toggl-bridge" ;; \
|
||||||
"linux/arm64") BINARY_PATH="target/aarch64-unknown-linux-gnu/release/toggl-bridge" ;; \
|
"linux/arm64") BINARY_PATH="target/aarch64-unknown-linux-gnu/release/toggl-bridge" ;; \
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user