Release #1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Release | |
on: | |
workflow_dispatch: | |
inputs: | |
version: | |
description: 'Release version' | |
required: false | |
jobs: | |
release: | |
name: Release | |
runs-on: ubuntu-latest | |
timeout-minutes: 30 | |
steps: | |
- name: Assign input version | |
if: github.event.inputs.version != null | |
run: echo "RELEASE_VERSION=${{ github.event.inputs.version }}" >> $GITHUB_ENV | |
- uses: actions/github-script@v7 | |
if: github.event.inputs.version == null | |
id: candidate-version | |
with: | |
github-token: ${{secrets.GITHUB_TOKEN}} | |
result-encoding: string | |
script: | | |
const list = await github.rest.repos.listReleases({ | |
owner: "domaframework", | |
repo: "doma-codegen-plugin", | |
}); | |
console.log(list) | |
let version = list.data[0].name | |
return version.startsWith("v") ? version.substring(1) : version | |
- name: Assign candidate version | |
if: github.event.inputs.version == null | |
run: echo "RELEASE_VERSION=${{ steps.candidate-version.outputs.result }}" >> $GITHUB_ENV | |
- name: Set up JDK 21 | |
uses: actions/setup-java@v4 | |
with: | |
distribution: 'zulu' | |
java-version: 21 | |
- name: Checkout | |
uses: actions/checkout@v4 | |
with: | |
token: ${{ secrets.REPO_ACCESS_TOKEN }} | |
- name: Grant execute permission for gradlew | |
run: chmod +x gradlew | |
- name: Cache Gradle | |
uses: actions/cache@v4 | |
with: | |
path: | | |
~/.gradle/caches | |
~/.gradle/wrapper | |
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*') }} | |
restore-keys: | | |
${{ runner.os }}-gradle- | |
- name: Release ${{ env.RELEASE_VERSION }} | |
run: | | |
java -version | |
git config --local user.email "[email protected]" | |
git config --local user.name "GitHub Action" | |
./gradlew release -Prelease.releaseVersion=${{ env.RELEASE_VERSION }} | |
- name: Upload reports | |
if: failure() | |
uses: actions/upload-artifact@v4 | |
with: | |
name: build | |
path: ./**/build/reports |