Skip to content

Commit d630fce

Browse files
committed
[Build] publish OSS artifacts through GitHub workflow
1 parent b0bfa08 commit d630fce

File tree

4 files changed

+145
-2
lines changed

4 files changed

+145
-2
lines changed

.github/workflows/ci.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
name: Continuous Integration
22

33
on:
4+
workflow_call:
45
workflow_dispatch:
56
push:
67
branches:
@@ -11,7 +12,7 @@ on:
1112
- master
1213

1314
concurrency:
14-
group: ${{ github.workflow }}-${{ github.ref }}
15+
group: ci-${{ github.workflow }}-${{ github.ref }}
1516
cancel-in-progress: true
1617

1718
env:

.github/workflows/codeql.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
name: "CodeQL"
22

33
on:
4+
workflow_call:
45
push:
56
branches:
67
- master
@@ -10,7 +11,7 @@ on:
1011
- master
1112

1213
concurrency:
13-
group: ${{ github.workflow }}-${{ github.ref }}
14+
group: codeql-${{ github.workflow }}-${{ github.ref }}
1415
cancel-in-progress: true
1516

1617
env:

.github/workflows/release.yml

Lines changed: 124 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,124 @@
1+
name: Release
2+
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
release:
7+
description: Is release? (Will create tag and update version)
8+
required: true
9+
default: false
10+
type: boolean
11+
release-version:
12+
description: Released version (x.y.z)
13+
required: true
14+
type: string
15+
next-version:
16+
description: Next version (x.y.z)
17+
required: true
18+
type: string
19+
20+
concurrency:
21+
group: ${{ github.workflow }}-${{ github.ref }}
22+
cancel-in-progress: false
23+
24+
env:
25+
GRADLE_OPTS: '-Dorg.gradle.daemon=false -Dorg.gradle.java.installations.auto-detect=false -Dorg.gradle.warning.mode=fail'
26+
27+
jobs:
28+
ci:
29+
uses: ./.github/workflows/ci.yml
30+
31+
codeql:
32+
uses: ./.github/workflows/codeql.yml
33+
34+
pre-release:
35+
name: Update version, tag repo, and return sha
36+
permissions:
37+
contents: write
38+
needs: [ ci, codeql ]
39+
runs-on: ubuntu-latest
40+
outputs:
41+
sha: ${{ steps.return-sha.outputs.sha }}
42+
steps:
43+
- id: checkout
44+
name: Checkout
45+
uses: actions/checkout@v4
46+
with:
47+
ref: ${{ github.ref }}
48+
- id: validate
49+
name: Validate no new commits
50+
run: |
51+
current_sha=$(git rev-parse HEAD)
52+
if test $current_sha != '${{ github.sha }}'
53+
then exit 1
54+
fi
55+
- id: tag-version
56+
if: ${{ inputs.release }}
57+
name: Update version and tag repo
58+
run: |
59+
git config user.name "github-actions"
60+
git config user.email "github-actions@aeron.io"
61+
echo ${{ inputs.release-version }} > version.txt
62+
git add version.txt
63+
git status
64+
git commit -m "${{ inputs.release-version }} version update."
65+
git push
66+
git tag ${{ inputs.release-version }}
67+
git push origin refs/tags/${{ inputs.release-version }}
68+
- id: return-sha
69+
name: Return current SHA
70+
run: |
71+
git rev-parse HEAD
72+
echo "sha=$(git rev-parse HEAD)" >> "$GITHUB_OUTPUT"
73+
74+
release:
75+
name: Release java artifacts
76+
permissions:
77+
contents: read
78+
packages: write
79+
needs: pre-release
80+
runs-on: ubuntu-latest
81+
steps:
82+
- name: checkout
83+
uses: actions/checkout@v4
84+
with:
85+
ref: ${{ needs.pre-release.outputs.sha }}
86+
- name: Setup java
87+
uses: actions/setup-java@v4
88+
with:
89+
distribution: 'zulu'
90+
java-version: 8
91+
- name: Setup BUILD_JAVA_HOME & BUILD_JAVA_VERSION
92+
run: |
93+
java -Xinternalversion
94+
echo "BUILD_JAVA_HOME=${JAVA_HOME}" >> $GITHUB_ENV
95+
echo "BUILD_JAVA_VERSION=8" >> $GITHUB_ENV
96+
- name: Publish with Gradle
97+
run: ./gradlew publish
98+
env:
99+
ORG_GRADLE_PROJECT_ossrhUsername: ${{ secrets.ossrhUsername }}
100+
ORG_GRADLE_PROJECT_ossrhPassword: ${{ secrets.ossrhPassword }}
101+
ORG_GRADLE_PROJECT_signingKey: ${{ secrets.signingKey }}
102+
ORG_GRADLE_PROJECT_signingPassword: ${{ secrets.signingPassword }}
103+
104+
post-release:
105+
name: Update version
106+
permissions:
107+
contents: write
108+
needs: release
109+
runs-on: ubuntu-latest
110+
steps:
111+
- name: Checkout
112+
uses: actions/checkout@v4
113+
with:
114+
ref: ${{ github.ref }}
115+
- name: Commit snapshot version to current branch
116+
if: ${{ inputs.release }}
117+
run: |
118+
git config user.name "github-actions"
119+
git config user.email "github-actions@aeron.io"
120+
echo ${{ inputs.next-version }}-SNAPSHOT > version.txt
121+
git add version.txt
122+
git status
123+
git commit -m "${{ inputs.next-version }}-SNAPSHOT version update."
124+
git push

build.gradle

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,14 @@ ext {
7979
if (!project.hasProperty('ossrhPassword')) {
8080
ossrhPassword = ''
8181
}
82+
83+
if (!project.hasProperty('signingKey')) {
84+
signingKey = null
85+
}
86+
87+
if (!project.hasProperty('signingPassword')) {
88+
signingPassword = null
89+
}
8290
}
8391

8492
def projectPom = {
@@ -404,6 +412,9 @@ project(':sbe-tool') {
404412
}
405413

406414
signing {
415+
if (signingKey != null) {
416+
useInMemoryPgpKeys(signingKey, signingPassword)
417+
}
407418
sign publishing.publications.sbe
408419
}
409420
}
@@ -471,6 +482,9 @@ project(':sbe-all') {
471482
}
472483

473484
signing {
485+
if (signingKey != null) {
486+
useInMemoryPgpKeys(signingKey, signingPassword)
487+
}
474488
sign publishing.publications.sbeAll
475489
}
476490
}
@@ -584,6 +598,9 @@ project(':sbe-samples') {
584598
}
585599

586600
signing {
601+
if (signingKey != null) {
602+
useInMemoryPgpKeys(signingKey, signingPassword)
603+
}
587604
sign publishing.publications.sbeSamples
588605
}
589606
}

0 commit comments

Comments
 (0)