Skip to content

Commit a96a3a9

Browse files
committed
build: experimenting -- do not merge
1 parent 1ea86ea commit a96a3a9

File tree

3 files changed

+87
-9
lines changed

3 files changed

+87
-9
lines changed
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
name: Secrets Testing
2+
3+
on:
4+
push:
5+
branches: [main,build-secrets-testing]
6+
pull_request:
7+
workflow_dispatch:
8+
9+
permissions:
10+
contents: read
11+
packages: write
12+
13+
jobs:
14+
secrets-testing:
15+
name: Secrets Testing
16+
runs-on: ubuntu-latest
17+
steps:
18+
- name: Checkout
19+
uses: actions/checkout@v4
20+
21+
- name: Set up Docker Buildx
22+
uses: docker/setup-buildx-action@v3
23+
24+
- name: Construct Maven settings file
25+
run: |
26+
cat > /tmp/maven_settings.xml <<'EOF'
27+
<?xml version="1.0" encoding="UTF-8"?>
28+
<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"
29+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
30+
xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0
31+
http://maven.apache.org/xsd/settings-1.0.0.xsd">
32+
<servers>
33+
<server>
34+
<id>central</id>
35+
<username>${{ secrets.MAVEN_CENTRAL_USERNAME }}</username>
36+
<password>${{ secrets.MAVEN_CENTRAL_PASSWORD }}</password>
37+
</server>
38+
</servers>
39+
</settings>
40+
EOF
41+
42+
- name: Write GPG key and passphrase to files
43+
run: |
44+
echo "${{ secrets.GPG_PRIVATE_KEY }}" > /tmp/gpg_private_key.asc
45+
echo "${{ secrets.SIGN_KEY_PASS }}" > /tmp/gpg_pass.txt
46+
47+
- name: Publish Java package with Docker
48+
uses: docker/build-push-action@v6
49+
with:
50+
context: .
51+
target: openfeature-provider-java.install
52+
cache-from: type=registry,ref=ghcr.io/${{ github.repository }}/cache:main
53+
secret-files: |
54+
maven_settings=/tmp/maven_settings.xml
55+
gpg_private_key=/tmp/gpg_private_key.asc
56+
gpg_pass=/tmp/gpg_pass.txt

Dockerfile

Lines changed: 30 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# syntax=docker/dockerfile:1.4
1+
# syntax=docker/dockerfile:1
22

33
# ==============================================================================
44
# Base image with Rust toolchain (Alpine - more reliable than Debian)
@@ -416,6 +416,15 @@ FROM openfeature-provider-js.test AS openfeature-provider-js.test_e2e
416416
RUN --mount=type=secret,id=js_e2e_test_env,target=.env.test \
417417
make test-e2e
418418

419+
# ==============================================================================
420+
# Test Secrets
421+
# ==============================================================================
422+
FROM alpine AS secrets-testing.print
423+
424+
# Never do this at home kids!
425+
RUN --mount=type=secret,id=test_secret,target=/run/secrets/secret.txt \
426+
cp /run/secrets/secret.txt /secret.txt
427+
419428
# ==============================================================================
420429
# Build OpenFeature Provider
421430
# ==============================================================================
@@ -485,19 +494,32 @@ FROM openfeature-provider-java-base AS openfeature-provider-java.build
485494

486495
RUN make build
487496

497+
# ==============================================================================
498+
# Publish OpenFeature Provider (Java) to Maven Central
499+
# ==============================================================================
500+
FROM openfeature-provider-java.build AS openfeature-provider-java.install
501+
502+
RUN --mount=type=secret,id=gpg_private_key \
503+
gpg --batch --pinentry-mode loopback --import /run/secrets/gpg_private_key
504+
505+
RUN --mount=type=secret,id=maven_settings \
506+
--mount=type=secret,id=gpg_pass,env=MAVEN_GPG_PASSPHRASE \
507+
mvn -q -s /run/secrets/maven_settings --batch-mode install \
508+
-Dgpg.pinentry-mode=loopback
509+
488510
# ==============================================================================
489511
# Publish OpenFeature Provider (Java) to Maven Central
490512
# ==============================================================================
491513
FROM openfeature-provider-java.build AS openfeature-provider-java.publish
492514

493515
# Import GPG private key and deploy to Maven Central
494-
RUN --mount=type=secret,id=maven_settings,target=/root/.m2/settings.xml \
495-
--mount=type=secret,id=gpg_private_key \
496-
--mount=type=secret,id=gpg_pass \
497-
# Import GPG key
498-
cat /run/secrets/gpg_private_key | gpg --batch --import && \
499-
# Deploy to Maven Central
500-
mvn -Dgpg.passphrase="$(cat /run/secrets/gpg_pass)" --batch-mode deploy
516+
RUN --mount=type=secret,id=gpg_private_key \
517+
gpg --batch --pinentry-mode loopback --import /run/secrets/gpg_private_key
518+
519+
RUN --mount=type=secret,id=maven_settings \
520+
--mount=type=secret,id=gpg_pass,env=MAVEN_GPG_PASSPHRASE \
521+
mvn -s /run/secrets/maven_settings --batch-mode deploy \
522+
-Dgpg.pinentry-mode=loopback
501523

502524
# ==============================================================================
503525
# All - Build and validate everything (default target)

openfeature-provider/java/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ $(RESOURCES_WASM): $(LOCAL_WASM)
2424
@cp -p $(LOCAL_WASM) $@
2525

2626
$(BUILD_STAMP): pom.xml $(RESOURCES_WASM) $(SRC)
27-
mvn package -DskipTests
27+
mvn -q package -DskipTests
2828
@touch $@
2929

3030
build: $(BUILD_STAMP)

0 commit comments

Comments
 (0)