Skip to content

Commit dcadb9f

Browse files
committed
fix: enable github actions
Signed-off-by: Phil Adams <[email protected]>
1 parent 49f9532 commit dcadb9f

File tree

4 files changed

+200
-2
lines changed

4 files changed

+200
-2
lines changed

.github/workflows/build.yaml

Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
# This workflow will build and unit test the project.
2+
# If the workflow is running on the "main" branch, then
3+
# semantic-release is also run to create a new release (if
4+
# warranted by the new commits being built).
5+
6+
name: Build/Test
7+
8+
on:
9+
push:
10+
branches: [ '**' ]
11+
pull_request:
12+
branches: [ '**' ]
13+
workflow_dispatch:
14+
# Allow workflow to be triggered manually.
15+
16+
jobs:
17+
detect-secrets:
18+
if: "!contains(github.event.head_commit.message, '[skip ci]')"
19+
name: Detect-Secrets
20+
runs-on: ubuntu-latest
21+
22+
steps:
23+
- name: Checkout repository
24+
uses: actions/checkout@v4
25+
26+
- name: Setup Python
27+
uses: actions/setup-python@v5
28+
with:
29+
python-version: 3.12
30+
31+
- name: Install detect-secrets
32+
run: |
33+
pip install --upgrade "git+https://github.com/ibm/detect-secrets.git@master#egg=detect-secrets"
34+
35+
- name: Run detect-secrets
36+
run: |
37+
detect-secrets scan --update .secrets.baseline
38+
detect-secrets -v audit --report --fail-on-unaudited --fail-on-live --fail-on-audited-real .secrets.baseline
39+
40+
build:
41+
needs: detect-secrets
42+
name: Build/Test (Java ${{matrix.java-version}})
43+
runs-on: ubuntu-latest
44+
strategy:
45+
matrix:
46+
java-version: ['11', '17']
47+
48+
steps:
49+
- name: Checkout repository
50+
uses: actions/checkout@v4
51+
52+
- name: Setup Java ${{matrix.java-version}}
53+
uses: actions/setup-java@v4
54+
with:
55+
java-version: ${{matrix.java-version}}
56+
distribution: 'adopt'
57+
cache: 'maven'
58+
59+
- name: Build & Test
60+
run: mvn -B clean package
61+
62+
create-release:
63+
needs: build
64+
name: Semantic-Release
65+
if: "github.ref_name == 'main' && github.event_name != 'pull_request'"
66+
runs-on: ubuntu-latest
67+
68+
steps:
69+
- name: Checkout repository
70+
uses: actions/checkout@v4
71+
with:
72+
persist-credentials: false
73+
74+
- name: Setup Node.js
75+
uses: actions/setup-node@v4
76+
with:
77+
node-version: 22
78+
79+
- name: Setup Python
80+
uses: actions/setup-python@v5
81+
with:
82+
python-version: 3.12
83+
84+
- name: Install Publishing Tools
85+
run: |
86+
pip install bump-my-version
87+
npm install
88+
89+
- name: Run semantic-release
90+
env:
91+
GH_TOKEN: ${{ secrets.GH_TOKEN }}
92+
run: npm run semantic-release

.github/workflows/publish.yaml

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
# This workflow is responsible for:
2+
# - publishing artifacts to Maven Central
3+
# - building and publishing javadocs to the git repository.
4+
# It is triggered when a new release is created.
5+
6+
name: Publish
7+
8+
on:
9+
release:
10+
types: [created]
11+
workflow_dispatch:
12+
# Allow this workflow to be triggered manually
13+
14+
jobs:
15+
publish:
16+
name: Publish Release
17+
runs-on: ubuntu-latest
18+
19+
steps:
20+
- name: Checkout repository
21+
uses: actions/checkout@v4
22+
with:
23+
persist-credentials: false
24+
25+
- name: Setup Java
26+
uses: actions/setup-java@v4
27+
with:
28+
java-version: 11
29+
distribution: 'adopt'
30+
cache: 'maven'
31+
# Configure ~/.m2/settings.xml
32+
server-id: ossrh
33+
server-username: OSSRH_USERNAME
34+
server-password: OSSRH_PASSWORD
35+
# Import GPG key into build agent's local keystore
36+
gpg-private-key: ${{ secrets.GPG_PRIVATE_KEY }}
37+
gpg-passphrase: ${{ secrets.GPG_PASSPHRASE }}
38+
39+
- name: Set artifact version to ${{ github.ref_name }}
40+
run: mvn versions:set -DnewVersion=${{ github.ref_name}} -DgenerateBackupPoms=false
41+
42+
- name: Publish Javadocs
43+
env:
44+
GH_TOKEN: ${{ secrets.GH_TOKEN }}
45+
GH_REPO_SLUG: ${{ github.repository }}
46+
GH_TAG: ${{ github.ref_name}}
47+
run: |
48+
mvn clean javadoc:javadoc -B
49+
build/publishJavadoc-gha.sh
50+
51+
- name: Publish to Maven Central
52+
env:
53+
OSSRH_USERNAME: ${{ secrets.OSSRH_USERNAME }}
54+
OSSRH_PASSWORD: ${{ secrets.OSSRH_PASSWORD }}
55+
GPG_KEYNAME: ${{ secrets.GPG_KEYNAME }}
56+
GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }}
57+
run: |
58+
echo "Publishing to maven central"
59+
# build only the "verify" goal for now until we're brave enough to try to deploy to MC :)
60+
mvn verify -B -DskipTests -P central
61+
ls -al target

.secrets.baseline

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"files": "package-lock.json|^.secrets.baseline$",
44
"lines": null
55
},
6-
"generated_at": "2024-10-01T20:10:03Z",
6+
"generated_at": "2025-01-08T20:47:36Z",
77
"plugins_used": [
88
{
99
"name": "AWSKeyDetector"
@@ -65,6 +65,16 @@
6565
}
6666
],
6767
"results": {
68+
".github/workflows/publish.yaml": [
69+
{
70+
"hashed_secret": "87ddb19c18c56534a4011f47f38530f6df9a8a80",
71+
"is_secret": false,
72+
"is_verified": false,
73+
"line_number": 34,
74+
"type": "Secret Keyword",
75+
"verified_result": null
76+
}
77+
],
6878
"Authentication.md": [
6979
{
7080
"hashed_secret": "91dfd9ddb4198affc5c194cd8ce6d338fde470e2",
@@ -172,7 +182,7 @@
172182
"hashed_secret": "360c23c1ac7d9d6dad1d0710606b0df9de6e1a18",
173183
"is_secret": false,
174184
"is_verified": false,
175-
"line_number": 63,
185+
"line_number": 61,
176186
"type": "Secret Keyword",
177187
"verified_result": null
178188
}

build/publishJavadoc-gha.sh

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
#!/bin/bash
2+
3+
# Required environment variables:
4+
# GH_TOKEN
5+
# GH_REPO_SLUG
6+
# GH_TAG
7+
8+
printf "\n>>>>> Publishing javadoc for release build: repo=%s tag=%s\n" ${GH_REPO_SLUG} ${GH_TAG}
9+
10+
printf "\n>>>>> Cloning repository's gh-pages branch into directory 'gh-pages'\n"
11+
rm -fr ./gh-pages
12+
git clone --branch=gh-pages https://${GH_TOKEN}@github.com/IBM/java-sdk-core.git gh-pages
13+
14+
printf "\n>>>>> Finished cloning...\n"
15+
16+
pushd gh-pages
17+
18+
# Create a new directory for this branch/tag and copy the javadocs there.
19+
printf "\n>>>>> Copying javadocs to new directory: docs/%s\n" ${GH_TAG}
20+
rm -rf docs/${GH_TAG}
21+
mkdir -p docs/${GH_TAG}
22+
cp -rf ../target/site/apidocs/* docs/${GH_TAG}
23+
24+
printf "\n>>>>> Generating gh-pages index.html...\n"
25+
../build/generateJavadocIndex.sh > index.html
26+
27+
printf "\n>>>>> Committing new javadoc...\n"
28+
git add -f .
29+
git commit -m "docs: latest javadoc for ${GH_TAG}"
30+
git push -f origin gh-pages
31+
32+
popd
33+
34+
printf "\n>>>>> Published javadoc for release build: repo=%s tag=%s\n" ${GH_REPO_SLUG} ${GH_TAG}
35+

0 commit comments

Comments
 (0)