Skip to content

release

release #1

Workflow file for this run

name: release
on:
workflow_dispatch:
env:
VERSION: '0.1.${{ github.run_number }}'
TZ: Europe/Zurich
CARGO_TERM_COLOR: always
jobs:
build-and-test:
runs-on: ubuntu-latest
environment: release
permissions:
contents: write
packages: write
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
with:
toolchain: stable
components: rustfmt, clippy
target: x86_64-unknown-linux-musl
- uses: actions/cache@v4
with:
path: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
target/
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
- run: sudo apt update && sudo apt install musl-tools -y
- run: curl -L --proto '=https' --tlsv1.2 -sSf https://raw.githubusercontent.com/cargo-bins/cargo-binstall/main/install-from-binstall-release.sh | bash
- run: cargo binstall -y cross
- run: cargo clippy
- name: run the security audit check
run: cargo audit
- name: set the crate version
run: cargo install cargo-edit --bin cargo-set-version && cargo set-version ${{ env.VERSION }}
- name: run the tests for x86_64 target
run: cross test --target x86_64-unknown-linux-musl && cargo clean
- name: build the release binaries for x86_64 and aarch64
run: |
mkdir -p ./binaries
cross build --target x86_64-unknown-linux-musl --release && mv ./target/x86_64-unknown-linux-musl/release/healthcheck ./binaries/healthcheck.x86_64
cargo clean
cross build --target aarch64-unknown-linux-musl --release && mv ./target/aarch64-unknown-linux-musl/release/healthcheck ./binaries/healthcheck.aarch64
cp ./binaries/healthcheck.x86_64 ./binaries/healthcheck
- uses: docker/setup-qemu-action@v3
- uses: docker/setup-buildx-action@v3
- uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- uses: docker/build-push-action@v6
with:
platforms: linux/amd64,linux/arm64
file: ${{ github.workspace }}/.build/images/Dockerfile
context: ./binaries
push: true
labels: |
org.opencontainers.image.source=https://github.com/${{ github.repository_owner }}/distroless-http-healthcheck
org.opencontainers.image.version=${{ env.VERSION }}
org.opencontainers.image.ref.name=${{ github.ref_name }}
org.opencontainers.image.revision=${{ github.sha }}
org.opencontainers.image.authors=https://github.com/meck93
org.opencontainers.image.description=A tiny HTTP client for distroless container health checks.
org.opencontainers.image.url=https://github.com/meck93/distroless-http-healthcheck
tags: |
ghcr.io/${{ github.repository_owner }}/distroless-http-healthcheck:latest
ghcr.io/${{ github.repository_owner }}/distroless-http-healthcheck:${{ env.VERSION }}
- name: publish the release binaries as a part of the Github release
run: |
gh release create --latest \
-n "healthcheck (v${{ env.VERSION}}), compiled for target x86_64-unknown-linux-musl and aarch64-unknown-linux-musl" \
-t "healthcheck v${{ env.VERSION}}" \
${{ env.VERSION }} \
./binaries/healthcheck*
env:
GH_TOKEN: ${{ github.token }}