Skip to content

Commit 36f41d1

Browse files
committed
add github workflows
Signed-off-by: Avi Deitcher <[email protected]>
1 parent 911c40d commit 36f41d1

File tree

4 files changed

+109
-1
lines changed

4 files changed

+109
-1
lines changed

.github/workflows/build.yaml

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
---
2+
name: PR build
3+
on:
4+
pull_request_target:
5+
paths-ignore:
6+
- '.github/workflows/**'
7+
branches:
8+
- "main"
9+
push:
10+
branches:
11+
- "main"
12+
13+
14+
concurrency:
15+
group: ${{ github.workflow }}-${{ github.event.pull_request.number }}
16+
cancel-in-progress: true
17+
18+
jobs:
19+
build:
20+
runs-on: ubuntu-latest
21+
strategy:
22+
fail-fast: false
23+
steps:
24+
- name: Starting Report
25+
run: |
26+
echo Git Ref: ${{ github.event.pull_request.head.ref }}
27+
echo GitHub Event: ${{ github.event_name }}
28+
echo Disk usage
29+
df -h
30+
echo Memory
31+
free -m
32+
- uses: actions/checkout@v4
33+
with:
34+
repository: ${{ github.event.pull_request.head.repo.full_name }}
35+
ref: ${{ github.event.pull_request.head.ref }}
36+
fetch-depth: 0
37+
- name: Set up QEMU
38+
uses: docker/setup-qemu-action@v3
39+
- name: Set up Docker Buildx
40+
uses: docker/setup-buildx-action@v3
41+
- uses: docker/build-push-action@v5
42+
with:
43+
context: .
44+
platforms: linux/amd64,linux/arm64
45+
push: false
46+
tags: |
47+
${{ github.event.pull_request.head.repo.full_name }}:${{ github.event.pull_request.head.ref }}
48+
${{ github.event.pull_request.head.repo.full_name }}:latest
49+

.github/workflows/release.yaml

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
name: release
2+
on:
3+
push:
4+
tags:
5+
- "[0-9]+.[0-9]+.[0-9]+"
6+
paths-ignore:
7+
- '.github/workflows/**'
8+
9+
env:
10+
OCIREPO: lfedge/eve-rust
11+
12+
jobs:
13+
build_and_push:
14+
runs-on: ubuntu-latest
15+
strategy:
16+
fail-fast: false
17+
steps:
18+
- uses: actions/checkout@v4
19+
with:
20+
fetch-depth: 0
21+
- name: Get rust version
22+
id: rust_version
23+
run: |
24+
RUST_VERSION=$(awk -F= '/ARG RUST_VERSION/ {print $2}' Dockerfile)
25+
# make sure we got a rust version
26+
if [ -z "$RUST_VERSION" ]; then
27+
echo "Failed to get RUST_VERSION"
28+
exit 1
29+
fi
30+
# strip off any potential eve-specific extensions to the tag
31+
TAG="${{ github.ref_name }}"
32+
TAG="${TAG%%-*}"
33+
if [ "$TAG" != "$RUST_VERSION" ]; then
34+
echo "Tag $TAG does not match RUST_VERSION $RUST_VERSION"
35+
exit 1
36+
fi
37+
echo "::set-output name=RUST_VERSION::$RUST_VERSION"
38+
- name: Login to Docker Hub
39+
if: ${{ github.event.repository.full_name }} == 'lf-edge/eve-rust'
40+
uses: docker/login-action@v3
41+
with:
42+
username: ${{ secrets.RELEASE_DOCKERHUB_ACCOUNT }}
43+
password: ${{ secrets.RELEASE_DOCKERHUB_TOKEN }}
44+
- name: Set up QEMU
45+
uses: docker/setup-qemu-action@v3
46+
- name: Set up Docker Buildx
47+
uses: docker/setup-buildx-action@v3
48+
- uses: docker/build-push-action@v5
49+
with:
50+
context: .
51+
platforms: linux/amd64,linux/arm64
52+
push: true
53+
tags: |
54+
${{ env.OCIREPO }}:${{ steps.rust_version.outputs.RUST_VERSION }}
55+
${{ env.OCIREPO }}:latest

Dockerfile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
FROM rust:1.80.1-alpine3.19
1+
ARG RUST_VERSION=1.80.1
2+
FROM rust:${RUST_VERSION}-alpine3.19
23
ENV TARGETS x86_64-unknown-linux-musl aarch64-unknown-linux-musl x86_64-unknown-linux-gnu aarch64-unknown-linux-gnu riscv64gc-unknown-linux-gnu
34
RUN rustup target add x86_64-unknown-linux-musl
45
RUN cargo install cargo-chef cargo-sbom

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,3 +72,6 @@ as an already-released image of `eve-rust`, we will append a patch version to th
7272
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
7373
the sequential `eve-rust` patch version. This will be very short-lived, only as long as we need to get to the next
7474
version of rust.
75+
76+
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
77+
checks that it matches the version in the Dockerfile, and if it does not, it will fail the build.

0 commit comments

Comments
 (0)