1
mirror of https://github.com/CarmJos/GithubReleases4J.git synced 2024-09-19 21:55:45 +00:00
GithubReleases4J/.github/workflows/deploy.yml

108 lines
3.6 KiB
YAML
Raw Normal View History

2022-01-21 18:32:04 +00:00
# This workflow will build a Java project with Maven, and cache/restore any dependencies to improve the workflow execution time
# For more information see: https://help.github.com/actions/language-and-framework-guides/building-and-testing-java-with-maven
2022-02-06 19:04:40 +00:00
name: "Deploy & Upload"
2022-01-21 18:32:04 +00:00
on:
# 支持手动触发构建
workflow_dispatch:
release:
# 创建release的时候触发
types: [ published ]
jobs:
2022-02-06 19:00:46 +00:00
gh-deploy:
name: "Publish Project (GitHub)"
2022-01-21 18:32:04 +00:00
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: "Set up JDK"
uses: actions/setup-java@v2
with:
java-version: '11'
distribution: 'adopt'
cache: maven
server-id: github
server-username: MAVEN_USERNAME
server-password: MAVEN_TOKEN
2022-01-22 06:35:45 +00:00
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
2022-01-21 18:32:04 +00:00
2022-02-06 19:00:46 +00:00
- name: "Maven Deploy With Javadoc"
run: mvn -B -Pgithub deploy --file pom.xml -DskipTests
2022-01-21 18:32:04 +00:00
env:
MAVEN_USERNAME: ${{ github.repository_owner }}
2022-02-06 19:00:46 +00:00
MAVEN_TOKEN: ${{secrets.GITHUB_TOKEN}}
2022-01-22 06:35:45 +00:00
MAVEN_GPG_PASSPHRASE: ${{ secrets.MAVEN_GPG_PASSPHRASE }}
2022-01-21 18:32:04 +00:00
2022-02-06 19:00:46 +00:00
- name: "Copy Javadoc to Location"
2022-01-21 18:32:04 +00:00
run: |
rm -rf docs
mkdir -vp docs
cp -vrf target/apidocs/* docs/
cp -vrf .documentation/JAVADOC-README.md docs/README.md
- name: "Generate the Javadoc sitemap"
id: sitemap
uses: cicirello/generate-sitemap@v1
with:
2022-02-06 19:00:46 +00:00
base-url-path: https://carmjos.github.io/GithubReleases4J
2022-01-21 18:32:04 +00:00
path-to-root: docs
2022-02-06 19:00:46 +00:00
- name: "Output stats"
2022-01-21 18:32:04 +00:00
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'
2022-02-06 19:00:46 +00:00
- name: "Commit documentations"
2022-01-21 18:32:04 +00:00
run: |
cd docs
git init
2022-02-06 19:00:46 +00:00
git remote add origin git@github.com:CarmJos/GithubReleases4J.git
2022-01-21 18:32:04 +00:00
git checkout -b gh-pages
git add -A
git commit -m "API Document generated."
- name: "Push javadocs"
run: |
cd docs
2022-02-06 19:00:46 +00:00
git push origin HEAD:gh-pages --force
central-deploy:
2022-02-06 19:04:40 +00:00
name: "Deploy Project (Central)"
2022-02-06 19:00:46 +00:00
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: "Set up JDK"
uses: actions/setup-java@v2
with:
java-version: '11'
distribution: 'adopt'
cache: maven
server-id: ossrh
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
env:
MAVEN_USERNAME: ${{ secrets.OSSRH_USER }}
MAVEN_PASSWORD: ${{ secrets.OSSRH_PASS }}
MAVEN_GPG_PASSPHRASE: ${{ secrets.MAVEN_GPG_PASSPHRASE }}