Skip to content

Commit 651c885

Browse files
authored
Merge pull request #60 from domaframework/ci/release
Automate the release
2 parents 1c565d6 + 5c56da1 commit 651c885

File tree

3 files changed

+81
-2
lines changed

3 files changed

+81
-2
lines changed

.github/release-drafter.yml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@ template: |
44
# What's Changed
55
66
$CHANGES
7+
8+
**Full Changelog**: https://github.com/$OWNER/$REPOSITORY/compare/$PREVIOUS_TAG...$RESOLVED_VERSION
9+
710
categories:
811
- title: 'New Features'
912
labels:
@@ -14,7 +17,7 @@ categories:
1417
- 'bug'
1518
- 'fix'
1619
- title: 'Maintenance'
17-
label:
20+
labels:
1821
- 'ci'
1922
- 'chore'
2023
- 'perf'
@@ -27,7 +30,6 @@ categories:
2730
label: 'dependencies'
2831
exclude-labels:
2932
- 'skip-changelog'
30-
change-template: '* $TITLE (#$NUMBER)'
3133
version-resolver:
3234
major:
3335
labels:

.github/workflows/release-drafter.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ on:
44
push:
55
branches:
66
- master
7+
workflow_dispatch:
78

89
jobs:
910
update_release_draft:

.github/workflows/release.yml

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
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

Comments
 (0)