Skip to content

Commit 04dfc3f

Browse files
committed
Initial commit
0 parents  commit 04dfc3f

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

53 files changed

+45601
-0
lines changed

.github/workflows/callable.build.yml

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
name: Build & Test
2+
3+
on: workflow_call
4+
5+
jobs:
6+
build:
7+
name: gradle build
8+
runs-on: ubuntu-latest
9+
steps:
10+
- name: Checkout project sources
11+
uses: actions/checkout@v4
12+
13+
- uses: actions/setup-java@v4
14+
with:
15+
distribution: 'corretto'
16+
java-version: '21'
17+
18+
- uses: gradle/actions/wrapper-validation@v3
19+
20+
- name: Setup Gradle
21+
uses: gradle/actions/setup-gradle@v3.3.2
22+
with:
23+
cache-write-only: true
24+
25+
- name: Build with Gradle
26+
run: ./gradlew build --no-daemon
Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
name: Gradle Release
2+
3+
on:
4+
workflow_call:
5+
inputs:
6+
type:
7+
description: 'Release type'
8+
required: true
9+
type: string
10+
11+
jobs:
12+
release:
13+
name: gradle release
14+
runs-on: ubuntu-latest
15+
steps:
16+
- name: Validate 'Release Type' param
17+
env:
18+
TYPE: ${{ inputs.type }}
19+
run: |
20+
valid_types=(major minor patch)
21+
if [[ ! ${valid_types[*]} =~ "$TYPE" ]]; then
22+
echo "Unknown release type: $TYPE"
23+
exit 1
24+
fi
25+
26+
- name: Checkout project sources ('main' branch)
27+
uses: actions/checkout@v4
28+
with:
29+
ref: main
30+
token: ${{ secrets.CI_GITHUB_TOKEN }}
31+
- uses: actions/setup-java@v4
32+
with:
33+
distribution: 'corretto'
34+
java-version: '21'
35+
36+
- uses: gradle/actions/wrapper-validation@v3
37+
38+
- name: Setup Gradle
39+
uses: gradle/actions/setup-gradle@v3.3.2
40+
with:
41+
cache-read-only: true
42+
43+
- name: Get current version
44+
run: |
45+
source gradle.properties
46+
echo "current_version=${version}" >> $GITHUB_ENV
47+
48+
- name: Determine version type
49+
env:
50+
TYPE: ${{ inputs.type }}
51+
VERSION: ${{ env.current_version }}
52+
run: |
53+
export major=$(echo "${VERSION}" | cut -d. -f1)
54+
export minor=$(echo "${VERSION}" | cut -d. -f2)
55+
export patch=$(echo "${VERSION}" | cut -d. -f3 | cut -d- -f1)
56+
echo "resolved: ${major}.${minor}.${patch}"
57+
58+
if [[ "$TYPE" == "major" ]]; then
59+
echo "new_version=$((major+1)).0.0" >> $GITHUB_ENV
60+
echo "new_snapshot_version=$((major+1)).0.1-SNAPSHOT" >> $GITHUB_ENV
61+
elif [ "$TYPE" == "minor" ]; then
62+
echo "new_version=${major}.$((minor+1)).0" >> $GITHUB_ENV
63+
echo "new_snapshot_version=${major}.$((minor+1)).1-SNAPSHOT" >> $GITHUB_ENV
64+
else
65+
echo "new_version=${major}.${minor}.${patch}" >> $GITHUB_ENV
66+
echo "new_snapshot_version=${major}.${minor}.$((patch+1))-SNAPSHOT" >> $GITHUB_ENV
67+
fi
68+
69+
- name: Set git config 'user.name' and 'user.email'
70+
run: |
71+
git config --local user.email "action@github.com"
72+
git config --local user.name "github-actions[bot]"
73+
74+
- name: Run 'gradle release'
75+
run: |
76+
echo "Type: ${{ inputs.type }}"
77+
echo "Current version: ${{ env.current_version }}"
78+
echo "New version: ${{ env.new_version }}"
79+
echo "New snapshot version: ${{ env.new_snapshot_version }}"
80+
echo "./gradlew release -Prelease.useAutomaticVersion=true -Prelease.releaseVersion=${{ env.new_version }} -Prelease.newVersion=${{ env.new_snapshot_version }}"
81+
gradle release -Prelease.useAutomaticVersion=true -Prelease.releaseVersion=${{ env.new_version }} -Prelease.newVersion=${{ env.new_snapshot_version }}
Lines changed: 152 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,152 @@
1+
name: Publish javadoc (GitHub Pages)
2+
3+
on:
4+
workflow_dispatch:
5+
workflow_call:
6+
7+
jobs:
8+
build_package_javadoc:
9+
name: Generate Javadoc
10+
runs-on: ubuntu-latest
11+
permissions:
12+
contents: write
13+
steps:
14+
- name: Checkout project sources
15+
uses: actions/checkout@v4
16+
17+
- uses: actions/setup-java@v4
18+
with:
19+
distribution: 'corretto'
20+
java-version: '21'
21+
22+
- uses: gradle/actions/wrapper-validation@v3
23+
- name: Setup Gradle
24+
uses: gradle/actions/setup-gradle@v3.3.2
25+
with:
26+
cache-read-only: true
27+
28+
- name: Generate javadoc (gradle)
29+
run: ./gradlew javadoc
30+
31+
- name: Conclude javadoc version and set env
32+
run: |
33+
if [[ "$GITHUB_REF" == "refs/heads/main" || "$GITHUB_REF" == "refs/heads/master" ]]; then
34+
echo "PUBLISH_VERSION=current" >> $GITHUB_ENV
35+
else
36+
echo "PUBLISH_VERSION=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV
37+
fi
38+
39+
- name: zip javadoc folder
40+
env:
41+
LIBRARY_NAME: ${{ env.LIBRARY_NAME }}
42+
run: |
43+
cd "lib/build/docs/javadoc"
44+
zip -r ../../../../javadoc.zip .
45+
46+
- name: Upload artifact
47+
uses: actions/upload-artifact@v4
48+
with:
49+
name: javadoc.zip
50+
path: javadoc.zip
51+
52+
deploy_javadoc:
53+
name: Deploy (GH Pages)
54+
runs-on: ubuntu-latest
55+
needs: build_package_javadoc
56+
permissions:
57+
contents: write
58+
steps:
59+
- name: Checkout project sources
60+
uses: actions/checkout@v4
61+
with:
62+
ref: main
63+
token: ${{ secrets.CI_GITHUB_TOKEN || secrets.GITHUB_TOKEN }}
64+
65+
- name: Checkout or create empty branch 'gh-pages'
66+
run: |
67+
git fetch origin gh-pages || true
68+
git checkout gh-pages || git switch --orphan gh-pages
69+
70+
- name: Conclude javadoc version and set env
71+
run: |
72+
if [[ "$GITHUB_REF" == "refs/heads/main" || "$GITHUB_REF" == "refs/heads/master" ]]; then
73+
echo "PUBLISH_VERSION=current" >> $GITHUB_ENV
74+
else
75+
echo "PUBLISH_VERSION=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV
76+
fi
77+
78+
- name: Create root index redirect
79+
env:
80+
GITHUB_REPOSITORY_NAME: ${{ github.event.repository.name }}
81+
run: |
82+
echo "<!DOCTYPE html><html lang=en><meta content=\"text/html; charset=utf-8\"http-equiv=Content-Type><meta content=\"index redirect\"name=description><link href=/$GITHUB_REPOSITORY_NAME/javadoc/ rel=canonical><link href=stylesheet.css rel=stylesheet title=Style><script>window.location.replace(\"/$GITHUB_REPOSITORY_NAME/javadoc/\")</script><noscript><meta content=0;/$GITHUB_REPOSITORY_NAME/javadoc/ http-equiv=Refresh></noscript><main role=main><noscript><p>JavaScript is disabled on your browser.</p></noscript><p><a href=/$GITHUB_REPOSITORY_NAME/javadoc/ >/$GITHUB_REPOSITORY_NAME/javadoc/</a></main>" > index.html
83+
84+
- name: Download artifact from build job
85+
uses: actions/download-artifact@v4
86+
with:
87+
name: javadoc.zip
88+
89+
- name: unzip javadoc folder
90+
env:
91+
PUBLISH_VERSION: ${{ env.PUBLISH_VERSION }}
92+
run: |
93+
mkdir -p javadoc
94+
rm -Rf "javadoc/$PUBLISH_VERSION" || true
95+
unzip -d "javadoc/$PUBLISH_VERSION" javadoc.zip
96+
rm javadoc.zip
97+
98+
- name: Create javadoc index.html listing versions
99+
env:
100+
PUBLISH_VERSION: ${{ env.PUBLISH_VERSION }}
101+
GITHUB_REPOSITORY_NAME: ${{ github.event.repository.name }}
102+
run: |
103+
mkdir -p javadoc
104+
rm javadoc/index.html || true
105+
touch javadoc/index.html
106+
107+
versions=( $(cd javadoc && find . -maxdepth 1 -type d | jq -srR 'split("\n") | unique | .[][2:] | select(length > 0)') )
108+
109+
echo "javadoc versions:"
110+
for value in "${versions[@]}"
111+
do
112+
echo "- $value"
113+
done
114+
115+
echo "<!DOCTYPE HTML>" >> javadoc/index.html
116+
echo "<html lang=\"en\">" >> javadoc/index.html
117+
echo "<head>" >> javadoc/index.html
118+
echo " <title>Javadoc | '$GITHUB_REPOSITORY_NAME'</title>" >> javadoc/index.html
119+
echo " <meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\">" >> javadoc/index.html
120+
echo " <meta charset=\"UTF-8\">" >> javadoc/index.html
121+
echo " <meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\">" >> javadoc/index.html
122+
echo " <meta http-equiv=\"X-UA-Compatible\" content=\"ie=edge\">" >> javadoc/index.html
123+
echo " <meta name=\"description\" content=\"Javadoc for library '$GITHUB_REPOSITORY_NAME'\">" >> javadoc/index.html
124+
echo "</head>" >> javadoc/index.html
125+
echo "<body>" >> javadoc/index.html
126+
echo "<main style=\"font-family: sans-serif;\">" >> javadoc/index.html
127+
echo " <h1>Javadoc</h1>" >> javadoc/index.html
128+
echo " <h2>Versions</h2>" >> javadoc/index.html
129+
echo " <ul>" >> javadoc/index.html
130+
131+
for value in "${versions[@]}"
132+
do
133+
echo " <li><a href=\"$value\">$value</a></li>" >> javadoc/index.html
134+
done
135+
136+
echo " </ul>" >> javadoc/index.html
137+
echo "</main>" >> javadoc/index.html
138+
echo "</body>" >> javadoc/index.html
139+
echo "</html>" >> javadoc/index.html
140+
141+
- name: Commit files
142+
run: |
143+
git config --local user.email "action@github.com"
144+
git config --local user.name "github-actions[bot]"
145+
git add .
146+
git status
147+
git diff-index --quiet HEAD || git commit -m "chore: update index.html files incl. javadoc versions"
148+
149+
# Push changes
150+
- name: Push changes
151+
run: |
152+
git push --set-upstream origin gh-pages
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
name: Publish to Sonatype (Maven Central)
2+
3+
on:
4+
workflow_call:
5+
6+
jobs:
7+
publish:
8+
name: Publish to Sonatype (Maven Central)
9+
runs-on: ubuntu-latest
10+
steps:
11+
- name: Checkout project sources
12+
uses: actions/checkout@v4
13+
14+
- uses: actions/setup-java@v4
15+
with:
16+
distribution: 'corretto'
17+
java-version: '21'
18+
cache: 'gradle'
19+
20+
- uses: gradle/actions/wrapper-validation@v3
21+
22+
- name: Setup Gradle
23+
uses: gradle/actions/setup-gradle@v3.3.2
24+
with:
25+
cache-read-only: true
26+
27+
- name: Publish to Sonatype (Maven Central)
28+
if: github.ref_type == 'tag'
29+
env:
30+
ORG_GRADLE_PROJECT_mavenCentralUsername: ${{ secrets.MAVEN_CENTRAL_USERNAME }}
31+
ORG_GRADLE_PROJECT_mavenCentralPassword: ${{ secrets.MAVEN_CENTRAL_PASSWORD }}
32+
ORG_GRADLE_PROJECT_signingInMemoryKey: ${{ secrets.SIGNING_KEY }}
33+
ORG_GRADLE_PROJECT_signingInMemoryKeyPassword: ${{ secrets.SIGNING_PASSWORD }}
34+
run: ./gradlew publishMavenPublicationToMavenCentralRepository

.github/workflows/ci.yml

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches: [ "main" ]
6+
tags:
7+
- '*'
8+
pull_request:
9+
branches: [ '*' ]
10+
workflow_dispatch:
11+
inputs:
12+
type:
13+
description: 'Release Library'
14+
required: true
15+
default: '...no release'
16+
type: choice
17+
options:
18+
- '...no release'
19+
- major
20+
- minor
21+
- patch
22+
23+
jobs:
24+
build:
25+
name: Build
26+
uses: ./.github/workflows/callable.build.yml
27+
if: | # avoid unnecessary pipeline runs during artifact release process ('gradle release plugin')
28+
!contains(github.event.head_commit.message, 'chore: bump current version to')
29+
|| github.ref_type == 'tag'
30+
31+
gradle-release:
32+
name: Create Release
33+
uses: ./.github/workflows/callable.gradle-release.yml
34+
secrets: inherit
35+
with:
36+
type: ${{ inputs.type }}
37+
needs: build
38+
if: |
39+
github.event_name == 'workflow_dispatch'
40+
&& inputs.type != '...no release'
41+
42+
publish_sonatype:
43+
name: Publish artifact (Maven Central)
44+
uses: ./.github/workflows/callable.publish-sonatype.yml
45+
secrets: inherit
46+
needs: build
47+
if: |
48+
(
49+
github.event_name != 'workflow_dispatch'
50+
|| inputs.type == '...no release'
51+
) && (
52+
github.ref == 'refs/heads/main'
53+
|| github.ref_type == 'tag'
54+
)
55+
56+
publish_javadoc:
57+
name: Publish Javadoc to GitHub Pages
58+
permissions:
59+
contents: write
60+
uses: ./.github/workflows/callable.publish-javadoc.yml
61+
needs: build
62+
if: |
63+
(
64+
github.ref == 'refs/heads/main'
65+
&& ( inputs.type == '' || inputs.type == '...no release' )
66+
) || github.ref_type == 'tag'

0 commit comments

Comments
 (0)