Skip to content

Publish package to the Maven Central Repository #179

Publish package to the Maven Central Repository

Publish package to the Maven Central Repository #179

Workflow file for this run

name: Publish package to the Maven Central Repository
on:
push:
pull_request:
branches: [ master ]
jobs:
build:
runs-on: ubuntu-latest
outputs:
cacheKey: ${{ steps.cacheKey.outputs.cacheKey }}
steps:
- run: echo "CACHE_KEY=maven-de-tschuehly-$(date +%s)" >> $GITHUB_ENV
- uses: actions/checkout@v4
- name: Set up Java
uses: actions/setup-java@v4
with:
java-version: '17'
distribution: 'temurin'
cache: 'gradle'
cache-dependency-path: |
thymeleaf/build.gradle.kts
core/build.gradle.kts
jte/build.gradle.kts
kte/build.gradle.kts
- name: make gradle executable
run: chmod +x ./gradlew
- name: publishToMavenLocal
run: ./gradlew :thymeleaf:publishToMavenLocal :jte:publishToMavenLocal :core:publishToMavenLocal :kte:publishToMavenLocal
- name: Cache local Maven repository
uses: actions/cache@v4
with:
path: ~/.m2/repository
key: ${{ env.CACHE_KEY }}
- id: cacheKey
run: echo "cacheKey=${{ env.CACHE_KEY }}" >> $GITHUB_OUTPUT
test-thymeleaf-kotlin:
needs: build
runs-on: ubuntu-latest
steps:
- name: checkout
uses: actions/checkout@v4
- uses: actions/cache@v4
with:
path: ~/.m2/repository
key: ${{ needs.build.outputs.cacheKey }}
- name: Set up Java
uses: actions/setup-java@v4
with:
java-version: '17'
distribution: 'temurin'
cache: 'gradle'
cache-dependency-path: |
examples/thymeleaf-kotlin-example/build.gradle.kts
- name: run thymeleaf kotlin tests
run: |
cd ./examples
chmod +x ./gradlew
./gradlew thymeleaf-kotlin-example:test
test-thymeleaf-java:
needs: build
runs-on: ubuntu-latest
steps:
- name: checkout
uses: actions/checkout@v4
- uses: actions/cache@v4
with:
path: ~/.m2/repository
key: ${{ needs.build.outputs.cacheKey }}
- name: Set up Java
uses: actions/setup-java@v4
with:
java-version: '17'
distribution: 'temurin'
cache: 'gradle'
cache-dependency-path: |
examples/thymeleaf-java-example/build.gradle.kts
- name: run thymeleaf java tests
run: |
cd ./examples
chmod +x ./mvnw
./mvnw -f thymeleaf-java-example test
test-jte:
needs: build
runs-on: ubuntu-latest
steps:
- name: checkout
uses: actions/checkout@v4
- uses: actions/cache@v4
with:
path: ~/.m2/repository
key: ${{ needs.build.outputs.cacheKey }}
- uses: actions/checkout@v4
- name: Set up Java
uses: actions/setup-java@v4
with:
java-version: '17'
distribution: 'temurin'
cache: 'gradle'
cache-dependency-path: |
examples/jte-example/build.gradle.kts
- name: run jte java tests
run: |
cd ./examples/
chmod +x ./gradlew
./gradlew jte-example:test
chmod +x ./mvnw
./mvnw -f jte-example test
test-kte:
needs: build
runs-on: ubuntu-latest
steps:
- name: checkout
uses: actions/checkout@v4
- uses: actions/cache@v4
with:
path: ~/.m2/repository
key: ${{ needs.build.outputs.cacheKey }}
- name: Set up Java
uses: actions/setup-java@v4
with:
java-version: '17'
distribution: 'temurin'
cache: 'gradle'
cache-dependency-path: |
examples/kte-example/build.gradle.kts
- name: run kte kotlin tests
run: |
cd ./examples
chmod +x ./gradlew
./gradlew kte-example:test
publish:
needs: [build, test-jte, test-kte, test-thymeleaf-kotlin, test-thymeleaf-java]
if: github.ref_type == 'tag' || contains(github.ref_name, 'SNAPSHOT')
runs-on: ubuntu-latest
steps:
- name: checkout
uses: actions/checkout@v4
- uses: actions/cache@v4
with:
path: ~/.m2/repository
key: ${{ needs.build.outputs.cacheKey }}
- name: Set up Java
uses: actions/setup-java@v4
with:
java-version: '17'
distribution: 'temurin'
cache: 'gradle'
cache-dependency-path: |
thymeleaf/build.gradle.kts
core/build.gradle.kts
jte/build.gradle.kts
kte/build.gradle.kts
- name: Run chmod to make gradlew executable
run: chmod +x ./gradlew
- name: Publish thymeleaf package to staging
run: ./gradlew :thymeleaf:publish
- name: Publish thymeleaf package to maven central
env:
JRELEASER_NEXUS2_USERNAME: ${{ secrets.JRELEASER_NEXUS2_USERNAME }}
JRELEASER_NEXUS2_PASSWORD: ${{ secrets.JRELEASER_NEXUS2_PASSWORD }}
JRELEASER_GPG_PASSPHRASE: ${{ secrets.JRELEASER_GPG_PASSPHRASE }}
JRELEASER_GPG_SECRET_KEY: ${{ secrets.JRELEASER_GPG_SECRET_KEY }}
JRELEASER_GPG_PUBLIC_KEY: ${{ secrets.JRELEASER_GPG_PUBLIC_KEY }}
JRELEASER_GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: ./gradlew :thymeleaf:jreleaserDeploy -DaltDeploymentRepository=local::file:./thymeleaf/build/staging-deploy --stacktrace
- name: Publish jte package to staging
run: ./gradlew :jte:publish
- name: Publish jte package to maven central
env:
JRELEASER_NEXUS2_USERNAME: ${{ secrets.JRELEASER_NEXUS2_USERNAME }}
JRELEASER_NEXUS2_PASSWORD: ${{ secrets.JRELEASER_NEXUS2_PASSWORD }}
JRELEASER_GPG_PASSPHRASE: ${{ secrets.JRELEASER_GPG_PASSPHRASE }}
JRELEASER_GPG_SECRET_KEY: ${{ secrets.JRELEASER_GPG_SECRET_KEY }}
JRELEASER_GPG_PUBLIC_KEY: ${{ secrets.JRELEASER_GPG_PUBLIC_KEY }}
JRELEASER_GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: ./gradlew :jte:jreleaserDeploy -DaltDeploymentRepository=local::file:./jte/jte/build/staging-deploy --stacktrace
- name: Publish kte package to staging
run: ./gradlew :kte:publish
- name: Publish kte package to maven central
env:
JRELEASER_NEXUS2_USERNAME: ${{ secrets.JRELEASER_NEXUS2_USERNAME }}
JRELEASER_NEXUS2_PASSWORD: ${{ secrets.JRELEASER_NEXUS2_PASSWORD }}
JRELEASER_GPG_PASSPHRASE: ${{ secrets.JRELEASER_GPG_PASSPHRASE }}
JRELEASER_GPG_SECRET_KEY: ${{ secrets.JRELEASER_GPG_SECRET_KEY }}
JRELEASER_GPG_PUBLIC_KEY: ${{ secrets.JRELEASER_GPG_PUBLIC_KEY }}
JRELEASER_GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: ./gradlew :kte:jreleaserDeploy -DaltDeploymentRepository=local::file:./jte/kte/build/staging-deploy --stacktrace
- name: Publish core package to staging
run: ./gradlew :core:publish
- name: Publish core package to maven central
env:
JRELEASER_NEXUS2_USERNAME: ${{ secrets.JRELEASER_NEXUS2_USERNAME }}
JRELEASER_NEXUS2_PASSWORD: ${{ secrets.JRELEASER_NEXUS2_PASSWORD }}
JRELEASER_GPG_PASSPHRASE: ${{ secrets.JRELEASER_GPG_PASSPHRASE }}
JRELEASER_GPG_SECRET_KEY: ${{ secrets.JRELEASER_GPG_SECRET_KEY }}
JRELEASER_GPG_PUBLIC_KEY: ${{ secrets.JRELEASER_GPG_PUBLIC_KEY }}
JRELEASER_GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: ./gradlew :core:jreleaserDeploy -DaltDeploymentRepository=local::file:./core/build/staging-deploy --stacktrace