Skip to content

build: even better docker #30

build: even better docker

build: even better docker #30

Workflow file for this run

name: build
on:
push:
jobs:
build:
runs-on: ubuntu-latest
permissions:
contents: write
packages: write
steps:
- uses: actions/checkout@v4
- uses: actions/cache@v4
with:
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
restore-keys: ${{ runner.os }}-cargo-
save-always: true
path: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
target/
- run: rustup update --no-self-update stable && rustup default stable
- run: cargo fmt --check
- run: cargo check --release --locked
- run: cargo test
- uses: docker/setup-qemu-action@v3
- uses: docker/setup-buildx-action@v3
- name: Login to ghcr.io
if: ${{ github.ref == 'refs/heads/main' }} || ${{ startsWith(github.ref, 'refs/tags/v') }}
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: build & push (main)
if: ${{ github.ref == 'refs/heads/main' }}
uses: docker/build-push-action@v6
with:
push: true
platforms: linux/amd64,linux/arm64
cache-from: type=gha
cache-to: type=gha,mode=max
tags: |
ghcr.io/${{ github.repository }}:main
- name: build & push (tag)
if: ${{ startsWith(github.ref, 'refs/tags/v') }}
uses: docker/build-push-action@v6
with:
push: true
platforms: linux/amd64,linux/arm64
cache-from: type=gha
cache-to: type=gha,mode=max
tags: |
ghcr.io/${{ github.repository }}:${{ github.ref_name }}
ghcr.io/${{ github.repository }}:latest
- name: Create Github Release
if: ${{ startsWith(github.ref, 'refs/tags/v') }}
uses: softprops/action-gh-release@v2
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}