Skip to content
This repository was archived by the owner on Sep 16, 2023. It is now read-only.

Commit baf827a

Browse files
build(ci): enable auto-release for dependency-update-only releases
Automatically perform a Java client library release when: 1. Only dependency updates are going out in the release since any releases containing bug fixes, build changes or new features should be supervised; 2. There are no outstanding/open dependency update pull requests in the repo. This is to avoid multiple/redundant releases; 3. It is a SNAPSHOT release which is automatically generated post regular release -- this requires no human supervision. Testing done in 5 java-bigquery* client library repos. Example: [chore: release 0.3.4 ](googleapis/java-bigqueryconnection#130) [chore: release 0.3.5-SNAPSHOT](googleapis/java-bigqueryconnection#131) Source-Author: Stephanie Wang <[email protected]> Source-Date: Thu Sep 17 15:30:02 2020 -0400 Source-Repo: googleapis/synthtool Source-Sha: 538a68019eb4a36a0cdfa4021f324dd01b784395 Source-Link: googleapis/synthtool@538a680
1 parent b0c2e49 commit baf827a

File tree

2 files changed

+72
-2
lines changed

2 files changed

+72
-2
lines changed

.github/workflows/auto-release.yaml

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
on:
2+
pull_request:
3+
name: auto-release
4+
jobs:
5+
approve:
6+
runs-on: ubuntu-latest
7+
steps:
8+
- uses: actions/[email protected]
9+
with:
10+
github-token: ${{secrets.GITHUB_TOKEN}}
11+
debug: true
12+
script: |
13+
// only approve PRs from release-please[bot]
14+
if (context.payload.pull_request.user.login !== "release-please[bot]") {
15+
return;
16+
}
17+
18+
// only approve PRs like "chore: release <release version>"
19+
if ( !context.payload.pull_request.title.startsWith("chore: release") ) {
20+
return;
21+
}
22+
23+
// trigger auto-release when
24+
// 1) it is a SNAPSHOT release (auto-generated post regular release)
25+
// 2) there are dependency updates only
26+
// 3) there are no open dependency update PRs in this repo (to avoid multiple releases)
27+
if (
28+
context.payload.pull_request.body.includes("Fix") ||
29+
context.payload.pull_request.body.includes("Build") ||
30+
context.payload.pull_request.body.includes("Documentation") ||
31+
context.payload.pull_request.body.includes("BREAKING CHANGES") ||
32+
context.payload.pull_request.body.includes("Features")
33+
) {
34+
console.log( "Not auto-releasing since it is not a dependency-update-only release." );
35+
return;
36+
}
37+
38+
const promise = github.pulls.list.endpoint({
39+
owner: context.repo.owner,
40+
repo: context.repo.repo,
41+
state: 'open'
42+
});
43+
const open_pulls = await github.paginate(promise)
44+
45+
if ( open_pulls.length > 1 && !context.payload.pull_request.title.includes("SNAPSHOT") ) {
46+
for ( const pull of open_pulls ) {
47+
if ( pull.title.startsWith("deps: update dependency") ) {
48+
console.log( "Not auto-releasing yet since there are dependency update PRs open in this repo." );
49+
return;
50+
}
51+
}
52+
}
53+
54+
// approve release PR
55+
await github.pulls.createReview({
56+
owner: context.repo.owner,
57+
repo: context.repo.repo,
58+
body: 'Rubber stamped release!',
59+
pull_number: context.payload.pull_request.number,
60+
event: 'APPROVE'
61+
});
62+
63+
// attach kokoro:force-run and automerge labels
64+
await github.issues.addLabels({
65+
owner: context.repo.owner,
66+
repo: context.repo.repo,
67+
issue_number: context.payload.pull_request.number,
68+
labels: ['kokoro:force-run', 'automerge']
69+
});

synth.metadata

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
"git": {
55
"name": ".",
66
"remote": "https://github.com/googleapis/java-tasks.git",
7-
"sha": "35cf6f7d04a1c3dd163736e785f0037dac408646"
7+
"sha": "b0c2e49069233b12ff3fc27cbdeb0079bd077370"
88
}
99
},
1010
{
@@ -19,7 +19,7 @@
1919
"git": {
2020
"name": "synthtool",
2121
"remote": "https://github.com/googleapis/synthtool.git",
22-
"sha": "019c7168faa0e56619f792693a8acdb30d6de19b"
22+
"sha": "538a68019eb4a36a0cdfa4021f324dd01b784395"
2323
}
2424
}
2525
],
@@ -60,6 +60,7 @@
6060
".github/PULL_REQUEST_TEMPLATE.md",
6161
".github/release-please.yml",
6262
".github/trusted-contribution.yml",
63+
".github/workflows/auto-release.yaml",
6364
".github/workflows/ci.yaml",
6465
".github/workflows/samples.yaml",
6566
".kokoro/build.bat",

0 commit comments

Comments
 (0)