refactor: use ARG for Java runtime version in Dockerfile #964
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Snapshot Release | |
on: | |
push: | |
branches: | |
- "*" # All branches for snapshot builds | |
tags-ignore: | |
- "*" # Ignore all tags | |
paths: | |
- "**/*.java" | |
- "**/*.xml" | |
- "**/Dockerfile*" | |
- "**/pom.xml" | |
- ".github/workflows/*.yml" | |
jobs: | |
build: | |
if: "!contains(github.event.head_commit.message, 'skip ci')" | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
mongodb-version: ["5.0", "6.0", "7.0", "8.0"] | |
timeout-minutes: 5 | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Set up JDK 21 | |
uses: actions/setup-java@v4 | |
with: | |
distribution: "temurin" | |
java-version: "21" | |
cache: "maven" | |
- name: Build and Test | |
run: mvn -B clean verify -Dmongodb.version="${{ matrix.mongodb-version }}" | |
- name: Upload build artifacts for Docker jobs (only for 8.0) | |
if: matrix.mongodb-version == '8.0' | |
uses: actions/upload-artifact@v4 | |
with: | |
name: restheart-artifacts | |
path: | | |
core/target/restheart.jar | |
core/target/lib/*.jar | |
core/target/plugins/*.jar | |
core/target/plugins/lib/*.jar | |
deploy-maven-central: | |
if: "!contains(github.event.head_commit.message, 'skip ci')" | |
needs: build | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
mongodb-version: ["8.0"] | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Set up JDK 21 | |
uses: actions/setup-java@v4 | |
with: | |
distribution: "temurin" | |
java-version: "21" | |
cache: "maven" | |
- name: Import private gpg key | |
run: | | |
printf "%s" "$GPG_PRIVATE_KEY" > private.key | |
gpg --pinentry-mode=loopback --batch --yes --fast-import private.key | |
env: | |
GPG_PRIVATE_KEY: ${{ secrets.GPG_PRIVATE_KEY }} | |
- name: Deploy to Maven Central (8.0 only) | |
run: | | |
MAVEN_OPTS="--add-opens=java.base/java.util=ALL-UNNAMED --add-opens=java.base/java.lang.reflect=ALL-UNNAMED --add-opens=java.base/java.text=ALL-UNNAMED --add-opens=java.desktop/java.awt.font=ALL-UNNAMED" \ | |
mvn -B deploy -Pdeploy -Dmongodb.version="${{ matrix.mongodb-version }}" -s settings.xml | |
env: | |
CENTRAL_USERNAME: ${{ secrets.CENTRAL_USERNAME }} | |
CENTRAL_PASSWORD: ${{ secrets.CENTRAL_PASSWORD }} | |
GPG_KEY_NAME: ${{ secrets.GPG_KEY_NAME }} | |
GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }} | |
build-docker-standard: | |
if: "!contains(github.event.head_commit.message, 'skip ci')" | |
needs: build | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
mongodb-version: ["8.0"] | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Download build artifacts | |
uses: actions/download-artifact@v4 | |
with: | |
name: restheart-artifacts | |
path: core/target/ | |
- name: Set SHA | |
run: | | |
echo "SHA=$(echo ${GITHUB_SHA:0:7})" >> $GITHUB_ENV | |
- name: Set up QEMU | |
uses: docker/setup-qemu-action@v3 | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v3 | |
- name: Login to DockerHub | |
uses: docker/login-action@v3 | |
with: | |
username: ${{ secrets.DOCKER_USER }} | |
password: ${{ secrets.DOCKER_TOKEN }} | |
- name: Build and Push multi-arch Docker images (8.0 only) | |
uses: docker/build-push-action@v6 | |
with: | |
context: ./core/ | |
platforms: | | |
linux/amd64, | |
linux/arm64, | |
linux/ppc64le, | |
linux/s390x | |
push: true | |
pull: true | |
tags: | | |
softinstigate/restheart-snapshot:${{ env.SHA }}, | |
${{ github.ref == 'refs/heads/master' && 'softinstigate/restheart-snapshot:latest' || '' }} | |
build-docker-graalvm: | |
if: "!contains(github.event.head_commit.message, 'skip ci')" | |
needs: build | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
mongodb-version: ["8.0"] | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Download build artifacts | |
uses: actions/download-artifact@v4 | |
with: | |
name: restheart-artifacts | |
path: core/target/ | |
- name: Set SHA | |
run: | | |
echo "SHA=$(echo ${GITHUB_SHA:0:7})" >> $GITHUB_ENV | |
- name: Set up QEMU | |
uses: docker/setup-qemu-action@v3 | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v3 | |
- name: Login to DockerHub | |
uses: docker/login-action@v3 | |
with: | |
username: ${{ secrets.DOCKER_USER }} | |
password: ${{ secrets.DOCKER_TOKEN }} | |
- name: Build and Push GraalVM Docker image (8.0 only) | |
uses: docker/build-push-action@v6 | |
with: | |
context: ./core/ | |
file: ./core/Dockerfile.graalvm | |
platforms: | | |
linux/amd64, | |
linux/arm64 | |
push: true | |
pull: true | |
tags: | | |
softinstigate/restheart-snapshot:${{ env.SHA }}-graalvm, | |
${{ github.ref == 'refs/heads/master' && 'softinstigate/restheart-snapshot:latest-graalvm' || '' }} | |
build-docker-distroless: | |
if: "!contains(github.event.head_commit.message, 'skip ci')" | |
needs: build | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
mongodb-version: ["8.0"] | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Download build artifacts | |
uses: actions/download-artifact@v4 | |
with: | |
name: restheart-artifacts | |
path: core/target/ | |
- name: Set SHA | |
run: | | |
echo "SHA=$(echo ${GITHUB_SHA:0:7})" >> $GITHUB_ENV | |
- name: Set up QEMU | |
uses: docker/setup-qemu-action@v3 | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v3 | |
- name: Login to DockerHub | |
uses: docker/login-action@v3 | |
with: | |
username: ${{ secrets.DOCKER_USER }} | |
password: ${{ secrets.DOCKER_TOKEN }} | |
- name: Build and Push distroless docker image (8.0 only) | |
uses: docker/build-push-action@v6 | |
with: | |
context: ./core/ | |
file: ./core/Dockerfile.distroless | |
platforms: | | |
linux/amd64, | |
linux/arm64, | |
linux/ppc64le | |
push: true | |
pull: true | |
tags: | | |
softinstigate/restheart-snapshot:${{ env.SHA }}-distroless, | |
${{ github.ref == 'refs/heads/master' && 'softinstigate/restheart-snapshot:latest-distroless' || '' }} |