Skip to content

Commit d195b8c

Browse files
committed
Initial setup of github actions
1 parent b566ac7 commit d195b8c

File tree

4 files changed

+240
-0
lines changed

4 files changed

+240
-0
lines changed

.github/actions/setup/action.yml

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
name: "setup"
2+
description: "Setups App Version, JDK and Gradle for the project"
3+
author: "Henry Addo"
4+
5+
inputs:
6+
java-version:
7+
description: "Java version"
8+
default: "21"
9+
java-distribution:
10+
description: "Java distribution"
11+
default: "zulu"
12+
13+
runs:
14+
using: "composite"
15+
steps:
16+
- name: Validate Gradle Wrapper
17+
uses: gradle/actions/wrapper-validation@v3
18+
- name: Setup JDK ${{ inputs.java-version }} from ${{ inputs.java-distribution }} distribution
19+
uses: actions/setup-java@v4
20+
with:
21+
distribution: ${{ inputs.java-distribution }}
22+
java-version: ${{ inputs.java-version }}
23+
- name: Setup Gradle
24+
uses: gradle/actions/setup-gradle@v3
25+
with:
26+
gradle-version: wrapper
27+
- name: Setup Konan cache key # Kotlin native dependencies
28+
id: konan-cache-key
29+
shell: bash
30+
run: echo "KOTLIN_VERSION=$(grep -oE 'kotlin\s*=\s*"[0-9.]*"' gradle/libs.versions.toml | grep -oE '[0-9.]+')" >> $GITHUB_OUTPUT
31+
32+
- name: Cache Konan # Kotlin native dependencies
33+
uses: actions/cache@v4
34+
with:
35+
path: |
36+
~/.konan
37+
key: v1-konan-${{ runner.os }}-${{ hashFiles('.sdkmanrc') }}-${{ steps.konan-cache-key.outputs.KOTLIN_VERSION }}
38+
- name: Setup App Version Number
39+
shell: bash
40+
run: |
41+
echo "VERSION_NAME=$(./gradlew -q --no-configuration-cache printVersionName)" >> $GITHUB_ENV

.github/workflows/deploy.yml

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
# This workflow uses actions that are not certified by GitHub.
2+
# They are provided by a third-party and are governed by
3+
# separate terms of service, privacy policy, and support
4+
# documentation.
5+
# This workflow will build a Java project with Gradle and cache/restore any dependencies to improve the workflow execution time
6+
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-java-with-gradle
7+
8+
name: Deploy to central
9+
10+
on:
11+
push:
12+
tags:
13+
- 'v*.*.*'
14+
15+
permissions:
16+
contents: read
17+
18+
jobs:
19+
build:
20+
uses: ./.github/workflows/gradle.yml
21+
deploy:
22+
needs: build
23+
runs-on: macos-latest
24+
permissions:
25+
contents: write
26+
steps:
27+
- uses: actions/checkout@v4
28+
- name: Setup
29+
uses: ./.github/actions/setup
30+
- name: Gradle publish
31+
uses: gradle/actions/setup-gradle@v3
32+
env:
33+
OSSRH_GPG_SECRET_KEY_PASSWORD: ${{ secrets.OSSRH_GPG_SECRET_KEY_PASSWORD }}
34+
OSSRH_GPG_SECRET_KEY_ID: ${{ secrets.OSSRH_GPG_SECRET_KEY_ID }}
35+
OSSRH_GPG_SECRET_KEY: ${{ secrets.OSSRH_GPG_SECRET_KEY }}
36+
OSSRH_USERNAME: ${{ secrets.OSSRH_USERNAME }}
37+
OSSRH_PASSWORD: ${{ secrets.OSSRH_PASSWORD }}
38+
with:
39+
arguments: |
40+
--no-configuration-cache
41+
publishToSonatype
42+
closeAndReleaseSonatypeStagingRepository
43+
-Psigning.gnupg.keyName='${{secrets.OSSRH_GPG_SECRET_KEY_ID}}'
44+
45+
- name: Extract release notes
46+
id: release_notes
47+
uses: ffurrer2/extract-release-notes@v2
48+
49+
- name: Create release
50+
uses: ncipollo/release-action@v1
51+
with:
52+
body: ${{ steps.release_notes.outputs.release_notes }}

.github/workflows/gradle.yml

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
# This workflow uses actions that are not certified by GitHub.
2+
# They are provided by a third-party and are governed by
3+
# separate terms of service, privacy policy, and support
4+
# documentation.
5+
# This workflow will build a Java project with Gradle and cache/restore any dependencies to improve the workflow execution time
6+
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-java-with-gradle
7+
8+
name: Build
9+
10+
on:
11+
push:
12+
branches:
13+
- main
14+
paths-ignore:
15+
- '**.md'
16+
- 'docs/**'
17+
pull_request:
18+
paths-ignore:
19+
- '**.md'
20+
- 'docs/**'
21+
workflow_call:
22+
23+
permissions:
24+
contents: read
25+
26+
jobs:
27+
build:
28+
# Skip build if head commit contains 'skip ci'
29+
if: "!contains(github.event.head_commit.message, 'skip ci')"
30+
strategy:
31+
matrix:
32+
include:
33+
- target: iosSimulatorArm64Test
34+
os: macos-latest
35+
- target: iosX64Test
36+
os: macos-latest
37+
- target: testDebugUnitTest
38+
os: ubuntu-latest
39+
runs-on: ${{ matrix.os }}
40+
timeout-minutes: 60
41+
42+
steps:
43+
- name: Checkout
44+
uses: actions/checkout@v4
45+
- name: Setup
46+
uses: ./.github/actions/setup
47+
- name: Spotless Check
48+
run: ./gradlew spotlessCheck --stacktrace
49+
- name: Lint
50+
run: ./gradlew lint --stacktrace
51+
- name: Build with Gradle
52+
uses: gradle/actions/setup-gradle@v3
53+
with:
54+
arguments: ${{ matrix.target }}
55+
publish-snapshots:
56+
runs-on: macos-latest
57+
if: github.repository == 'addhen/kanalytics' && github.ref == 'refs/heads/main' && github.event_name != 'pull_request'
58+
needs: [build]
59+
steps:
60+
- name: Checkout
61+
uses: actions/checkout@v4
62+
- name: Setup
63+
uses: ./.github/actions/setup
64+
- name: Upload Snapshot
65+
uses: gradle/actions/setup-gradle@v3
66+
if: success() && endsWith(env.VERSION_NAME, '-SNAPSHOT')
67+
env:
68+
OSSRH_GPG_SECRET_KEY_PASSWORD: ${{ secrets.OSSRH_GPG_SECRET_KEY_PASSWORD }}
69+
OSSRH_GPG_SECRET_KEY_ID: ${{ secrets.OSSRH_GPG_SECRET_KEY_ID }}
70+
OSSRH_GPG_SECRET_KEY: ${{ secrets.OSSRH_GPG_SECRET_KEY }}
71+
OSSRH_USERNAME: ${{ secrets.OSSRH_USERNAME }}
72+
OSSRH_PASSWORD: ${{ secrets.OSSRH_PASSWORD }}
73+
with:
74+
arguments: |
75+
--no-configuration-cache
76+
publishAllPublicationsToSonatypeRepository
77+
closeSonatypeStagingRepository
78+
-Psigning.gnupg.keyName='${{secrets.OSSRH_GPG_SECRET_KEY_ID}}'

.github/workflows/publish-docs.yml

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
name: Publish docs
2+
3+
on:
4+
push:
5+
tags:
6+
- '*'
7+
workflow_dispatch:
8+
9+
permissions:
10+
contents: read
11+
pages: write
12+
id-token: write
13+
14+
jobs:
15+
deploy_docs:
16+
runs-on: macos-latest
17+
environment:
18+
name: github-pages
19+
url: ${{ steps.deployment.outputs.page_url }}
20+
21+
steps:
22+
- uses: actions/checkout@v4
23+
24+
- name: Setup JDK
25+
uses: actions/setup-java@v4
26+
with:
27+
distribution: 'zulu'
28+
java-version: 21
29+
30+
- name: Setup Python
31+
uses: actions/setup-python@v5
32+
with:
33+
python-version: '3.x'
34+
35+
- name: Setup Pages
36+
uses: actions/configure-pages@v5
37+
38+
- name: Install dependencies
39+
run: |
40+
brew install cairo freetype libffi libjpeg libpng zlib
41+
python3 -m pip install --upgrade pip
42+
python3 -m pip install mkdocs mkdocs-material mkdocs-video "mkdocs-material[imaging]"
43+
44+
- name: Copy files for the documentation site
45+
run: |
46+
cp CHANGELOG.md docs/changelog.md
47+
cp CONTRIBUTING.md docs/contributing.md
48+
cp CODE_OF_CONDUCT.md docs/code-of-conduct.md
49+
50+
- name: Build site
51+
run: mkdocs build
52+
env:
53+
DYLD_FALLBACK_LIBRARY_PATH: /opt/homebrew/lib
54+
55+
- uses: gradle/gradle-build-action@v3
56+
- run: |
57+
./gradlew --no-configuration-cache :dokkaHtmlMultiModule
58+
59+
- name: Copy Dokka output to site
60+
run: cp -r build/dokka/htmlMultiModule/ site/api/
61+
62+
- name: Upload artifact
63+
uses: actions/upload-pages-artifact@v3
64+
with:
65+
path: 'site'
66+
67+
- name: Deploy to GitHub Pages
68+
id: deployment
69+
uses: actions/deploy-pages@v4

0 commit comments

Comments
 (0)