Skip to content

Commit 6d8eba1

Browse files
authored
Make release operations simpler (#69)
1 parent 628a619 commit 6d8eba1

File tree

3 files changed

+81
-11
lines changed

3 files changed

+81
-11
lines changed

.github/workflows/ci.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ on:
88

99
jobs:
1010
build:
11-
if: contains(github.event.head_commit.message, '[skip ci]') == false
1211
runs-on: ubuntu-latest
1312

1413
steps:

.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@v4
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.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 8
41+
uses: actions/setup-java@v2
42+
with:
43+
distribution: 'zulu'
44+
java-version: 8
45+
46+
- name: Checkout
47+
uses: actions/checkout@v2
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@v2
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@v2
74+
with:
75+
name: build
76+
path: ./**/build/reports

RELEASE_OPERATIONS.md

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,19 @@
11
# Release Operations
22

3-
## Run the Gradle release task
3+
## Dispatch the release workflow
44

5-
The Gradle release task creates a release commit and push it to the origin/master branch.
5+
Dispatch the [release workflow](.github/workflows/release.yml) as follows:
66

77
```
8-
$ git checkout master
9-
$ git pull
10-
$ ./gradlew release -Prelease.releaseVersion=1.0.0 -Prelease.newVersion=1.1.0-SNAPSHOT
8+
$ gh api repos/domaframework/doma-codegen-plugin/actions/workflows/release.yml/dispatches -F ref='master'
119
```
1210

13-
The value of `release.releaseVersion` is decided by the draft name of
14-
[Releases](https://github.com/domaframework/doma/releases).
15-
1611
## Build and Publish with GitHub Action
1712

1813
(No operation required)
1914

20-
The GitHub Action workflow [Java CI with Gradle](.github/workflows/ci.yml) handles the above push event
21-
and publishes to the [Gradle Plugin Portal](https://plugins.gradle.org/).
15+
The [CI](.github/workflows/ci.yml) workflow follows the above release workflow
16+
and publishes the doma-codegen-plugin to the [Gradle Plugin Portal](https://plugins.gradle.org/).
2217

2318
## Publish release notes
2419

0 commit comments

Comments
 (0)