Skip to content

Commit cc200cf

Browse files
committed
build: Setup a release pipeline - bug fixes, optimizations and polishing (#691)
1 parent ea2b4d1 commit cc200cf

13 files changed

+288
-75
lines changed

.github/dependabot.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,6 @@ updates:
88
- package-ecosystem: "gradle"
99
directory: "/" # Location of package manifests
1010
schedule:
11-
interval: "daily"
11+
interval: "weekly"
1212
commit-message:
1313
prefix: deps(upgrade)

.github/workflows/build.yml

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,17 @@
11
name: Build and test
22
on:
33
# Build PRs
4-
pull_request: ~
4+
pull_request:
5+
paths-ignore:
6+
- 'docs/**'
7+
- '*.md'
8+
- '**/*.md'
9+
- '.github/workflows/bump*.yaml'
10+
- '.github/workflows/codeql*.yaml'
11+
- '.github/workflows/command-*.yaml'
12+
- '.github/workflows/deploy-tag.yaml'
13+
- '.github/workflows/prepare-release.yaml'
14+
515
# On push event
616
push:
717
# Build only changes pushed into the `master` branch.
@@ -13,12 +23,18 @@ on:
1323
- 'docs/**'
1424
- '*.md'
1525
- '**/*.md'
26+
- '.github/workflows/bump*.yaml'
27+
- '.github/workflows/codeql*.yaml'
28+
- '.github/workflows/command-*.yaml'
29+
- '.github/workflows/deploy-tag.yaml'
30+
- '.github/workflows/prepare-release.yaml'
31+
1632
workflow_dispatch:
1733

1834
# Currently you cannot use ${{ env.IS_FORK }} for some reason, which is why you might need to copy-paste some of these.
1935
env:
2036
REPOSITORY: ${{ github.repository }}
21-
IS_FORK: ${{ github.repository != 'carlspring/s3fs-nio' }}
37+
IS_FORK: ${{ github.repository != vars.CURRENT_REPO }}
2238
IS_PR: ${{ github.event_name == 'pull_request' }}
2339
EVENT_NAME: ${{ toJSON(github.event_name) }}
2440
# format: username:branch
@@ -33,6 +49,8 @@ jobs:
3349
matrix:
3450
os: [ ubuntu-latest, windows-latest, macos-latest ]
3551
java: [ 8, 11 ]
52+
#os: [ ubuntu-latest ]
53+
#java: [ 11 ]
3654
steps:
3755
- name: Show GitHub context
3856
run: echo "$EVENT_NAME $REPOSITORY $PR_HEAD_LABEL $IS_PR $IS_FORK"
@@ -130,9 +148,7 @@ jobs:
130148
131149
# Publish snapshot only when on master branch, version is actually snapshot and from just one of the matrix jobs.
132150
- name: Publish snapshot (only on master branch)
133-
# TODO: Add this back before merge.
134-
# ${{ github.ref_name == 'master' }} &&
135-
if: ${{ fromJSON(steps.deploy_check.outputs.result).is_deployable == 'true' }}
151+
if: ${{ github.ref_name == 'master' }} && ${{ fromJSON(steps.deploy_check.outputs.result).is_deployable == 'true' }}
136152
env:
137153
S3FS_PUBLISH_SONATYPE_USER: "${{ secrets.S3FS_PUBLISH_SONATYPE_USER }}"
138154
S3FS_PUBLISH_SONATYPE_PASS: "${{ secrets.S3FS_PUBLISH_SONATYPE_PASS }}"

.github/workflows/bump-snapshot-version.yaml

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,17 +7,14 @@ on:
77
description: Next snapshot version (i.e. 1.2.3, no SNAPSHOT suffix)
88

99
name: Bump snapshot version
10-
11-
env:
12-
IS_FORK: ${{ github.repository != 'carlspring/s3fs-nio' }}
13-
IS_ADMIN: ${{ github.triggering_actor == 'carlspring' || github.triggering_actor == 'steve-todorov' }}
10+
run-name: Bump snapshot version to ${{ inputs.VERSION }}-SNAPSHOT
1411

1512
jobs:
1613
bump-version:
1714
runs-on: ubuntu-latest
1815
if: |
19-
${{ github.repository == 'carlspring/s3fs-nio' }} &&
20-
${{ (github.triggering_actor == 'carlspring' || github.triggering_actor == 'steve-todorov') == true }}
16+
github.repository == vars.CURRENT_REPO &&
17+
contains('["carlspring", "steve-todorov"]', github.triggering_actor)
2118
permissions:
2219
contents: write
2320
pull-requests: write
@@ -54,8 +51,8 @@ jobs:
5451
- name: Bump version
5552
run: |
5653
cat <<< $(jq '."." = "${{ inputs.VERSION }}-SNAPSHOT"' .release-please-manifest.json) > .release-please-manifest.json
57-
sed -i 's/version\ \= .*/version = "${{ inputs.VERSION }}-SNAPSHOT"/g' gradle.properties
58-
sed -i 's/POM_VERSION: .*/POM_VERSION: "${{ inputs.VERSION }}-SNAPSHOT"/g' docs/mkdocs.yaml
54+
sed -Ei 's/version([ ]*)\=.*/version=${{ inputs.VERSION }}-SNAPSHOT/g' gradle.properties
55+
sed -Ei 's/POM_VERSION:.*/POM_VERSION: "${{ inputs.VERSION }}-SNAPSHOT"/g' docs/mkdocs.y*ml
5956
6057
- name: Create PR
6158
uses: peter-evans/create-pull-request@v5

.github/workflows/codeql.yml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,27 @@ name: "CodeQL"
33
on:
44
push:
55
branches: [ "master" ]
6+
paths-ignore:
7+
- 'docs/**'
8+
- '*.md'
9+
- '**/*.md'
10+
- '.github/workflows/bump*.yaml'
11+
- '.github/workflows/command-*.yaml'
12+
- '.github/workflows/deploy-tag.yaml'
13+
- '.github/workflows/prepare-release.yaml'
614
pull_request:
715
# The branches below must be a subset of the branches above
816
branches: [ "master" ]
917
# schedule:
1018
# - cron: '21 3 * * 4'
19+
paths-ignore:
20+
- 'docs/**'
21+
- '*.md'
22+
- '**/*.md'
23+
- '.github/workflows/bump*.yaml'
24+
- '.github/workflows/command-*.yaml'
25+
- '.github/workflows/deploy-tag.yaml'
26+
- '.github/workflows/prepare-release.yaml'
1127

1228
jobs:
1329
analyze:
Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
on:
2+
repository_dispatch:
3+
types: [ deploy-pr-command ]
4+
5+
name: command-deploy-pr
6+
run-name: Deploying PR-${{ github.event.client_payload.github.payload.issue.number }}-SNAPSHOT@${{ github.event.client_payload.pull_request.head.sha }}
7+
8+
permissions:
9+
contents: write
10+
pull-requests: write
11+
actions: write
12+
13+
jobs:
14+
build-and-deploy:
15+
runs-on: ubuntu-latest
16+
steps:
17+
18+
- name: Checkout
19+
uses: actions/checkout@v3
20+
with:
21+
ref: ${{ github.event.client_payload.pull_request.head.sha }}
22+
23+
- name: Setup Java
24+
uses: actions/setup-java@v3
25+
with:
26+
java-version: 11
27+
distribution: "temurin"
28+
29+
- name: Setup Gradle
30+
uses: gradle/gradle-build-action@v2
31+
with:
32+
# The Gradle wrapper's version (already the default, putting it here to clarity)
33+
gradle-version: wrapper
34+
# Removing unused files from Gradle User Home before saving to cache (i.e. older versions of gradle)
35+
gradle-home-cache-cleanup: true
36+
# Cache downloaded JDKs in addition to the default directories.
37+
gradle-home-cache-includes: |
38+
caches
39+
notifications
40+
jdks
41+
42+
- name: Build and deploy snapshot PR-${{ github.event.client_payload.github.payload.issue.number }}-SNAPSHOT
43+
env:
44+
S3FS_BUCKET_NAME: ${{ secrets.S3FS_BUCKET_NAME }}
45+
S3FS_ACCESS_KEY: ${{ secrets.S3FS_ACCESS_KEY }}
46+
S3FS_SECRET_KEY: ${{ secrets.S3FS_SECRET_KEY }}
47+
S3FS_REGION: ${{ secrets.S3FS_REGION }}
48+
S3FS_PROTOCOL: "https"
49+
S3FS_PUBLISH_SONATYPE_USER: "${{ secrets.S3FS_PUBLISH_SONATYPE_USER }}"
50+
S3FS_PUBLISH_SONATYPE_PASS: "${{ secrets.S3FS_PUBLISH_SONATYPE_PASS }}"
51+
run: ./gradlew build publish --warn --stacktrace -Pversion=PR-${{ github.event.client_payload.github.payload.issue.number }}-SNAPSHOT
52+
53+
# Add reaction to the comment
54+
- name: Add success reaction
55+
uses: peter-evans/create-or-update-comment@v2
56+
if: ${{ success() }}
57+
with:
58+
token: ${{ secrets.GITHUB_TOKEN }}
59+
repository: ${{ github.event.client_payload.github.payload.repository.full_name }}
60+
comment-id: ${{ github.event.client_payload.github.payload.comment.id }}
61+
reaction-type: hooray
62+
63+
# Add comment (for historic reasons)
64+
- name: Add success reaction
65+
uses: peter-evans/create-or-update-comment@v2
66+
if: ${{ success() }}
67+
with:
68+
token: ${{ secrets.GITHUB_TOKEN }}
69+
repository: ${{ github.event.client_payload.github.payload.repository.full_name }}
70+
body: |
71+
PR-${{ github.event.client_payload.github.payload.issue.number }}-SNAPSHOT@${{ github.event.client_payload.pull_request.head.sha }} was successfully deployed!
72+
Check the [build logs](${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }})
73+
74+
- name: Add failure response
75+
uses: peter-evans/create-or-update-comment@v2
76+
if: ${{ failure() }}
77+
with:
78+
token: ${{ secrets.GITHUB_TOKEN }}
79+
repository: ${{ github.event.client_payload.github.payload.repository.full_name }}
80+
comment-id: ${{ github.event.client_payload.github.payload.comment.id }}
81+
reaction-type: -1
82+
body: |
83+
> FAILURE: Action failed! Check the [logs](${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }})

.github/workflows/command-dispatcher.yaml

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,18 @@
1-
name: Slash Command Dispatch
1+
name: command-dispatch
22
on:
33
issue_comment:
44
types: [created]
5-
#permissions:
6-
# pull-requests: write
7-
# issues: write
8-
# contents: read
9-
# repository-projects: read
10-
# actions: write
11-
permissions: write-all
5+
permissions:
6+
contents: write
7+
pull-requests: write
8+
actions: write
9+
#permissions: write-all
1210
jobs:
1311
slashCommandDispatch:
1412
runs-on: ubuntu-latest
13+
if: |
14+
contains('["carlspring", "steve-todorov"]', github.triggering_actor) &&
15+
github.event.issue.pull_request
1516
steps:
1617
- name: Slash Command Dispatch
1718
uses: peter-evans/slash-command-dispatch@v3
@@ -29,6 +30,11 @@ jobs:
2930
"permission": "write",
3031
"issue_type": "pull-request"
3132
},
33+
{
34+
"command": "deploy-pr",
35+
"permission": "write",
36+
"issue_type": "pull-request"
37+
},
3238
{
3339
"command": "help",
3440
"permission": "write",
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
name: command-help
2+
run-name: command-help PR-${{ github.event.client_payload.github.payload.issue.number }}
3+
4+
on:
5+
repository_dispatch:
6+
types: [help-command]
7+
permissions:
8+
issues: write
9+
pull-requests: write
10+
contents: write
11+
jobs:
12+
help:
13+
runs-on: ubuntu-latest
14+
steps:
15+
- name: Dump the client payload context
16+
env:
17+
PAYLOAD_CONTEXT: ${{ toJson(github.event.client_payload) }}
18+
run: echo "$PAYLOAD_CONTEXT"
19+
- name: Update comment
20+
uses: peter-evans/create-or-update-comment@v2
21+
with:
22+
token: ${{ secrets.GITHUB_TOKEN }}
23+
repository: ${{ github.event.client_payload.github.payload.repository.full_name }}
24+
comment-id: ${{ github.event.client_payload.github.payload.comment.id }}
25+
body: |
26+
> Command | Description
27+
> --- | ---
28+
> /merge-snapshot | Squash and merge snapshot PR.
29+
> /merge-release | Squash and merge release PR.
30+
> /deploy-pr | Deploys the PR as a snapshot version (i.e. `org.carlspring.cloud.aws:s3fs-nio:PR-${{ github.event.client_payload.github.payload.issue.number }}-SNAPSHOT` using ref `${{ github.event.client_payload.pull_request.head.sha }}`)
31+
reaction-type: hooray

.github/workflows/merge-release-command.yaml renamed to .github/workflows/command-merge-release.yaml

Lines changed: 38 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@ on:
22
repository_dispatch:
33
types: [ merge-release-command ]
44

5-
name: merge-release-command
5+
name: command-merge-release
6+
run-name: command-merge-release PR-${{ github.event.client_payload.github.payload.issue.number }}
67

78
permissions:
89
contents: write
@@ -11,11 +12,6 @@ permissions:
1112

1213
jobs:
1314
merge-release:
14-
if: |
15-
${{ github.repository == 'carlspring/s3fs-nio' }} &&
16-
${{ (github.triggering_actor == 'carlspring' || github.triggering_actor == 'steve-todorov') == true }} &&
17-
${{ github.event.client_payload.slash_command.command == 'merge-release' }} &&
18-
${{ github.event_name == 'pull_request' }}
1915
runs-on: ubuntu-latest
2016
steps:
2117
- uses: actions/github-script@v6
@@ -25,15 +21,30 @@ jobs:
2521
# The method mappings can be found here: https://github.com/octokit/plugin-rest-endpoint-methods.js/blob/main/src/generated/endpoints.ts
2622
# Method parameters are available in the api docs: https://docs.github.com/en/rest/pulls/pulls?apiVersion=2022-11-28#merge-a-pull-request
2723
script: |
28-
const response = await github.rest.pulls.listCommits({
24+
const pr = await github.rest.pulls.get({
25+
owner: context.repo.owner,
26+
repo: context.repo.repo,
27+
pull_number: '${{ github.event.client_payload.github.payload.issue.number }}'
28+
});
29+
const prTitle = pr.data.title
30+
31+
const isRelease = prTitle.includes("Release v")
32+
if(!isRelease) {
33+
console.log("")
34+
console.error("/merge-snapshot is supposed to be executed only on pull requests updating the version to snapshot!")
35+
console.log("")
36+
process.exit(1)
37+
}
38+
39+
const listCommits = await github.rest.pulls.listCommits({
2940
owner: context.repo.owner,
3041
repo: context.repo.repo,
3142
pull_number: '${{ github.event.client_payload.github.payload.issue.number }}',
3243
headers: { 'X-GitHub-Api-Version': '2022-11-28' }
3344
});
34-
//console.log(response.data);
45+
//console.log(listCommits.data);
3546
36-
const commits = [...response.data].map(c => c.commit);
47+
const commits = [...listCommits.data].map(c => c.commit);
3748
//console.log("Commits: ", commits);
3849
3950
const split = commits[0].message.split('\n');
@@ -42,7 +53,8 @@ jobs:
4253
split.shift()
4354
let commit_message = (split.join('\n') + "\n\nCo-authored-by: " + commits[0].author.name + " <" + commits[0].author.email + ">").trim();
4455
console.log("Squash title: " + commit_title);
45-
console.log("Squash message: " + commit_message);
56+
console.log("Squash message: \n" + commit_message + "\n/Squash message\n");
57+
4658
await github.rest.pulls.merge({
4759
owner: context.repo.owner,
4860
repo: context.repo.repo,
@@ -79,10 +91,25 @@ jobs:
7991
gh workflow run deploy-tag.yaml -f TAG=v${{ fromJSON(steps.release.outputs.result).version }}
8092
8193
# Add reaction to the comment
82-
- name: Add reaction
94+
- name: Add success response
8395
uses: peter-evans/create-or-update-comment@v2
96+
if: ${{ success() }}
8497
with:
8598
token: ${{ secrets.GITHUB_TOKEN }}
8699
repository: ${{ github.event.client_payload.github.payload.repository.full_name }}
87100
comment-id: ${{ github.event.client_payload.github.payload.comment.id }}
88101
reaction-type: hooray
102+
body: |
103+
> Success: Action was successful! Check the [logs](${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }})
104+
105+
- name: Add failure response
106+
uses: peter-evans/create-or-update-comment@v2
107+
if: ${{ failure() }}
108+
with:
109+
token: ${{ secrets.GITHUB_TOKEN }}
110+
repository: ${{ github.event.client_payload.github.payload.repository.full_name }}
111+
comment-id: ${{ github.event.client_payload.github.payload.comment.id }}
112+
reaction-type: -1
113+
body: |
114+
> FAILURE: Action failed! Check the [logs](${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }})
115+

0 commit comments

Comments
 (0)