name: Release & Upload

on:
  release:
    types:
      - published  # 创建release的时候触发

jobs:
  build:

    runs-on: ubuntu-latest

    steps:
      - name: "Checkout"
        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

      - name: "Maven Package"
        run: mvn -B package --file pom.xml -Dmaven.javadoc.skip=true -DskipTests
        env:
          MAVEN_USERNAME: ${{ github.repository_owner }}
          MAVEN_TOKEN: ${{secrets.GITHUB_TOKEN}}

      - name: "Upload Release Asset"
        id: upload-release-asset
        uses: shogo82148/actions-upload-release-asset@v1
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
        with:
          upload_url: ${{ github.event.release.upload_url }}
          asset_path: asset/*.jar
          asset_content_type: application/java-archive