|
| 1 | +# This workflow will build a Java project with Maven |
| 2 | +# For more information see: https://help.github.com/actions/language-and-framework-guides/building-and-testing-java-with-maven |
| 3 | +# |
| 4 | + |
| 5 | +name: Java CI with Maven |
| 6 | + |
| 7 | +on: |
| 8 | + push: |
| 9 | + branches: [ main,develop ] |
| 10 | + tags: |
| 11 | + - 'v*' |
| 12 | + pull_request: |
| 13 | + branches: [ main,develop ] |
| 14 | + paths-ignore: |
| 15 | + - README.md |
| 16 | + - .gitignore |
| 17 | + |
| 18 | +jobs: |
| 19 | + build: |
| 20 | + |
| 21 | + runs-on: ubuntu-latest |
| 22 | + |
| 23 | + steps: |
| 24 | + - name: Cache Maven Repos |
| 25 | + uses: actions/cache@v2 |
| 26 | + with: |
| 27 | + path: ~/.m2/repository |
| 28 | + key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }} |
| 29 | + restore-keys: | |
| 30 | + ${{ runner.os }}-maven- |
| 31 | + - uses: actions/checkout@v2 |
| 32 | + - name: Set up JDK 1.8 |
| 33 | + uses: actions/setup-java@v1 |
| 34 | + with: |
| 35 | + java-version: 1.8 |
| 36 | + - name: Build Plugin |
| 37 | + run: mvn -B clean package install --file pom.xml |
| 38 | + - uses: bhowell2/github-substring-action@v1.0.0 |
| 39 | + if: startsWith(github.ref, 'refs/tags/') |
| 40 | + id: releaseVersion |
| 41 | + with: |
| 42 | + fail_if_not_found: false |
| 43 | + default_return_value: ${{ github.ref }} |
| 44 | + value: ${{ github.ref }} |
| 45 | + index_of_str: "refs/tags/v" |
| 46 | + - name: Release |
| 47 | + uses: softprops/action-gh-release@v1 |
| 48 | + if: startsWith(github.ref, 'refs/tags/') |
| 49 | + with: |
| 50 | + draft: true |
| 51 | + files: ./fizz-simple-cache-plugin-${{ steps.releaseVersion.outputs.substring }}.zip |
| 52 | + env: |
| 53 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 54 | + - name: Publish to Apache Maven Central |
| 55 | + if: startsWith(github.ref, 'refs/tags/') |
| 56 | + uses: samuelmeuli/action-maven-publish@v1 |
| 57 | + with: |
| 58 | + maven_profiles: release |
| 59 | + server_id: sonatype-release |
| 60 | + gpg_private_key: ${{ secrets.GPG_SECRET }} |
| 61 | + gpg_passphrase: ${{ secrets.GPG_PASSPHASE }} |
| 62 | + nexus_username: ${{ secrets.OSSRH_USER }} |
| 63 | + nexus_password: ${{ secrets.OSSRH_PASSWORD }} |
0 commit comments