Add Dockerfile for containerization #7
Workflow file for this run
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
name: build_release | |
on: | |
push: | |
tags: | |
- "v*.*.*" | |
jobs: | |
build_binary: | |
name: Build for ${{ matrix.name }} | |
runs-on: ${{ matrix.os }} | |
strategy: | |
fail-fast: true | |
matrix: | |
include: | |
- os: ubuntu-latest | |
name: x86_64 | |
tag: x86_64-musl | |
target: x86_64-unknown-linux-musl | |
- os: ubuntu-latest | |
name: arm64 | |
tag: aarch64-musl | |
target: aarch64-unknown-linux-musl | |
steps: | |
- name: "Checkout" | |
uses: actions/checkout@v3 | |
with: | |
fetch-depth: 1 | |
- name: "Cache builder image" | |
id: cache-builder-image | |
uses: actions/cache@v3 | |
with: | |
path: musl-builder-image-${{ matrix.name }} | |
key: musl-builder-image-${{ matrix.name }} | |
- name: "Pull and save builder image" | |
if: steps.cache-builder-image.outputs.cache-hit != 'true' | |
run: | | |
docker pull messense/rust-musl-cross:${{ matrix.tag }} | |
docker save messense/rust-musl-cross:${{ matrix.tag }} -o musl-builder-image-${{ matrix.name }} | |
- name: "Load builder image" | |
run: docker load -i musl-builder-image-${{ matrix.name }} | |
- name: "Cache Rust" | |
uses: actions/cache@v3 | |
with: | |
path: | | |
~/.cargo/bin/ | |
~/.cargo/registry/index/ | |
~/.cargo/registry/cache/ | |
~/.cargo/git/db/ | |
target/ | |
key: ${{ matrix.name }}-cargo-${{ hashFiles('**/Cargo.lock') }} | |
- name: "Build binary" | |
run: docker run --rm -u root -v "$(pwd)":/home/rust/src messense/rust-musl-cross:${{ matrix.tag }} cargo build --release | |
- name: "Upload binary" | |
uses: actions/upload-artifact@v3 | |
with: | |
name: tataki-${{ matrix.name }} | |
path: target/${{ matrix.target }}/release/tataki | |
create_release: | |
needs: [build_binary] | |
name: Create release for ${{ matrix.name }} | |
runs-on: ubuntu-latest | |
strategy: | |
fail-fast: true | |
matrix: | |
include: | |
- name: x86_64 | |
- name: arm64 | |
steps: | |
- name: "Download tataki binary" | |
uses: actions/download-artifact@v3 | |
with: | |
name: tataki-${{ matrix.name }} | |
- name: Upload tataki binary | |
uses: svenstaro/upload-release-action@v2 | |
with: | |
repo_token: ${{ secrets.GITHUB_TOKEN }} | |
file: tataki | |
asset_name: tataki-${{ matrix.name }} | |
deploy_ghcr: | |
needs: [create_release] | |
runs-on: ubuntu-latest | |
steps: | |
- name: "Checkout" | |
uses: actions/checkout@v3 | |
with: | |
fetch-depth: 1 | |
- name: Set up QEMU | |
uses: docker/setup-qemu-action@v3 | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v3 | |
- name: Login to GitHub Container Registry | |
uses: docker/login-action@v3 | |
with: | |
registry: ghcr.io | |
username: ${{ github.repository_owner }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- name: Build and push | |
uses: docker/build-push-action@v5 | |
with: | |
context: . | |
platforms: linux/amd64,linux/arm64 | |
push: true | |
tags: | | |
ghcr.io/${{ github.repository_owner }}/tataki:${{ github.ref_name }} | |
ghcr.io/${{ github.repository_owner }}/tataki:latest |