Skip to content

Commit 28fa938

Browse files
committed
fix: Add Cross.toml for aarch64 sysroot, OCI labels for GHCR, metadata-action for proper tagging
1 parent b6c475e commit 28fa938

3 files changed

Lines changed: 63 additions & 34 deletions

File tree

.github/workflows/release.yml

Lines changed: 48 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -65,18 +65,28 @@ jobs:
6565
- os: ubuntu-latest
6666
target: x86_64-unknown-linux-gnu
6767
asset_name: streamforge-linux-x86_64
68-
- os: ubuntu-22.04
68+
69+
- os: ubuntu-latest
6970
target: aarch64-unknown-linux-gnu
7071
asset_name: streamforge-linux-aarch64
72+
7173
- os: macos-latest
7274
target: aarch64-apple-darwin
7375
asset_name: streamforge-macos-aarch64
7476

7577
steps:
7678
- uses: actions/checkout@v4
7779

78-
- name: Install system dependencies (Linux)
79-
if: runner.os == 'Linux'
80+
- name: Install Rust
81+
uses: dtolnay/rust-toolchain@stable
82+
with:
83+
targets: ${{ matrix.target }}
84+
85+
- name: Cache cargo
86+
uses: Swatinem/rust-cache@v2
87+
88+
- name: Install system dependencies (Linux x86_64)
89+
if: matrix.target == 'x86_64-unknown-linux-gnu'
8090
run: |
8191
sudo apt-get update
8292
sudo apt-get install -y \
@@ -100,23 +110,17 @@ jobs:
100110
echo "OPENSSL_DIR=$(brew --prefix openssl@3)" >> $GITHUB_ENV
101111
echo "PKG_CONFIG_PATH=$(brew --prefix openssl@3)/lib/pkgconfig:$(brew --prefix cyrus-sasl)/lib/pkgconfig" >> $GITHUB_ENV
102112
103-
- name: Install Rust
104-
uses: dtolnay/rust-toolchain@stable
105-
with:
106-
targets: ${{ matrix.target }}
107-
108-
- name: Cache cargo
109-
uses: Swatinem/rust-cache@v2
113+
- name: Build (native — x86_64 and macOS)
114+
if: matrix.target != 'aarch64-unknown-linux-gnu'
115+
run: cargo build --release --locked --target ${{ matrix.target }}
110116

111-
- name: Build release binary
112-
run: |
113-
if [ "${{ matrix.target }}" = "aarch64-unknown-linux-gnu" ]; then
114-
cross build --release --locked --target ${{ matrix.target }}
115-
else
116-
cargo build --release --locked --target ${{ matrix.target }}
117-
fi
117+
- name: Build (cross — Linux aarch64)
118+
if: matrix.target == 'aarch64-unknown-linux-gnu'
119+
env:
120+
PKG_CONFIG_ALLOW_CROSS: "1"
121+
run: cross build --release --locked --target ${{ matrix.target }}
118122

119-
- name: Strip binary
123+
- name: Strip binary (native only)
120124
if: matrix.target != 'aarch64-unknown-linux-gnu'
121125
run: strip target/${{ matrix.target }}/release/streamforge
122126

@@ -132,6 +136,9 @@ jobs:
132136
name: Build and Push Docker Images
133137
runs-on: ubuntu-latest
134138
continue-on-error: true
139+
permissions:
140+
contents: read
141+
packages: write
135142
steps:
136143
- uses: actions/checkout@v4
137144

@@ -148,11 +155,14 @@ jobs:
148155
username: ${{ github.actor }}
149156
password: ${{ secrets.GITHUB_TOKEN }}
150157

151-
- name: Extract version
152-
id: version
153-
run: |
154-
TAG="${{ github.event.inputs.tag || github.ref_name }}"
155-
echo "VERSION=${TAG#v}" >> $GITHUB_OUTPUT
158+
- name: Extract metadata (tags and labels)
159+
id: meta
160+
uses: docker/metadata-action@v5
161+
with:
162+
images: ghcr.io/${{ github.repository }}
163+
tags: |
164+
type=semver,pattern={{version}},value=${{ github.event.inputs.tag || github.ref_name }}
165+
type=raw,value=latest
156166
157167
- name: Build and push multi-arch Docker image
158168
uses: docker/build-push-action@v5
@@ -161,16 +171,18 @@ jobs:
161171
file: ./Dockerfile
162172
push: true
163173
platforms: linux/amd64,linux/arm64
164-
tags: |
165-
ghcr.io/${{ github.repository }}:${{ steps.version.outputs.VERSION }}
166-
ghcr.io/${{ github.repository }}:latest
174+
tags: ${{ steps.meta.outputs.tags }}
175+
labels: ${{ steps.meta.outputs.labels }}
167176
cache-from: type=gha
168177
cache-to: type=gha,mode=max
169178

170179
build-operator-image:
171180
name: Build and Push Operator Image
172181
runs-on: ubuntu-latest
173182
continue-on-error: true
183+
permissions:
184+
contents: read
185+
packages: write
174186
steps:
175187
- uses: actions/checkout@v4
176188

@@ -187,11 +199,14 @@ jobs:
187199
username: ${{ github.actor }}
188200
password: ${{ secrets.GITHUB_TOKEN }}
189201

190-
- name: Extract version
191-
id: version
192-
run: |
193-
TAG="${{ github.event.inputs.tag || github.ref_name }}"
194-
echo "VERSION=${TAG#v}" >> $GITHUB_OUTPUT
202+
- name: Extract metadata
203+
id: meta
204+
uses: docker/metadata-action@v5
205+
with:
206+
images: ghcr.io/${{ github.repository }}-operator
207+
tags: |
208+
type=semver,pattern={{version}},value=${{ github.event.inputs.tag || github.ref_name }}
209+
type=raw,value=latest
195210
196211
- name: Build and push Operator image
197212
uses: docker/build-push-action@v5
@@ -200,8 +215,7 @@ jobs:
200215
file: ./operator/Dockerfile
201216
push: true
202217
platforms: linux/amd64,linux/arm64
203-
tags: |
204-
ghcr.io/${{ github.repository }}-operator:${{ steps.version.outputs.VERSION }}
205-
ghcr.io/${{ github.repository }}-operator:latest
218+
tags: ${{ steps.meta.outputs.tags }}
219+
labels: ${{ steps.meta.outputs.labels }}
206220
cache-from: type=gha
207221
cache-to: type=gha,mode=max

Cross.toml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
[target.aarch64-unknown-linux-gnu]
2+
pre-build = [
3+
"dpkg --add-architecture $CROSS_DEB_ARCH",
4+
"apt-get update && apt-get install -y --no-install-recommends libssl-dev:$CROSS_DEB_ARCH libsasl2-dev:$CROSS_DEB_ARCH libzstd-dev:$CROSS_DEB_ARCH libcurl4-openssl-dev:$CROSS_DEB_ARCH pkg-config"
5+
]
6+
7+
[build.env]
8+
passthrough = [
9+
"PKG_CONFIG_ALLOW_CROSS",
10+
"CARGO_TERM_COLOR"
11+
]

Dockerfile

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,10 @@ RUN touch src/main.rs && \
3535
# Stage 2: Runtime
3636
FROM cgr.dev/chainguard/rust:latest
3737

38+
LABEL org.opencontainers.image.source="https://github.com/rahulbsw/streamforge"
39+
LABEL org.opencontainers.image.description="High-performance Kafka streaming toolkit"
40+
LABEL org.opencontainers.image.licenses="Apache-2.0"
41+
3842
# Copy binary from builder
3943
COPY --from=builder /build/target/release/streamforge /usr/local/bin/streamforge
4044

0 commit comments

Comments
 (0)