Skip to content

Commit 8866087

Browse files
authored
Run the Gradle release task in the GitHub Actions workflow (#623)
1 parent 084af70 commit 8866087

File tree

2 files changed

+83
-15
lines changed

2 files changed

+83
-15
lines changed

.github/workflows/release.yml

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
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+
15+
steps:
16+
- name: Assign input version
17+
if: github.event.inputs.version != null
18+
run: echo "RELEASE_VERSION=${{ github.event.inputs.version }}" >> $GITHUB_ENV
19+
20+
- uses: actions/github-script@v3
21+
if: github.event.inputs.version == null
22+
id: candidate-version
23+
with:
24+
github-token: ${{secrets.GITHUB_TOKEN}}
25+
result-encoding: string
26+
script: |
27+
const list = await github.repos.listReleases({
28+
owner: "domaframework",
29+
repo: "doma",
30+
});
31+
console.log(list)
32+
return list.data[0].name
33+
34+
- name: Assign candidate version
35+
if: github.event.inputs.version == null
36+
run: echo "RELEASE_VERSION=${{ steps.candidate-version.outputs.result }}" >> $GITHUB_ENV
37+
38+
- name: Set up JDK 8
39+
uses: actions/setup-java@v1
40+
with:
41+
java-version: 8
42+
43+
- name: Checkout
44+
uses: actions/checkout@v2
45+
with:
46+
token: ${{ secrets.WORKFLOW_DISPATCH_TOKEN }}
47+
48+
- name: Grant execute permission for gradlew
49+
run: chmod +x gradlew
50+
51+
- name: Cache Gradle
52+
uses: actions/cache@v2
53+
with:
54+
path: |
55+
~/.gradle/caches
56+
~/.gradle/wrapper
57+
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*') }}
58+
restore-keys: |
59+
${{ runner.os }}-gradle-
60+
61+
- name: Release ${{ env.RELEASE_VERSION }}
62+
run: |
63+
java -version
64+
git config --global user.name "github-actions[bot]"
65+
git config --global user.email "41898282+github-actions[bot]@users.noreply.github.com"
66+
./gradlew release -Prelease.releaseVersion=${{ env.RELEASE_VERSION }}
67+
68+
- name: Upload reports
69+
if: failure()
70+
uses: actions/upload-artifact@v2
71+
with:
72+
name: build
73+
path: ./**/build/reports

RELEASE_OPERATIONS.md

Lines changed: 10 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,25 @@
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=$(gh release list -L 1 | tee /dev/tty | awk '{print $1}')
8+
$ gh api repos/domaframework/doma/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
1712

1813
(No operation required)
1914

20-
The GitHub Actions workflow [Java CI with Gradle](.github/workflows/ci.yml) handles the above push event.
21-
22-
The workflow builds artifacts and publishes them to [Maven Central](https://repo1.maven.org/).
15+
The [ci workflow](.github/workflows/ci.yml) follows the above release workflow
16+
and publishes artifacts to [Maven Central](https://repo1.maven.org/).
2317

2418
## Wait for the artifacts to appear on Maven Central
2519

2620
(Optional)
2721

28-
Use [Dependency Watch](https://github.com/JakeWharton/dependency-watch).
22+
Use [Dependency Watch](https://github.com/JakeWharton/dependency-watch):
2923

3024
```
3125
$ dependency-watch await org.seasar.doma:doma-core:$(gh release list -L 1 | tee /dev/tty | awk '{print $1}') && say "New version is available!"
@@ -54,6 +48,7 @@ and publish release notes.
5448

5549
## Announce the release
5650

57-
Announce the release of new version using Twitter and Google Group.
58-
- [@domaframework](https://twitter.com/domaframework)
59-
- [doma-user](https://groups.google.com/g/doma-user)
51+
Announce the release of new version using
52+
[Twitter]((https://twitter.com/domaframework)),
53+
[Zulip](https://domaframework.zulipchat.com), and
54+
[Google Group](https://groups.google.com/g/doma-user).

0 commit comments

Comments
 (0)