|
1 |
| -# This workflow uses actions that are not certified by GitHub. |
2 |
| -# They are provided by a third-party and are governed by |
3 |
| -# separate terms of service, privacy policy, and support |
4 |
| -# documentation. |
5 |
| -# This workflow will build a Java project with Gradle and cache/restore any dependencies to improve the workflow execution time |
6 |
| -# For more information see: https://help.github.com/actions/language-and-framework-guides/building-and-testing-java-with-gradle |
7 |
| - |
8 | 1 | name: Java CI with Gradle
|
9 |
| - |
| 2 | +env: |
| 3 | + JAR_SHA256: '' |
10 | 4 | on:
|
11 | 5 | push:
|
| 6 | + paths: |
| 7 | + - ".github/workflows/*.yml" |
| 8 | + - "**.kts" |
| 9 | + - "**.kt" |
| 10 | + - "**.java" |
12 | 11 | pull_request:
|
13 |
| - |
14 |
| -permissions: |
15 |
| - contents: read |
| 12 | + release: |
| 13 | + types: |
| 14 | + - created |
| 15 | + workflow_dispatch: |
16 | 16 |
|
17 | 17 | jobs:
|
18 | 18 | build:
|
19 |
| - |
20 | 19 | runs-on: ubuntu-latest
|
| 20 | + steps: |
| 21 | + - uses: actions/checkout@v3 |
| 22 | + - name: Set up JDK 17 |
| 23 | + uses: actions/setup-java@v3 |
| 24 | + with: |
| 25 | + java-version: '17' |
| 26 | + distribution: 'temurin' |
21 | 27 |
|
| 28 | + - name: Build with Gradle |
| 29 | + |
| 30 | + with: |
| 31 | + arguments: build |
| 32 | + - name: Upload a Build Artifact |
| 33 | + |
| 34 | + with: |
| 35 | + path: build/libs |
| 36 | + |
| 37 | + upload-to-release: |
| 38 | + name: Upload to Release |
| 39 | + needs: |
| 40 | + - build |
| 41 | + runs-on: ubuntu-latest |
| 42 | + if: github.event_name == 'release' |
22 | 43 | steps:
|
23 |
| - - uses: actions/checkout@v3 |
24 |
| - - name: Set up JDK 17 |
25 |
| - uses: actions/setup-java@v3 |
26 |
| - with: |
27 |
| - java-version: '17' |
28 |
| - distribution: 'temurin' |
| 44 | + - name: Checkout |
| 45 | + uses: actions/checkout@v3 |
| 46 | + with: |
| 47 | + fetch-depth: 0 |
| 48 | + |
| 49 | + - name: Get Version |
| 50 | + run: echo "VERSION=${{ github.ref_name }}" >> $GITHUB_ENV |
| 51 | + |
| 52 | + - name: Download Artifacts |
| 53 | + uses: actions/download-artifact@v3 |
| 54 | + |
| 55 | + - name: Compute Artifacts SHA256 |
| 56 | + run: | |
| 57 | + echo "JAR_SHA256=$(sha256sum artifact/HeaderGenerator-${{ env.VERSION }}-all.jar | cut -d ' ' -f 1)" >> $GITHUB_ENV |
| 58 | + shell: bash |
29 | 59 |
|
30 |
| - - name: Build with Gradle |
31 |
| - |
32 |
| - with: |
33 |
| - arguments: build |
34 |
| - - name: Upload a Build Artifact |
35 |
| - |
36 |
| - with: |
37 |
| - path: build/libs |
| 60 | + - name: Upload Release Assets |
| 61 | + uses: softprops/action-gh-release@v1 |
| 62 | + with: |
| 63 | + append_body: true |
| 64 | + files: | |
| 65 | + artifact/HeaderGenerator-${{ env.VERSION }}-all.jar |
| 66 | + body: | |
| 67 | + --- |
| 68 | + | File | SHA256 | |
| 69 | + | :--------------------------------------------- | :-------------------- | |
| 70 | + | HeaderGenerator-${{ env.VERSION }}-all.jar | ${{ env.JAR_SHA256 }} | |
0 commit comments