From 96804f83bafbfce272e16c020fdd14da406943c5 Mon Sep 17 00:00:00 2001 From: carm Date: Thu, 20 Feb 2025 00:13:45 +0800 Subject: [PATCH] ci: Update ci --- .github/workflows/deploy.yml | 63 +++++++++++++++++++++++++---- .github/workflows/javadoc.yml | 74 ----------------------------------- .github/workflows/maven.yml | 4 -- 3 files changed, 55 insertions(+), 86 deletions(-) delete mode 100644 .github/workflows/javadoc.yml diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 2570ffb..4efa712 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -12,7 +12,7 @@ on: jobs: gh-deploy: - name: "Deploy Project (GitHub)" + name: "Publish Project (GitHub)" runs-on: ubuntu-latest steps: @@ -22,23 +22,70 @@ jobs: with: java-version: '11' distribution: 'adopt' -# cache: maven # Say 4uck u to github cache services. + cache: maven server-id: github server-username: MAVEN_USERNAME server-password: MAVEN_TOKEN 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: "Maven Deploy" + - name: "Maven Deploy With Javadoc" run: mvn -B -Pgithub deploy --file pom.xml -DskipTests env: MAVEN_USERNAME: ${{ github.repository_owner }} MAVEN_TOKEN: ${{secrets.GITHUB_TOKEN}} MAVEN_GPG_PASSPHRASE: ${{ secrets.MAVEN_GPG_PASSPHRASE }} + - name: "Copy Javadoc to Location" + run: | + rm -rf docs + mkdir -vp docs + cp -vrf core/target/reports/apidocs/* docs/ + cp -vrf .doc/JAVADOC-README.md docs/README.md + + - name: "Generate the Javadoc sitemap" + id: sitemap + uses: cicirello/generate-sitemap@v1 + with: + base-url-path: https://CarmJos.github.io/EasyConfiguration + path-to-root: docs + + - name: "Output stats" + run: | + echo "sitemap-path = ${{ steps.sitemap.outputs.sitemap-path }}" + echo "url-count = ${{ steps.sitemap.outputs.url-count }}" + echo "excluded-count = ${{ steps.sitemap.outputs.excluded-count }}" + + - name: "Configure Git" + env: + DEPLOY_PRI: ${{secrets.DEPLOY_PRI}} + run: | + sudo timedatectl set-timezone "Asia/Shanghai" + mkdir -p ~/.ssh/ + echo "$DEPLOY_PRI" > ~/.ssh/id_rsa + chmod 600 ~/.ssh/id_rsa + ssh-keyscan github.com >> ~/.ssh/known_hosts + git config --global user.name 'CarmJos' + git config --global user.email 'carm@carm.cc' + + - name: "Commit documentations" + run: | + cd docs + git init + git remote add origin git@github.com:CarmJos/EasyConfiguration.git + git checkout -b gh-pages + git add -A + git commit -m "API Document generated." + + - name: "Push javadocs" + run: | + cd docs + git push origin HEAD:gh-pages --force + central-deploy: - name: "Deploy Project (Central)" + name: "Deploy Project (Central Repository)" runs-on: ubuntu-latest + steps: - uses: actions/checkout@v4 - name: "Set up JDK" @@ -46,16 +93,16 @@ jobs: with: java-version: '11' distribution: 'adopt' -# cache: maven # Say 4uck u to github cache services. - server-id: ossrh + cache: maven + server-id: central server-username: MAVEN_USERNAME server-password: MAVEN_PASSWORD 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: "Central Deploy" - run: mvn -B -Possrh deploy --file pom.xml -DskipTests + run: mvn -B -Pcentral deploy --file pom.xml -DskipTests env: MAVEN_USERNAME: ${{ secrets.OSSRH_USER }} MAVEN_PASSWORD: ${{ secrets.OSSRH_PASS }} - MAVEN_GPG_PASSPHRASE: ${{ secrets.MAVEN_GPG_PASSPHRASE }} + MAVEN_GPG_PASSPHRASE: ${{ secrets.MAVEN_GPG_PASSPHRASE }} \ No newline at end of file diff --git a/.github/workflows/javadoc.yml b/.github/workflows/javadoc.yml deleted file mode 100644 index d9650fd..0000000 --- a/.github/workflows/javadoc.yml +++ /dev/null @@ -1,74 +0,0 @@ -name: "Publish Javadoc" - -on: - # 支持手动触发构建 - workflow_dispatch: - release: - # 创建release的时候触发 - types: [ published ] - - -jobs: - - javadoc-deploy: - name: "Deploy Javadoc (Github Pages)" - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - - name: "Set up JDK" - uses: actions/setup-java@v4 - with: - java-version: '8' - distribution: 'adopt' - cache: maven - - - name: "Generate Javadoc" - run: mvn -B javadoc:aggregate --file pom.xml -DskipTests - - - name: "Copy Javadoc" - run: | - rm -rf docs - mkdir -vp docs - cp -vrf target/site/apidocs/* docs/ - cp -vrf .doc/javadoc/JAVADOC-README.md docs/README.md - - - name: "Generate Sitemap" - id: sitemap - uses: cicirello/generate-sitemap@v1 - with: - base-url-path: https://${{ github.repository_owner }}.github.io/${{ github.event.repository.name }} - path-to-root: docs - - - name: Output stats - run: | - echo "sitemap-path = ${{ steps.sitemap.outputs.sitemap-path }}" - echo "url-count = ${{ steps.sitemap.outputs.url-count }}" - echo "excluded-count = ${{ steps.sitemap.outputs.excluded-count }}" - ls -l docs - - - name: Configure Git - env: - DEPLOY_PRI: ${{secrets.DEPLOY_PRI}} - run: | - sudo timedatectl set-timezone "Asia/Shanghai" - mkdir -p ~/.ssh/ - echo "$DEPLOY_PRI" > ~/.ssh/id_rsa - chmod 600 ~/.ssh/id_rsa - ssh-keyscan github.com >> ~/.ssh/known_hosts - git config --global user.name '${{ github.repository_owner }}' - git config --global user.email '${{ github.repository_owner }}@users.noreply.github.com' - - - name: Commit documentation changes - run: | - echo "Committing changes to git@github.com:${{ github.repository_owner }}/${{ github.event.repository.name }}.git ..." - cd docs - git init - git remote add origin git@github.com:${{ github.repository_owner }}/${{ github.event.repository.name }}.git - git checkout -b gh-pages - git add -A - git commit -m "API Document generated." - - - name: Javadoc Website Push - run: | - cd docs - git push origin HEAD:gh-pages --force \ No newline at end of file diff --git a/.github/workflows/maven.yml b/.github/workflows/maven.yml index 0bfe942..4dcdf4b 100644 --- a/.github/workflows/maven.yml +++ b/.github/workflows/maven.yml @@ -8,10 +8,6 @@ on: workflow_dispatch: pull_request: push: - paths-ignore: - - ".github/**" - - "README.md" - - "LICENCE" jobs: build: