Skip to content

Commit

Permalink
build/ci: configure jgitver for automated versioning and configure mi…
Browse files Browse the repository at this point in the history
…sc ci stuff (#11)
  • Loading branch information
sargunv authored Nov 26, 2024
1 parent f2a9f7a commit d7c3e0c
Show file tree
Hide file tree
Showing 14 changed files with 186 additions and 128 deletions.
2 changes: 0 additions & 2 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,5 @@ root = true
[*]
end_of_line = lf
insert_final_newline = true

[*.{yml,json,kt,kts,swift,md}]
indent_style = space
indent_size = 2
47 changes: 24 additions & 23 deletions .github/actions/run-with-avd/action.yml
Original file line number Diff line number Diff line change
@@ -1,43 +1,44 @@
name: 'Execute with AVD'
description: 'Set up an Android virtual device, cache it, and run a script'
---
name: "Execute with AVD"
description: "Set up an Android virtual device, cache it, and run a script"
inputs:
api-level:
description: 'API level of the platform system image'
description: "API level of the platform system image"
required: true
script:
description: 'Custom script to run'
description: "Custom script to run"
required: true
runs:
using: "composite"
steps:
- name: Configure KVM
shell: bash
- name: "Configure KVM"
shell: "bash"
run: |
echo 'KERNEL=="kvm", GROUP="kvm", MODE="0666", OPTIONS+="static_node=kvm"' | sudo tee /etc/udev/rules.d/99-kvm4all.rules
sudo udevadm control --reload-rules
sudo udevadm trigger --name-match=kvm
- name: Cache AVD
uses: actions/cache@v4
id: avd-cache
- name: "Cache AVD"
uses: "actions/cache@v4"
id: "avd-cache"
with:
path: |
~/.android/avd/*
~/.android/adb*
key: avd-v${{ inputs.api-level }}
- name: Create AVD for caching
if: steps.avd-cache.outputs.cache-hit != 'true'
uses: reactivecircus/android-emulator-runner@v2
key: "avd-v${{ inputs.api-level }}"
- name: "Create AVD for caching"
if: "steps.avd-cache.outputs.cache-hit != 'true'"
uses: "reactivecircus/android-emulator-runner@v2"
with:
api-level: ${{ inputs.api-level }}
arch: x86_64
api-level: "${{ inputs.api-level }}"
arch: "x86_64"
force-avd-creation: false
emulator-options: -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none
script: echo "Generated AVD snapshot for caching."
- name: ${{ inputs.script }}
uses: reactivecircus/android-emulator-runner@v2
emulator-options: "-no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none"
script: "echo 'Generated AVD snapshot for caching.'"
- name: "${{ inputs.script }}"
uses: "reactivecircus/android-emulator-runner@v2"
with:
api-level: ${{ inputs.api-level }}
arch: x86_64
api-level: "${{ inputs.api-level }}"
arch: "x86_64"
force-avd-creation: false
emulator-options: -no-snapshot-save -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none
script: ${{ inputs.script }}
emulator-options: "-no-snapshot-save -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none"
script: "${{ inputs.script }}"
13 changes: 7 additions & 6 deletions .github/actions/setup/action.yml
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
name: 'Setup'
description: 'Set up the build environment, used by most jobs'
---
name: "Setup"
description: "Set up the build environment, used by most jobs"
runs:
using: "composite"
steps:
- uses: actions/setup-java@v4
- uses: "actions/setup-java@v4"
with:
distribution: 'temurin'
java-version: '21'
- uses: gradle/actions/setup-gradle@v4
distribution: "temurin"
java-version: "21"
- uses: "gradle/actions/setup-gradle@v4"
with:
build-scan-publish: true
build-scan-terms-of-use-url: "https://gradle.com/terms-of-service"
Expand Down
3 changes: 2 additions & 1 deletion .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
---
version: 2
updates:
- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: "weekly"
interval: "weekly"
- package-ecosystem: "gradle"
directory: "/"
schedule:
Expand Down
134 changes: 82 additions & 52 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,91 +1,121 @@
name: CI
---
name: "CI"

on:
push:
branches: [ "main" ]
branches: ["main"]
pull_request:
branches: [ "main" ]
branches: ["main"]

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
group: "${{ github.workflow }}-${{ github.ref }}"
cancel-in-progress: true

jobs:
check-format:
runs-on: ubuntu-latest
runs-on: "ubuntu-latest"
steps:
- uses: actions/checkout@v4
- uses: ./.github/actions/setup
- run: ./gradlew spotlessCheck
- uses: "actions/checkout@v4"
with:
fetch-depth: 0
- uses: "./.github/actions/setup"
- run: "./gradlew spotlessCheck"

check-podspec:
runs-on: "macos-latest"
steps:
- uses: "actions/checkout@v4"
with:
fetch-depth: 0
- uses: "./.github/actions/setup"
- run: "./gradlew podInstall"
- run: |
git diff -I '^COCOAPODS: [0-9]+\.[0-9]+\.[0-9]+$' --exit-code
lint-android:
runs-on: ubuntu-latest
runs-on: "ubuntu-latest"
steps:
- uses: actions/checkout@v4
- uses: ./.github/actions/setup
- run: ./gradlew lint
- uses: "actions/checkout@v4"
with:
fetch-depth: 0
- uses: "./.github/actions/setup"
- run: "./gradlew lint"

test-android:
runs-on: ubuntu-latest
runs-on: "ubuntu-latest"
steps:
- uses: actions/checkout@v4
- uses: ./.github/actions/setup
- name: Run with AVD ./gradlew connectedDebugAndroidTest
uses: ./.github/actions/run-with-avd
- uses: "actions/checkout@v4"
with:
fetch-depth: 0
- uses: "./.github/actions/setup"
- name: "Run with AVD ./gradlew connectedDebugAndroidTest"
uses: "./.github/actions/run-with-avd"
with:
api-level: 35
script: ./gradlew connectedDebugAndroidTest
script: "./gradlew connectedDebugAndroidTest"

test-ios:
runs-on: macos-latest
runs-on: "macos-latest"
steps:
- uses: actions/checkout@v4
- uses: ./.github/actions/setup
- run: ./gradlew iosSimulatorArm64Test
- uses: "actions/checkout@v4"
with:
fetch-depth: 0
- uses: "./.github/actions/setup"
- run: "./gradlew iosSimulatorArm64Test"

build-docs:
runs-on: macos-latest
runs-on: "macos-latest"
steps:
- uses: actions/checkout@v4
- uses: ./.github/actions/setup
- run: ./gradlew dokkaHtmlMultiModule
- uses: actions/upload-pages-artifact@v3
- uses: "actions/checkout@v4"
with:
path: build/dokka/htmlMultiModule
fetch-depth: 0
- uses: "./.github/actions/setup"
- run: "./gradlew dokkaHtmlMultiModule"
- uses: "actions/upload-pages-artifact@v3"
with:
path: "build/dokka/htmlMultiModule"

build-android-app:
runs-on: ubuntu-latest
runs-on: "ubuntu-latest"
steps:
- uses: actions/checkout@v4
- uses: ./.github/actions/setup
- run: ./gradlew packageDebug packageRelease
- uses: actions/upload-artifact@v4
- uses: "actions/checkout@v4"
with:
if-no-files-found: error
name: demo-app-debug
path: demo-app/build/outputs/apk/debug/demo-app-debug.apk
- uses: actions/upload-artifact@v4
fetch-depth: 0
- uses: "./.github/actions/setup"
- run: "./gradlew packageDebug"
- uses: "actions/upload-artifact@v4"
with:
if-no-files-found: error
name: demo-app-release-unsigned
path: demo-app/build/outputs/apk/release/demo-app-release-unsigned.apk
if-no-files-found: "error"
name: "demo-app-debug"
path: "demo-app/build/outputs/apk/debug/demo-app-debug.apk"

publish-snapshot:
needs: [test-android, test-ios]
if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/main' }}
runs-on: macos-latest
needs:
- "test-android"
- "test-ios"
if: "${{ github.event_name == 'push' && github.ref == 'refs/heads/main' }}"
runs-on: "macos-latest"
permissions:
packages: write
packages: "write"
steps:
- uses: actions/checkout@v4
- uses: ./.github/actions/setup
- run: ./gradlew publishAllPublicationsToGitHubPackagesRepository
- uses: "actions/checkout@v4"
with:
fetch-depth: 0
- uses: "./.github/actions/setup"
- run: "./gradlew publishAllPublicationsToGitHubPackagesRepository"
env:
ORG_GRADLE_PROJECT_githubToken: ${{ secrets.GITHUB_TOKEN }}
ORG_GRADLE_PROJECT_githubUser: ${{ github.actor }}
ORG_GRADLE_PROJECT_githubToken: "${{ secrets.GITHUB_TOKEN }}"
ORG_GRADLE_PROJECT_githubUser: "${{ github.actor }}"

all-good:
needs: [check-format, lint-android, test-android, test-ios, build-docs, build-android-app]
runs-on: ubuntu-latest
needs:
- "check-format"
- "check-podspec"
- "lint-android"
- "test-android"
- "test-ios"
- "build-docs"
- "build-android-app"
runs-on: "ubuntu-latest"
steps:
- run: echo "All checks passed!"
- run: "echo 'All checks passed!'"
20 changes: 11 additions & 9 deletions .github/workflows/dependency-submission.yml
Original file line number Diff line number Diff line change
@@ -1,23 +1,25 @@
name: Dependency Submission
---
name: "Dependency Submission"

on:
push:
branches: [ 'main' ]
branches:
- "main"

jobs:
dependency-submission:
runs-on: ubuntu-latest
runs-on: "ubuntu-latest"
permissions:
contents: write
contents: "write"
steps:
- uses: actions/checkout@v4
- uses: actions/setup-java@v4
- uses: "actions/checkout@v4"
- uses: "actions/setup-java@v4"
with:
distribution: temurin
distribution: "temurin"
java-version: 21
- uses: gradle/actions/dependency-submission@v4
- uses: "gradle/actions/dependency-submission@v4"
with:
build-scan-publish: true
build-scan-terms-of-use-url: "https://gradle.com/help/legal-terms-of-use"
build-scan-terms-of-use-agree: "yes"
- uses: advanced-security/[email protected]
- uses: "advanced-security/[email protected]"
57 changes: 32 additions & 25 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -1,39 +1,46 @@
name: Release
---
name: "Release"

on:
workflow_dispatch:
push:
tags: ["v*.*.*"]

jobs:
publish-maven:
runs-on: macos-latest
runs-on: "macos-latest"
environment:
name: maven-central
url: https://central.sonatype.com/namespace/dev.sargunv.maplibre-compose
name: "maven-central"
url: "https://central.sonatype.com/namespace/dev.sargunv.maplibre-compose"
steps:
- uses: actions/checkout@v4
- uses: ./.github/actions/setup
- run: ./gradlew publishAndReleaseToMavenCentral --no-configuration-cache
- uses: "actions/checkout@v4"
with:
fetch-depth: 0
- uses: "./.github/actions/setup"
- run: "./gradlew publishAndReleaseToMavenCentral --no-configuration-cache"
env:
ORG_GRADLE_PROJECT_mavenCentralUsername: ${{ secrets.MAVEN_CENTRAL_USERNAME }}
ORG_GRADLE_PROJECT_mavenCentralPassword: ${{ secrets.MAVEN_CENTRAL_PASSWORD }}
ORG_GRADLE_PROJECT_signingInMemoryKey: ${{ secrets.GPG_PRIVATE_KEY }}
ORG_GRADLE_PROJECT_signingInMemoryKeyPassword: ${{ secrets.GPG_PASSPHRASE }}
ORG_GRADLE_PROJECT_mavenCentralUsername: "${{ secrets.MAVEN_CENTRAL_USERNAME }}"
ORG_GRADLE_PROJECT_mavenCentralPassword: "${{ secrets.MAVEN_CENTRAL_PASSWORD }}"
ORG_GRADLE_PROJECT_signingInMemoryKey: "${{ secrets.GPG_PRIVATE_KEY }}"
ORG_GRADLE_PROJECT_signingInMemoryKeyPassword: "${{ secrets.GPG_PASSPHRASE }}"

publish-pages:
needs: [publish-maven]
runs-on: macos-latest
needs:
- "publish-maven"
runs-on: "macos-latest"
permissions:
pages: write
id-token: write
pages: "write"
id-token: "write"
environment:
name: github-pages
url: ${{ steps.deploy-pages.outputs.page_url }}
name: "github-pages"
url: "${{ steps.deploy-pages.outputs.page_url }}"
steps:
- uses: actions/checkout@v4
- uses: ./.github/actions/setup
- run: ./gradlew dokkaHtmlMultiModule
- uses: actions/upload-pages-artifact@v3
- uses: "actions/checkout@v4"
with:
fetch-depth: 0
- uses: "./.github/actions/setup"
- run: "./gradlew dokkaHtmlMultiModule"
- uses: "actions/upload-pages-artifact@v3"
with:
path: build/dokka/htmlMultiModule
- uses: actions/deploy-pages@v4
id: deploy-pages
path: "build/dokka/htmlMultiModule"
- uses: "actions/deploy-pages@v4"
id: "deploy-pages"
3 changes: 2 additions & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,5 @@ run the tests:

A Git pre-commit hook is available to ensure that the code is formatted before every commit. Run
`./gradlew installGitHooks` to install it. It will run `./gradlew spotlessApply` before every
commit.
commit. To run the formatter, you'll need to have `swift` installed (for `swift format`) and `npm`
installed (for `prettier`).
Loading

0 comments on commit d7c3e0c

Please sign in to comment.