diff --git a/.github/workflows/java-gradle-ci.yml b/.github/workflows/java-gradle-ci.yml index 2356bd7..d0f0f28 100644 --- a/.github/workflows/java-gradle-ci.yml +++ b/.github/workflows/java-gradle-ci.yml @@ -7,12 +7,6 @@ name: Java CI with Gradle for library on: push: workflow_dispatch: - inputs: - create_release: - type: boolean - description: Create a release when CI passes - default: false - required: true concurrency: group: ${{ github.workflow }}-${{ github.ref }} @@ -57,51 +51,3 @@ jobs: reuse-compliance: name: REUSE Compliance uses: ./.github/workflows/reuse-compliance.yml - - publish: - name: Publish to maven central - needs: [build-and-test] - if: github.ref_type == 'tag' - runs-on: ubuntu-latest - environment: release - permissions: - contents: read - - steps: - - name: Checkout repository - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # 7.0.1 - with: - fetch-depth: 1 - persist-credentials: false - - - name: Setup runtime - uses: ./.github/actions/setup-runtime - - - name: Cache Gradle - uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 #v6.1.0 - with: - path: | - ~/.gradle/caches - ~/.gradle/wrapper - key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/settings.gradle*') }} - - - name: Optimize Gradle - shell: bash - run: | - mkdir -p ~/.gradle - echo "org.gradle.caching=true" >> ~/.gradle/gradle.properties - echo "org.gradle.configuration-cache=true" >> ~/.gradle/gradle.properties - - - name: Gradle Release Build - env: - JRELEASER_GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }} - JRELEASER_GPG_PUBLIC_KEY: ${{ secrets.GPG_PUBLIC_KEY }} - JRELEASER_GPG_SECRET_KEY: ${{ secrets.GPG_PRIVATE_KEY }} - JRELEASER_MAVENCENTRAL_USERNAME: ${{ secrets.MAVEN_USERNAME }} - JRELEASER_MAVENCENTRAL_PASSWORD: ${{ secrets.MAVEN_PASSWORD }} - SANITIZED_TAG: ${{ github.ref_name }} - run: | - echo "Performing release Gradle publish for tag: $SANITIZED_TAG" - - ./gradlew clean build publish -Pversion=$SANITIZED_TAG - ./gradlew jreleaserDeploy -Pversion=$SANITIZED_TAG \ No newline at end of file diff --git a/.github/workflows/release.yaml.yml b/.github/workflows/release.yaml.yml new file mode 100644 index 0000000..4d47a5a --- /dev/null +++ b/.github/workflows/release.yaml.yml @@ -0,0 +1,81 @@ +# SPDX-FileCopyrightText: Contributors to the Power Grid Model project +# +# SPDX-License-Identifier: MPL-2.0 + +name: Release to Maven central + +on: + workflow_dispatch: + inputs: + version: + type: string + description: Version tag + required: true + +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + +jobs: + + publish: + name: Publish to Maven central + runs-on: ubuntu-latest + environment: release + permissions: + contents: read + + steps: + - name: Checkout repository + uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # 7.0.1 + with: + fetch-depth: 1 + persist-credentials: false + + - name: Setup runtime + uses: ./.github/actions/setup-runtime + + - name: Cache Gradle + uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 #v6.1.0 + with: + path: | + ~/.gradle/caches + ~/.gradle/wrapper + key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/settings.gradle*') }} + + - name: Optimize Gradle + shell: bash + run: | + mkdir -p ~/.gradle + echo "org.gradle.caching=true" >> ~/.gradle/gradle.properties + echo "org.gradle.configuration-cache=true" >> ~/.gradle/gradle.properties + + - name: generate GitHub App token + uses: actions/create-github-app-token@bcd2ba49218906704ab6c1aa796996da409d3eb1 # v3.2.0 + id: generate-token + with: + client-id: ${{ secrets.RELEASE_BOT_APP_ID }} + private-key: ${{ secrets.RELEASE_BOT_PRIVATE_KEY }} + repositories: ${{ github.repository }} + permission-contents: write + + - name: Create GitHub release + uses: softprops/action-gh-release@efb35369e0ad2afab669f228072c1b0d510eae64 # v3.0.3 + with: + tag_name: ${{ inputs.version }} + generate_release_notes: true + target_commitish: ${{ github.sha }} + token: ${{ steps.generate-token.outputs.token }} + + - name: Gradle Release Build + env: + JRELEASER_GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }} + JRELEASER_GPG_PUBLIC_KEY: ${{ secrets.GPG_PUBLIC_KEY }} + JRELEASER_GPG_SECRET_KEY: ${{ secrets.GPG_PRIVATE_KEY }} + JRELEASER_MAVENCENTRAL_USERNAME: ${{ secrets.MAVEN_USERNAME }} + JRELEASER_MAVENCENTRAL_PASSWORD: ${{ secrets.MAVEN_PASSWORD }} + run: | + echo "Performing release Gradle publish for tag: ${{ inputs.version }}" + + ./gradlew clean build publish -Pversion=${{ inputs.version }} + ./gradlew jreleaserDeploy -Pversion=${{ inputs.version }} \ No newline at end of file