Skip to content

Commit

Permalink
Restore Actions
Browse files Browse the repository at this point in the history
  • Loading branch information
mkjsix committed Aug 9, 2024
1 parent 9390eb1 commit 5919308
Show file tree
Hide file tree
Showing 3 changed files with 79 additions and 143 deletions.
94 changes: 33 additions & 61 deletions .github/workflows/branch.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,135 +10,107 @@ on:
- "*"

jobs:
build_and_test:
runs-on: ubuntu-22.04
build:
if: "!contains(github.event.head_commit.message, 'skip ci')"
runs-on: ubuntu-22.04
strategy:
matrix:
include:
- mongodb-version: "5.0"
- mongodb-version: "6.0"
- mongodb-version: "7.0"
deploy: true
outputs:
deploy: ${{ steps.set_output.outputs.deploy }}
version: ${{ steps.vars.outputs.VERSION }}
timeout-minutes: 20
steps:
- uses: actions/checkout@v4
- uses: actions/cache@v4
with:
path: ~/.m2/repository
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
restore-keys: |
${{ runner.os }}-maven-
- name: Set up JDK 21
uses: actions/setup-java@v4
with:
distribution: "temurin"
java-version: "21"

- name: Set the VERSION and SHA
- name: Set VERSION and SHA
id: vars
run: |
echo "VERSION=$(echo ${GITHUB_REF:10})" >> $GITHUB_ENV
echo "SHA=$(echo ${GITHUB_SHA:0:7})" >> $GITHUB_ENV
echo "VERSION=${{ steps.vars.outputs.VERSION }}" >> $GITHUB_OUTPUT
echo "SHA=${{ steps.vars.outputs.SHA }}" >> $GITHUB_OUTPUT
- name: Set deploy output
id: set_output
run: echo "deploy=${{ matrix.deploy }}" >> $GITHUB_OUTPUT

- name: Cache Maven Repository
uses: actions/cache@v4
with:
path: ~/.m2/repository
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
restore-keys: |
${{ runner.os }}-maven-
- uses: actions/checkout@v4
echo "VERSION=$(echo ${GITHUB_REF:10})" >> $GITHUB_OUTPUT
echo "SHA=$(echo ${GITHUB_SHA:0:7})" >> $GITHUB_OUTPUT
echo "VERSION=${{steps.vars.outputs.VERSION}}"
echo "SHA=${{steps.vars.outputs.SHA}}"
- name: Build and Test
if: ${{ ! matrix.deploy }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any
run: mvn -B clean verify -Dmongodb.version="${{ matrix.mongodb-version }}"

deploy:
runs-on: ubuntu-22.04
needs: build_and_test
if: "!contains(github.event.head_commit.message, 'skip ci') && needs.build_and_test.outputs.deploy == 'true'"
steps:
- uses: actions/checkout@v4
run: mvn -B clean verify -Dmongodb.version="${{ matrix.mongodb-version }}" -Dkarate.options="${{ matrix.karate-options }}"

- name: Set up JDK 21
uses: actions/setup-java@v4
with:
distribution: "temurin"
java-version: "21"

- name: Import private GPG key
- name: Import private gpg key
if: ${{ matrix.deploy }}
run: |
printf "%s" "$GPG_PRIVATE_KEY" > private.key
gpg --pinentry-mode=loopback --batch --yes --fast-import private.key
rm private.key
env:
GPG_PRIVATE_KEY: ${{ secrets.GPG_PRIVATE_KEY }}

- name: Deploy to Maven Central
if: ${{ matrix.deploy }}
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 -s settings.xml
env:
OSSRH_USERNAME: ${{ secrets.OSSRH_USERNAME }}
OSSRH_PASSWORD: ${{ secrets.OSSRH_PASSWORD }}
GPG_KEY_NAME: ${{ secrets.GPG_KEY_NAME }}
GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }}
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 -s settings.xml

- name: Set up QEMU
if: ${{ matrix.deploy }}
uses: docker/setup-qemu-action@v3

- name: Set up Docker Buildx
if: ${{ matrix.deploy }}
uses: docker/setup-buildx-action@v3

- name: Login to DockerHub
if: ${{ matrix.deploy }}
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKER_USER }}
password: ${{ secrets.DOCKER_TOKEN }}

- name: Build and Push multi-arch Docker images
if: ${{ matrix.deploy }}
uses: docker/build-push-action@v6
with:
context: ./core/
platforms: |
linux/amd64,
linux/arm64/v8,
linux/ppc64le,
linux/s390x
platforms: linux/amd64,linux/arm64/v8,linux/ppc64le,linux/s390x
push: true # push all images built
pull: true # pull all required images before building
# NOTE: snapshot images must be tagged with "latest" in master branch only
tags: |
softinstigate/restheart-snapshot:latest,
softinstigate/restheart-snapshot:${{ needs.build_and_test.outputs.SHA }}
tags: softinstigate/restheart-snapshot:latest,softinstigate/restheart-snapshot:${{steps.vars.outputs.SHA}}

- name: Build and Push GraalVM Docker image
if: ${{ matrix.deploy }}
uses: docker/build-push-action@v6
with:
context: ./core/
file: ./core/Dockerfile.graalvm
push: true # push all images built
pull: true # pull all required images before building
# NOTE: snapshot images must be tagged with "graalvm" in master branch only
tags: |
softinstigate/restheart-snapshot:graalvm,
softinstigate/restheart-snapshot:${{ needs.build_and_test.outputs.SHA }}-graalvm
tags: softinstigate/restheart-snapshot:graalvm,softinstigate/restheart-snapshot:${{steps.vars.outputs.SHA}}-graalvm

- name: Build and Push distroless Docker image
- name: Build and Push distroless docker image
if: ${{ matrix.deploy }}
uses: docker/build-push-action@v6
with:
context: ./core/
file: ./core/Dockerfile.distroless
push: true # push all images built
pull: true # pull all required images before building
# NOTE: snapshot images must be tagged with "distroless" in master branch only
tags: |
softinstigate/restheart-snapshot:distroless,
softinstigate/restheart-snapshot:${{ needs.build_and_test.outputs.SHA }}-distroless
tags: softinstigate/restheart-snapshot:distroless,softinstigate/restheart-snapshot:${{steps.vars.outputs.SHA}}-distroless
34 changes: 16 additions & 18 deletions .github/workflows/pullrequests.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# This workflow builds and tests pull requests
# This workflow build and test pull requests

name: Build pull request

Expand All @@ -9,34 +9,32 @@ on:
types: [opened, synchronize, reopened]

jobs:
build_and_test:
build:
runs-on: ubuntu-22.04
strategy:
matrix:
mongodb-version: ["5.0", "6.0", "7.0"]
include:
- mongodb-version: "5.0"
- mongodb-version: "6.0"
- mongodb-version: "7.0"
deploy: true
timeout-minutes: 20
steps:
- name: Set up JDK 21
uses: actions/setup-java@v4
with:
distribution: "temurin"
java-version: "21"

- name: Cache Maven Repository
uses: actions/cache@v4
- uses: actions/checkout@v4
- uses: actions/cache@v4
with:
path: ~/.m2/repository
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
restore-keys: |
${{ runner.os }}-maven-
- uses: actions/checkout@v4
- name: Set up JDK 21
uses: actions/setup-java@v4
with:
distribution: "temurin"
java-version: "21"

- name: Build and Test
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any
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 clean verify -Dmongodb.version="${{ matrix.mongodb-version }}"
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 clean verify -Dmongodb.version="${{ matrix.mongodb-version }}" -Dkarate.options="${{ matrix.karate-options }}"
94 changes: 30 additions & 64 deletions .github/workflows/tags.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,20 +10,26 @@ on:
- "*"

jobs:
build_and_test:
runs-on: ubuntu-22.04
build:
if: "!contains(github.event.head_commit.message, 'skip ci')"
runs-on: ubuntu-22.04
strategy:
matrix:
include:
- mongodb-version: "5.0"
- mongodb-version: "6.0"
- mongodb-version: "7.0"
deploy: true
outputs:
deploy: ${{ steps.set_output.outputs.deploy }}
version: ${{ steps.vars.outputs.VERSION }}
timeout-minutes: 20
steps:
- uses: actions/checkout@v4
- uses: actions/cache@v4
with:
path: ~/.m2/repository
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
restore-keys: |
${{ runner.os }}-maven-
- name: Set up JDK 21
uses: actions/setup-java@v4
with:
Expand All @@ -33,119 +39,79 @@ jobs:
- name: Set the VERSION
id: vars
run: |
echo "VERSION=$(echo ${GITHUB_REF:10})" >> $GITHUB_ENV
echo "VERSION=${{ steps.vars.outputs.VERSION }}" >> $GITHUB_OUTPUT
- name: Set deploy output
id: set_output
run: echo "deploy=${{ matrix.deploy }}" >> $GITHUB_OUTPUT

- name: Cache Maven Repository
uses: actions/cache@v4
with:
path: ~/.m2/repository
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
restore-keys: |
${{ runner.os }}-maven-
- uses: actions/checkout@v4
echo "VERSION=$(echo ${GITHUB_REF:10})" >> $GITHUB_OUTPUT
echo "VERSION=${{steps.vars.outputs.VERSION}}"
- name: Build and Test
if: ${{ ! matrix.deploy }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any
run: mvn -B clean verify -Dmongodb.version="${{ matrix.mongodb-version }}"

deploy:
runs-on: ubuntu-22.04
needs: build_and_test
if: "!contains(github.event.head_commit.message, 'skip ci') && needs.build_and_test.outputs.deploy == 'true'"
steps:
- uses: actions/checkout@v4
run: mvn -B clean verify -Dmongodb.version="${{ matrix.mongodb-version }}" -Dkarate.options="${{ matrix.karate-options }}"

- name: Set up JDK 21
uses: actions/setup-java@v4
with:
distribution: "temurin"
java-version: "21"

- name: Import private GPG key
- name: Import private gpg key
if: ${{ matrix.deploy }}
run: |
printf "%s" "$GPG_PRIVATE_KEY" > private.key
gpg --pinentry-mode=loopback --batch --yes --fast-import private.key
rm private.key
env:
GPG_PRIVATE_KEY: ${{ secrets.GPG_PRIVATE_KEY }}

- name: Deploy to Maven Central
if: ${{ matrix.deploy }}
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 -s settings.xml
env:
OSSRH_USERNAME: ${{ secrets.OSSRH_USERNAME }}
OSSRH_PASSWORD: ${{ secrets.OSSRH_PASSWORD }}
GPG_KEY_NAME: ${{ secrets.GPG_KEY_NAME }}
GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }}
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 -s settings.xml

- name: Set up QEMU
if: ${{ matrix.deploy }}
uses: docker/setup-qemu-action@v3

- name: Set up Docker Buildx
if: ${{ matrix.deploy }}
uses: docker/setup-buildx-action@v3

- name: Login to DockerHub
if: ${{ matrix.deploy }}
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKER_USER }}
password: ${{ secrets.DOCKER_TOKEN }}

- name: Build and Push multi-arch Docker images
if: ${{ matrix.deploy }}
uses: docker/build-push-action@v6
with:
context: ./core/
platforms: linux/amd64,linux/arm64/v8,linux/ppc64le,linux/s390x
push: true # push all images built
pull: true # pull all required images before building
tags: |
softinstigate/restheart:latest,
softinstigate/restheart:8,
softinstigate/restheart:8.0,
softinstigate/restheart:${{ needs.build_and_test.outputs.version }}
tags: softinstigate/restheart:latest,softinstigate/restheart:8,softinstigate/restheart:8.0,softinstigate/restheart:${{steps.vars.outputs.VERSION}}

- name: Build and Push GraalVM Docker image
if: ${{ matrix.deploy }}
uses: docker/build-push-action@v6
with:
context: ./core/
file: ./core/Dockerfile.graalvm
push: true # push all images built
pull: true # pull all required images before building
tags: |
softinstigate/restheart:graalvm,
softinstigate/restheart:latest-graalvm,
softinstigate/restheart:8-graalvm,
softinstigate/restheart:${{ needs.build_and_test.outputs.version }}-graalvm
tags: softinstigate/restheart:graalvm,softinstigate/restheart:latest-graalvm,softinstigate/restheart:8-graalvm,softinstigate/restheart:${{steps.vars.outputs.VERSION}}-graalvm

- name: Build and Push distroless Docker image
- name: Build and Push distroless docker image
if: ${{ matrix.deploy }}
uses: docker/build-push-action@v6
with:
context: ./core/
file: ./core/Dockerfile.distroless
push: true # push all images built
pull: true # pull all required images before building
tags: |
softinstigate/restheart:distroless,
softinstigate/restheart:latest-distroless,
softinstigate/restheart:8-distroless,
softinstigate/restheart:${{ needs.build_and_test.outputs.version }}-distroless
tags: softinstigate/restheart:distroless,softinstigate/restheart:latest-distroless,softinstigate/restheart:8-distroless,softinstigate/restheart:${{steps.vars.outputs.VERSION}}-distroless

release:
runs-on: ubuntu-22.04
needs: deploy
if: "!contains(github.event.head_commit.message, 'skip ci') && needs.build_and_test.outputs.deploy == 'true'"
steps:
- name: Upload GitHub release
if: ${{ matrix.deploy }}
uses: softprops/action-gh-release@v2
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
Expand Down

0 comments on commit 5919308

Please sign in to comment.