From 9888ae7c975027d8707e1edae6630f8c1baed594 Mon Sep 17 00:00:00 2001 From: Hirotaka Wakabayashi Date: Wed, 13 Nov 2024 17:21:55 +0900 Subject: [PATCH] Fix the workflow --- .github/workflows/main.yml | 102 ++++++++++++++++++++----------------- settings_github.xml | 50 ------------------ 2 files changed, 54 insertions(+), 98 deletions(-) delete mode 100644 settings_github.xml diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 0237e1f..30c858e 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -27,59 +27,65 @@ jobs: name: Java ${{ matrix.java }} steps: - - uses: actions/checkout@v4 - - name: Setup Java JDK - uses: actions/setup-java@v3 - with: - java-version: ${{ matrix.java }} - distribution: 'zulu' - server-id: ossrh - settings-path: ${{ github.workspace }} - server-username: OSSRH_USERNAME - server-password: OSSRH_PASSWORD - gpg-private-key: ${{ secrets.MAVEN_GPG_PRIVATE_KEY }} # Value of the GPG private key to import - gpg-passphrase: MAVEN_GPG_PASSPHRASE # env variable of GPG private key passphrase + - uses: actions/checkout@v4 + - name: Set up JDK + uses: actions/setup-java@v4 + with: + distribution: 'zulu' + java-version: ${{ matrix.java }} - - name: Set environments - run: | - echo "COMMON_MAVEN_OPTS=-Dmaven.compiler.failOnWarning=true -Dmaven.compiler.showDeprecation=true -Dmaven.compiler.verbose=true -Dmaven.compiler.debuglevel=lines,vars,source" >> "$GITHUB_ENV" + - name: Set environments + run: | + echo "COMMON_MAVEN_OPTS=-Dmaven.compiler.failOnWarning=true -Dmaven.compiler.showDeprecation=true -Dmaven.compiler.verbose=true -Dmaven.compiler.debuglevel=lines,vars,source" >> "$GITHUB_ENV" - - name: Install dependent packages - run: | - sudo apt-get install -y curl - curl -s https://packagecloud.io/install/repositories/antpickax/stable/script.deb.sh | sudo bash - sudo apt-get install -y k2hash-dev + - name: Install dependent packages + run: | + sudo apt-get install -y curl + curl -s https://packagecloud.io/install/repositories/antpickax/stable/script.deb.sh | sudo bash + sudo apt-get install -y k2hash-dev - - name: Run checkstyle - run: | - mvn ${{ env.COMMON_MAVEN_OPTS }} checkstyle:check + - name: Run checkstyle + run: | + mvn ${{ env.COMMON_MAVEN_OPTS }} checkstyle:check - - name: Run package on version 8 - if: "matrix.java == '8'" - run: | - mvn ${{ env.COMMON_MAVEN_OPTS }} -Dmaven.compiler.target=8 package + - name: Run package on version 8 + if: "matrix.java == '8'" + run: | + mvn ${{ env.COMMON_MAVEN_OPTS }} -Dmaven.compiler.target=8 package - - name: Run package on version other than 8 - if: "matrix.java != '8'" - run: | - mvn ${{ env.COMMON_MAVEN_OPTS }} -Dmaven.compiler.target=${{ matrix.java }} -Dmaven.compiler.source=${{ matrix.java }} -Dmaven.compiler.release=${{ matrix.java }} package + - name: Run package on version other than 8 + if: "matrix.java != '8'" + run: | + mvn ${{ env.COMMON_MAVEN_OPTS }} -Dmaven.compiler.target=${{ matrix.java }} -Dmaven.compiler.source=${{ matrix.java }} -Dmaven.compiler.release=${{ matrix.java }} package - - name: Run javadoc - run: | - mvn ${{ env.COMMON_MAVEN_OPTS }} javadoc:javadoc + - name: Run javadoc + run: | + mvn ${{ env.COMMON_MAVEN_OPTS }} javadoc:javadoc - - name: Deploy the docs to github - if: "github.event_name == 'release' && matrix.java == '21'" - run: | - mvn ${{ env.COMMON_MAVEN_OPTS }} site -s settings_github.xml - env: - GITPAGES_TOKEN: ${{ secrets.PERSONAL_ACCESS_TOKE_FOR_GITPAGES }} + - name: Deploy the docs to github + if: "github.event_name == 'release' && matrix.java == '21'" + run: | + mvn ${{ env.COMMON_MAVEN_OPTS }} site + env: + GITHUB_TOKEN: ${{ github.token }} # GITHUB_TOKEN is the default env for the password + + - name: Set up Apache Maven Central + uses: actions/setup-java@v4 + with: # running setup-java again overwrites the settings.xml + distribution: 'zulu' + java-version: ${{ matrix.java }} + server-id: ossrh # Value of the distributionManagement/repository/id field of the pom.xml + server-username: MAVEN_USERNAME # env variable for username in deploy + server-password: MAVEN_CENTRAL_TOKEN # env variable for token in deploy + gpg-private-key: ${{ secrets.MAVEN_GPG_PRIVATE_KEY }} # Value of the GPG private key to import + gpg-passphrase: MAVEN_GPG_PASSPHRASE # env variable for GPG private key passphrase + + - name: Publish to Apache Maven Central + if: "github.event_name == 'release' && matrix.java == '21'" + run: | + mvn ${{ env.COMMON_MAVEN_OPTS }} deploy -Prelease + env: + MAVEN_USERNAME: ${{ secrets.OSSRH_USERNAME }} + MAVEN_CENTRAL_TOKEN: ${{ secrets.OSSRH_PASSWORD }} + MAVEN_GPG_PASSPHRASE: ${{ secrets.MAVEN_GPG_PASSPHRASE }} - - name: Publish to Apache Maven Central - if: "github.event_name == 'release' && matrix.java == '21'" - run: | - mvn ${{ env.COMMON_MAVEN_OPTS }} deploy -Prelease -s $GITHUB_WORKSPACE/settings.xml - env: - OSSRH_USERNAME: ${{ secrets.OSSRH_USERNAME }} - OSSRH_PASSWORD: ${{ secrets.OSSRH_PASSWORD }} - MAVEN_GPG_PASSPHRASE: ${{ secrets.MAVEN_GPG_PASSPHRASE }} diff --git a/settings_github.xml b/settings_github.xml deleted file mode 100644 index f62f9c1..0000000 --- a/settings_github.xml +++ /dev/null @@ -1,50 +0,0 @@ - - - - github - - - - - github - - - central - https://repo1.maven.org/maven2 - true - false - - - github - GitHub yahoojapan Apache Maven Packages - https://maven.pkg.github.com/yahoojapan/k2hash_java - - - - - ossrh - - true - - - gpg2 - ${env.GNUPG_TOKEN} - - - - - - - github - ${env.GITPAGES_TOKEN} - - - ossrh - Wakabayashi - ${env.SONATYPE_TOKEN} - - -