name: Stable Release on: push: branches: - "!master" # Ignore the master branch tags: - "*" # Trigger on any tag jobs: # Build and test the project 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: 10 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 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 # Release the project on GitHub release: if: "!contains(github.event.head_commit.message, 'skip ci')" needs: build runs-on: ubuntu-latest outputs: version: ${{ steps.set_version.outputs.version }} strategy: matrix: mongodb-version: ["8.0"] timeout-minutes: 20 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: Set VERSION id: set_version run: | VERSION=${GITHUB_REF#refs/tags/} echo "VERSION=$VERSION" >> $GITHUB_ENV echo "version=$VERSION" >> $GITHUB_OUTPUT - name: Extract Version Components id: extract_version run: | MAJOR=$(echo "${{ env.VERSION }}" | cut -d '.' -f 1) MINOR=$(echo "${{ env.VERSION }}" | cut -d '.' -f 2) PATCH=$(echo "${{ env.VERSION }}" | cut -d '.' -f 3) # Export the major, minor, and patch versions as environment variables echo "MAJOR=$MAJOR" >> $GITHUB_ENV echo "MINOR=$MINOR" >> $GITHUB_ENV echo "PATCH=$PATCH" >> $GITHUB_ENV - name: Upload GitHub release uses: softprops/action-gh-release@v2 env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} with: body: | # Release ${{ env.VERSION }} files: | core/target/restheart.tar.gz core/target/restheart.zip draft: true prerelease: false build-docker-standard: if: "!contains(github.event.head_commit.message, 'skip ci')" needs: build runs-on: ubuntu-latest strategy: matrix: mongodb-version: ["8.0"] timeout-minutes: 10 steps: - uses: actions/checkout@v4 - name: Download build artifacts uses: actions/download-artifact@v4 with: name: restheart-artifacts path: core/target/ - name: Set VERSION run: | VERSION=${GITHUB_REF#refs/tags/} echo "VERSION=$VERSION" >> $GITHUB_ENV - name: Extract Version Components run: | MAJOR=$(echo "$VERSION" | cut -d '.' -f 1) MINOR=$(echo "$VERSION" | cut -d '.' -f 2) PATCH=$(echo "$VERSION" | cut -d '.' -f 3) echo "MAJOR=$MAJOR" >> $GITHUB_ENV echo "MINOR=$MINOR" >> $GITHUB_ENV echo "PATCH=$PATCH" >> $GITHUB_ENV - name: Set Docker Tags for standard images id: set_tags run: | TAGS="softinstigate/restheart:latest,softinstigate/restheart:$MAJOR,softinstigate/restheart:$MAJOR.$MINOR,softinstigate/restheart:$MAJOR.$MINOR.$PATCH" echo "TAGS=$TAGS" >> $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 uses: docker/build-push-action@v6 with: context: ./core/ platforms: | linux/amd64, linux/arm64, linux/ppc64le, linux/s390x push: true pull: true tags: ${{ env.TAGS }} build-docker-graalvm: if: "!contains(github.event.head_commit.message, 'skip ci')" needs: build runs-on: ubuntu-latest strategy: matrix: mongodb-version: ["8.0"] timeout-minutes: 10 steps: - uses: actions/checkout@v4 - name: Download build artifacts uses: actions/download-artifact@v4 with: name: restheart-artifacts path: core/target/ - name: Set VERSION run: | VERSION=${GITHUB_REF#refs/tags/} echo "VERSION=$VERSION" >> $GITHUB_ENV - name: Extract Version Components run: | MAJOR=$(echo "$VERSION" | cut -d '.' -f 1) MINOR=$(echo "$VERSION" | cut -d '.' -f 2) PATCH=$(echo "$VERSION" | cut -d '.' -f 3) echo "MAJOR=$MAJOR" >> $GITHUB_ENV echo "MINOR=$MINOR" >> $GITHUB_ENV echo "PATCH=$PATCH" >> $GITHUB_ENV - name: Set Docker Tags for GraalVM image id: set_graalvm_tags run: | TAGS_GRAALVM="softinstigate/restheart:latest-graalvm,softinstigate/restheart:$MAJOR-graalvm,softinstigate/restheart:$MAJOR.$MINOR-graalvm,softinstigate/restheart:$MAJOR.$MINOR.$PATCH-graalvm" echo "TAGS_GRAALVM=$TAGS_GRAALVM" >> $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 uses: docker/build-push-action@v6 with: context: ./core/ file: ./core/Dockerfile.graalvm platforms: | linux/amd64, linux/arm64 push: true pull: true tags: ${{ env.TAGS_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"] timeout-minutes: 10 steps: - uses: actions/checkout@v4 - name: Download build artifacts uses: actions/download-artifact@v4 with: name: restheart-artifacts path: core/target/ - name: Set VERSION run: | VERSION=${GITHUB_REF#refs/tags/} echo "VERSION=$VERSION" >> $GITHUB_ENV - name: Extract Version Components run: | MAJOR=$(echo "$VERSION" | cut -d '.' -f 1) MINOR=$(echo "$VERSION" | cut -d '.' -f 2) PATCH=$(echo "$VERSION" | cut -d '.' -f 3) echo "MAJOR=$MAJOR" >> $GITHUB_ENV echo "MINOR=$MINOR" >> $GITHUB_ENV echo "PATCH=$PATCH" >> $GITHUB_ENV - name: Set Docker tags for Distroless image id: set_distroless_tags run: | TAGS_DISTROLESS="softinstigate/restheart:latest-distroless,softinstigate/restheart:$MAJOR-distroless,softinstigate/restheart:$MAJOR.$MINOR-distroless,softinstigate/restheart:$MAJOR.$MINOR.$PATCH-distroless" echo "TAGS_DISTROLESS=$TAGS_DISTROLESS" >> $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 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: ${{ env.TAGS_DISTROLESS }} deploy-maven-central: if: "!contains(github.event.head_commit.message, 'skip ci')" needs: build runs-on: ubuntu-latest strategy: matrix: mongodb-version: ["8.0"] timeout-minutes: 20 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 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 -DskipTests -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 }} # Separate job to call the reusable workflow call-native-image-release: if: "!contains(github.event.head_commit.message, 'skip ci')" needs: release uses: softinstigate/restheart/.github/workflows/native-image-release.yml@master secrets: inherit with: version: "${{ needs.release.outputs.version }}"