Skip to content

Commit

Permalink
add github workflows
Browse files Browse the repository at this point in the history
Signed-off-by: Avi Deitcher <avi@deitcher.net>
  • Loading branch information
deitch committed Aug 16, 2024
1 parent 911c40d commit 36f41d1
Show file tree
Hide file tree
Showing 4 changed files with 109 additions and 1 deletion.
49 changes: 49 additions & 0 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
---
name: PR build
on:
pull_request_target:
paths-ignore:
- '.github/workflows/**'
branches:
- "main"
push:
branches:
- "main"


concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number }}
cancel-in-progress: true

jobs:
build:
runs-on: ubuntu-latest
strategy:
fail-fast: false
steps:
- name: Starting Report
run: |
echo Git Ref: ${{ github.event.pull_request.head.ref }}
echo GitHub Event: ${{ github.event_name }}
echo Disk usage
df -h
echo Memory
free -m
- uses: actions/checkout@v4
with:
repository: ${{ github.event.pull_request.head.repo.full_name }}
ref: ${{ github.event.pull_request.head.ref }}
fetch-depth: 0
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- uses: docker/build-push-action@v5
with:
context: .
platforms: linux/amd64,linux/arm64
push: false
tags: |
${{ github.event.pull_request.head.repo.full_name }}:${{ github.event.pull_request.head.ref }}
${{ github.event.pull_request.head.repo.full_name }}:latest
55 changes: 55 additions & 0 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
name: release
on:
push:
tags:
- "[0-9]+.[0-9]+.[0-9]+"
paths-ignore:
- '.github/workflows/**'

env:
OCIREPO: lfedge/eve-rust

jobs:
build_and_push:
runs-on: ubuntu-latest
strategy:
fail-fast: false
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Get rust version
id: rust_version
run: |
RUST_VERSION=$(awk -F= '/ARG RUST_VERSION/ {print $2}' Dockerfile)
# make sure we got a rust version
if [ -z "$RUST_VERSION" ]; then
echo "Failed to get RUST_VERSION"
exit 1
fi
# strip off any potential eve-specific extensions to the tag
TAG="${{ github.ref_name }}"
TAG="${TAG%%-*}"
if [ "$TAG" != "$RUST_VERSION" ]; then
echo "Tag $TAG does not match RUST_VERSION $RUST_VERSION"
exit 1
fi
echo "::set-output name=RUST_VERSION::$RUST_VERSION"
- name: Login to Docker Hub
if: ${{ github.event.repository.full_name }} == 'lf-edge/eve-rust'
uses: docker/login-action@v3
with:
username: ${{ secrets.RELEASE_DOCKERHUB_ACCOUNT }}
password: ${{ secrets.RELEASE_DOCKERHUB_TOKEN }}
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- uses: docker/build-push-action@v5
with:
context: .
platforms: linux/amd64,linux/arm64
push: true
tags: |
${{ env.OCIREPO }}:${{ steps.rust_version.outputs.RUST_VERSION }}
${{ env.OCIREPO }}:latest
3 changes: 2 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
FROM rust:1.80.1-alpine3.19
ARG RUST_VERSION=1.80.1
FROM rust:${RUST_VERSION}-alpine3.19
ENV TARGETS x86_64-unknown-linux-musl aarch64-unknown-linux-musl x86_64-unknown-linux-gnu aarch64-unknown-linux-gnu riscv64gc-unknown-linux-gnu
RUN rustup target add x86_64-unknown-linux-musl
RUN cargo install cargo-chef cargo-sbom
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -72,3 +72,6 @@ as an already-released image of `eve-rust`, we will append a patch version to th
is released, and we need to add a new cargo plugin or build target, we will release `eve-rust:1.80.1-1`, where `-1` is
the sequential `eve-rust` patch version. This will be very short-lived, only as long as we need to get to the next
version of rust.

New versions are released to Docker Hub by adding a tag, e.g. `1.80.1` or `1.80.1-1`. The GitHub Actions workflow
checks that it matches the version in the Dockerfile, and if it does not, it will fail the build.

0 comments on commit 36f41d1

Please sign in to comment.