|
| 1 | +name: Release |
| 2 | + |
| 3 | +on: |
| 4 | + workflow_dispatch: |
| 5 | + inputs: |
| 6 | + version: |
| 7 | + description: 'Release version' |
| 8 | + required: false |
| 9 | + |
| 10 | +jobs: |
| 11 | + release: |
| 12 | + name: Release |
| 13 | + runs-on: ubuntu-latest |
| 14 | + timeout-minutes: 30 |
| 15 | + |
| 16 | + steps: |
| 17 | + - name: Assign input version |
| 18 | + if: github.event.inputs.version != null |
| 19 | + run: echo "RELEASE_VERSION=${{ github.event.inputs.version }}" >> $GITHUB_ENV |
| 20 | + |
| 21 | + - uses: actions/github-script@v7 |
| 22 | + if: github.event.inputs.version == null |
| 23 | + id: candidate-version |
| 24 | + with: |
| 25 | + github-token: ${{secrets.GITHUB_TOKEN}} |
| 26 | + result-encoding: string |
| 27 | + script: | |
| 28 | + const list = await github.rest.repos.listReleases({ |
| 29 | + owner: "domaframework", |
| 30 | + repo: "doma-codegen-plugin", |
| 31 | + }); |
| 32 | + console.log(list) |
| 33 | + let version = list.data[0].name |
| 34 | + return version.startsWith("v") ? version.substring(1) : version |
| 35 | +
|
| 36 | + - name: Assign candidate version |
| 37 | + if: github.event.inputs.version == null |
| 38 | + run: echo "RELEASE_VERSION=${{ steps.candidate-version.outputs.result }}" >> $GITHUB_ENV |
| 39 | + |
| 40 | + - name: Set up JDK 21 |
| 41 | + uses: actions/setup-java@v4 |
| 42 | + with: |
| 43 | + distribution: 'zulu' |
| 44 | + java-version: 21 |
| 45 | + |
| 46 | + - name: Checkout |
| 47 | + uses: actions/checkout@v4 |
| 48 | + with: |
| 49 | + token: ${{ secrets.REPO_ACCESS_TOKEN }} |
| 50 | + |
| 51 | + - name: Grant execute permission for gradlew |
| 52 | + run: chmod +x gradlew |
| 53 | + |
| 54 | + - name: Cache Gradle |
| 55 | + uses: actions/cache@v4 |
| 56 | + with: |
| 57 | + path: | |
| 58 | + ~/.gradle/caches |
| 59 | + ~/.gradle/wrapper |
| 60 | + key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*') }} |
| 61 | + restore-keys: | |
| 62 | + ${{ runner.os }}-gradle- |
| 63 | +
|
| 64 | + - name: Release ${{ env.RELEASE_VERSION }} |
| 65 | + run: | |
| 66 | + java -version |
| 67 | + git config --local user.email "[email protected]" |
| 68 | + git config --local user.name "GitHub Action" |
| 69 | + ./gradlew release -Prelease.releaseVersion=${{ env.RELEASE_VERSION }} |
| 70 | +
|
| 71 | + - name: Upload reports |
| 72 | + if: failure() |
| 73 | + uses: actions/upload-artifact@v4 |
| 74 | + with: |
| 75 | + name: build |
| 76 | + path: ./**/build/reports |
0 commit comments