Skip to content

Commit 227ea1e

Browse files
nicklaslclaude
andauthored
ci: build Rust crates with Docker for publishing (#302)
Co-authored-by: Claude <noreply@anthropic.com>
1 parent 78b7423 commit 227ea1e

File tree

2 files changed

+46
-32
lines changed

2 files changed

+46
-32
lines changed

.github/workflows/release-please.yml

Lines changed: 26 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -210,24 +210,21 @@ jobs:
210210
- name: Checkout release tag
211211
uses: actions/checkout@v4
212212

213-
- name: Install stable toolchain
214-
uses: actions-rs/toolchain@v1
215-
with:
216-
profile: minimal
217-
toolchain: stable
218-
override: true
219-
220-
- name: Install protoc
221-
uses: arduino/setup-protoc@v3
222-
with:
223-
repo-token: ${{ secrets.GITHUB_TOKEN }}
213+
- name: Set up Docker Buildx
214+
uses: docker/setup-buildx-action@v3
224215

225-
- name: Cargo login
226-
run: cargo login ${{ secrets.CRATES_IO_TOKEN }}
216+
- name: Write crates.io token to file
217+
run: |
218+
echo "${{ secrets.CRATES_IO_TOKEN }}" > /tmp/crates_io_token.txt
227219
228-
- name: Publish to crates.io
229-
working-directory: confidence-resolver
230-
run: cargo publish
220+
- name: Publish confidence-resolver with Docker
221+
uses: docker/build-push-action@v6
222+
with:
223+
context: .
224+
target: confidence-resolver.publish
225+
cache-from: type=registry,ref=ghcr.io/${{ github.repository }}/cache:main
226+
secret-files: |
227+
crates_io_token=/tmp/crates_io_token.txt
231228
232229
publish-rust-provider-release:
233230
needs: [release, publish-confidence-resolver-release]
@@ -241,28 +238,25 @@ jobs:
241238
- name: Checkout release tag
242239
uses: actions/checkout@v4
243240

244-
- name: Install stable toolchain
245-
uses: actions-rs/toolchain@v1
246-
with:
247-
profile: minimal
248-
toolchain: stable
249-
override: true
250-
251-
- name: Install protoc
252-
uses: arduino/setup-protoc@v3
253-
with:
254-
repo-token: ${{ secrets.GITHUB_TOKEN }}
241+
- name: Set up Docker Buildx
242+
uses: docker/setup-buildx-action@v3
255243

256-
- name: Cargo login
257-
run: cargo login ${{ secrets.CRATES_IO_TOKEN }}
244+
- name: Write crates.io token to file
245+
run: |
246+
echo "${{ secrets.CRATES_IO_TOKEN }}" > /tmp/crates_io_token.txt
258247
259248
- name: Wait for crates.io index update
260249
if: ${{ needs.publish-confidence-resolver-release.result == 'success' }}
261250
run: sleep 30
262251

263-
- name: Publish to crates.io
264-
working-directory: openfeature-provider/rust
265-
run: cargo publish
252+
- name: Publish Rust provider with Docker
253+
uses: docker/build-push-action@v6
254+
with:
255+
context: .
256+
target: openfeature-provider-rust.publish
257+
cache-from: type=registry,ref=ghcr.io/${{ github.repository }}/cache:main
258+
secret-files: |
259+
crates_io_token=/tmp/crates_io_token.txt
266260
267261
publish-python-provider-release:
268262
needs: release

Dockerfile

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -606,6 +606,26 @@ FROM rust-test-base AS openfeature-provider-rust.build
606606
WORKDIR /workspace/openfeature-provider/rust
607607
RUN make build
608608

609+
# ==============================================================================
610+
# Publish confidence-resolver to crates.io
611+
# ==============================================================================
612+
FROM openfeature-provider-rust.build AS confidence-resolver.publish
613+
614+
WORKDIR /workspace/confidence-resolver
615+
RUN --mount=type=secret,id=crates_io_token \
616+
cargo login $(cat /run/secrets/crates_io_token) && \
617+
cargo publish
618+
619+
# ==============================================================================
620+
# Publish OpenFeature Provider (Rust) to crates.io
621+
# ==============================================================================
622+
FROM openfeature-provider-rust.build AS openfeature-provider-rust.publish
623+
624+
WORKDIR /workspace/openfeature-provider/rust
625+
RUN --mount=type=secret,id=crates_io_token \
626+
cargo login $(cat /run/secrets/crates_io_token) && \
627+
cargo publish
628+
609629
# ==============================================================================
610630
# OpenFeature Provider (Java) - Build and test
611631
# ==============================================================================

0 commit comments

Comments
 (0)