|
| 1 | +name: Publish package to GitHub Packages |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + tags: |
| 6 | + - '[0-9]+.[0-9]+.[0-9]+' |
| 7 | + |
| 8 | +jobs: |
| 9 | + build: |
| 10 | + name: Upload Release Asset |
| 11 | + runs-on: ubuntu-latest |
| 12 | + steps: |
| 13 | + - name: Get version number |
| 14 | + uses: bhowell2/github-substring-action@v1.0.0 |
| 15 | + id: substring_version |
| 16 | + with: |
| 17 | + output_name: "version" |
| 18 | + value: "${{github.ref}}" |
| 19 | + index_of_str: "tags/" |
| 20 | + - name: Checkout code |
| 21 | + uses: actions/checkout@v2 |
| 22 | + - name: Setup Java |
| 23 | + uses: actions/setup-java@v2 |
| 24 | + with: |
| 25 | + java-version: '16' |
| 26 | + distribution: 'zulu' |
| 27 | + - name: Build with Maven |
| 28 | + run: mvn -B clean package --file pom.xml |
| 29 | + - name: Create Release |
| 30 | + id: create_release |
| 31 | + uses: actions/create-release@v1 |
| 32 | + env: |
| 33 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 34 | + with: |
| 35 | + tag_name: "${{steps.substring_version.outputs.version}}" |
| 36 | + release_name: "Release v${{steps.substring_version.outputs.version}}" |
| 37 | + draft: false |
| 38 | + prerelease: false |
| 39 | + - name: Jar detection |
| 40 | + id: jar_finder |
| 41 | + uses: DovnarAlexander/github-action-file-detection@v0.3.0 |
| 42 | + with: |
| 43 | + wildcard: "*.jar" |
| 44 | + base_path: "./target/" |
| 45 | + - name: Get version number |
| 46 | + uses: bhowell2/github-substring-action@v1.0.0 |
| 47 | + id: substring_filename |
| 48 | + with: |
| 49 | + output_name: "filename" |
| 50 | + value: "${{steps.jar_finder.outputs.found}}" |
| 51 | + index_of_str: "target/" |
| 52 | + - name: Upload Release Asset |
| 53 | + id: upload-release-asset |
| 54 | + uses: actions/upload-release-asset@v1 |
| 55 | + env: |
| 56 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 57 | + with: |
| 58 | + upload_url: ${{steps.create_release.outputs.upload_url}} |
| 59 | + asset_path: ${{steps.jar_finder.outputs.found}} |
| 60 | + asset_name: ${{steps.substring_filename.outputs.filename}} |
| 61 | + asset_content_type: application/jar |
0 commit comments