diff --git a/.github/release-drafter.yml b/.github/release-drafter.yml index 975a035..1196d2d 100644 --- a/.github/release-drafter.yml +++ b/.github/release-drafter.yml @@ -4,6 +4,9 @@ template: | # What's Changed $CHANGES + + **Full Changelog**: https://github.com/$OWNER/$REPOSITORY/compare/$PREVIOUS_TAG...$RESOLVED_VERSION + categories: - title: 'New Features' labels: @@ -14,7 +17,7 @@ categories: - 'bug' - 'fix' - title: 'Maintenance' - label: + labels: - 'ci' - 'chore' - 'perf' @@ -27,7 +30,6 @@ categories: label: 'dependencies' exclude-labels: - 'skip-changelog' -change-template: '* $TITLE (#$NUMBER)' version-resolver: major: labels: diff --git a/.github/workflows/release-drafter.yml b/.github/workflows/release-drafter.yml index 618c957..4669ba5 100644 --- a/.github/workflows/release-drafter.yml +++ b/.github/workflows/release-drafter.yml @@ -4,6 +4,7 @@ on: push: branches: - master + workflow_dispatch: jobs: update_release_draft: diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..8610204 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,76 @@ +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 "action@github.com" + 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