Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
122 changes: 26 additions & 96 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,9 @@ on:

jobs:

package:
build-lib:
runs-on: ubuntu-24.04

permissions:
contents: read
packages: write

steps:
- name: Checkout
uses: actions/checkout@v4
Expand All @@ -30,99 +26,45 @@ jobs:
- name: Setup Gradle
uses: gradle/actions/setup-gradle@v3

- name: Set up Git Hub Pages
uses: actions/configure-pages@v5

- name: Setup Android SDK
uses: android-actions/setup-android@v3
with:
packages: ndk-bundle

- name: Setup Flutter SDK
uses: flutter-actions/setup-flutter@v3
with:
version: 3.29.2

- name: Cache Gradle packages
uses: actions/cache@v4
with:
path: |
~/.gradle/caches
~/.gradle/wrapper
key: gradle-${{ runner.os }}-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }}
restore-keys: gradle-${{ runner.os }}

- name: Get pub cache location
id: get-pub-cache
shell: bash
run: |
echo "pub_cache=$PUB_CACHE" >> "$GITHUB_OUTPUT"

- name: Cache Pub
uses: actions/cache@v3
with:
path: ${{ steps.get-pub-cache.outputs.pub_cache }}
key: pub-${{ runner.os }}-${{ hashFiles('**/pubspec.lock') }}

- name: Inflate Keystore
env:
ANDROID_JKS: ${{ secrets.ANDROID_JKS }}
ANDROID_JKS_SHA256: ${{ secrets.ANDROID_JKS_SHA256 }}
run: |
JKS_FILE="$(mktemp -p "${RUNNER_TEMP}" -d)/android.jks"
echo -n "$ANDROID_JKS" | base64 --decode > "$JKS_FILE"

if [ "${ANDROID_JKS_SHA256} *-" != "$(cat $JKS_FILE | sha256sum -b)" ]; then
exit 1
fi

echo "ANDROID_JKS_FILE=$JKS_FILE" >> $GITHUB_ENV

- name: Flutter plugin dependencies
working-directory: flutter
run: |
flutter pub get \
|| exit $?

- name: Analyze Flutter plugin
working-directory: flutter
run: |
flutter analyze \
--no-pub \
|| exit $?

- name: Lint Flutter plugin
working-directory: flutter
run: |
dart format \
--set-exit-if-changed \
. \
|| exit $?

- name: Build
env:
ANDROID_JKS_PASSWORD: ${{ secrets.ANDROID_JKS_PASSWORD }}
run: ./gradlew assembleRelease publishToMavenLocal
run: ./gradlew :lib:assembleRelease

- name: Upload lib artifacts
- name: Upload artifacts
uses: actions/upload-artifact@v4
with:
name: lib
path: lib/build/outputs/aar/*-release.aar

- name: Build Flutter example
working-directory: flutter/example
- name: Stage snapshot artifacts
if: ${{ (github.event_name == 'push' && github.ref_name == 'main') || (github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name == github.repository) }}
run: >
./gradlew :lib:publishReleasePublicationToStagingDeployRepository
-Puvccamera.version=${{ github.event_name == 'pull_request' && format('PR-{0}-SNAPSHOT', github.event.pull_request.number) || 'main-SNAPSHOT' }}

- name: Publish snapshot artifacts
if: ${{ github.event_name == 'push' && github.ref_name == 'main' }}
env:
ANDROID_JKS_PASSWORD: ${{ secrets.ANDROID_JKS_PASSWORD }}
run: flutter build apk
JRELEASER_GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
JRELEASER_NEXUS2_SNAPSHOTS_USERNAME: ${{ secrets.MAVEN_CENTRAL_USERNAME }}
JRELEASER_NEXUS2_SNAPSHOTS_PASSWORD: ${{ secrets.MAVEN_CENTRAL_PASSWORD }}
JRELEASER_GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }}
JRELEASER_GPG_PUBLIC_KEY: ${{ secrets.GPG_PUBLIC_KEY }}
JRELEASER_GPG_SECRET_KEY: ${{ secrets.GPG_PRIVATE_KEY }}
run: ./gradlew jreleaserDeploy --no-configuration-cache -Puvccamera.version=main-SNAPSHOT

build-github-pages:
runs-on: ubuntu-24.04

- name: Upload Flutter example artifacts
uses: actions/upload-artifact@v4
with:
name: flutter-example
path: flutter/example/build/app/outputs/flutter-apk/*-release.apk
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Build docs
- name: Build
run: |
sudo apt-get install -y pandoc

Expand All @@ -141,29 +83,17 @@ jobs:
with:
path: build/gh-pages

- name: Publish artifacts
if: ${{ github.event_name == 'push' && github.ref_name == 'main' }}
env:
ANDROID_JKS_PASSWORD: ${{ secrets.ANDROID_JKS_PASSWORD }}
GPG_PRIVATE_KEY: ${{ secrets.GPG_PRIVATE_KEY }}
GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
OSSRH_USERNAME: ${{ secrets.OSSRH_USERNAME }}
OSSRH_TOKEN: ${{ secrets.OSSRH_TOKEN }}
run: ./gradlew publish -Puvccamera.version=${{ github.ref_name }}-SNAPSHOT

publish-github-pages:
if: ${{ github.event_name == 'push' && github.ref_name == 'main' }}

runs-on: ubuntu-24.04

permissions:
contents: read
pages: write
id-token: write

needs:
- package
- build-github-pages

environment:
name: github-pages
Expand Down
17 changes: 10 additions & 7 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -105,15 +105,18 @@ jobs:
name: flutter-example
path: flutter/example/build/app/outputs/flutter-apk/*-release.apk

- name: Stage library artifacts
run: ./gradlew :lib:publishReleasePublicationToStagingDeployRepository -Puvccamera.version=${{ github.ref_name }}

- name: Publish library artifacts
env:
ANDROID_JKS_PASSWORD: ${{ secrets.ANDROID_JKS_PASSWORD }}
GPG_PRIVATE_KEY: ${{ secrets.GPG_PRIVATE_KEY }}
GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
OSSRH_USERNAME: ${{ secrets.OSSRH_USERNAME }}
OSSRH_TOKEN: ${{ secrets.OSSRH_TOKEN }}
run: ./gradlew :lib:publish -Puvccamera.version=${{ github.ref_name }}
JRELEASER_GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
JRELEASER_MAVENCENTRAL_SONATYPE_USERNAME: ${{ secrets.MAVEN_CENTRAL_USERNAME }}
JRELEASER_MAVENCENTRAL_SONATYPE_PASSWORD: ${{ secrets.MAVEN_CENTRAL_PASSWORD }}
JRELEASER_GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }}
JRELEASER_GPG_PUBLIC_KEY: ${{ secrets.GPG_PUBLIC_KEY }}
JRELEASER_GPG_SECRET_KEY: ${{ secrets.GPG_PRIVATE_KEY }}
run: ./gradlew jreleaserDeploy --no-configuration-cache -Puvccamera.version=${{ github.ref_name }}

- name: Publish Flutter plugin
working-directory: flutter
Expand Down
6 changes: 6 additions & 0 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
// Top-level build file where you can add configuration options common to all sub-projects/modules.
plugins {
base
alias(libs.plugins.android.library) apply false
alias(libs.plugins.android.application) apply false
alias(libs.plugins.jreleaser)
}

jreleaser {
configFile = file("jreleaser.yml")
}
2 changes: 2 additions & 0 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
[versions]
agp = "8.9.1"
jreleaser = "1.22.0"
junit = "4.13.2"
supportTestRunner = "1.0.2"
supportEspressoCore = "3.0.2"
Expand Down Expand Up @@ -32,3 +33,4 @@ swiperefreshlayout = { group = "androidx.swiperefreshlayout", name = "swiperefre
[plugins]
android-library = { id = "com.android.library", version.ref = "agp" }
android-application = { id = "com.android.application", version.ref = "agp" }
jreleaser = { id = "org.jreleaser", version.ref = "jreleaser" }
39 changes: 39 additions & 0 deletions jreleaser.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
project:
name: UVCCamera
description: USB Video (UVC) Camera Library for Android
authors:
- saki
- Alexey Pelykh
license: Apache-2.0
links:
homepage: https://uvccamera.org
languages:
java:
groupId: org.uvccamera
version: 17
versionPattern: CUSTOM

release:
github:
skipRelease: true

signing:
active: ALWAYS
pgp:
armored: true

deploy:
maven:
mavenCentral:
sonatype:
active: RELEASE
url: https://central.sonatype.com/api/v1/publisher
stagingRepositories:
- lib/build/staging-deploy
nexus2:
snapshots:
active: SNAPSHOT
url: https://central.sonatype.com/repository/maven-snapshots/
snapshotUrl: https://central.sonatype.com/repository/maven-snapshots/
stagingRepositories:
- lib/build/staging-deploy
32 changes: 2 additions & 30 deletions lib/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
plugins {
alias(libs.plugins.android.library)
id("maven-publish")
id("signing")
}

version = findProperty("uvccamera.version") as String? ?: "0.0.0-SNAPSHOT"
Expand Down Expand Up @@ -98,35 +97,8 @@ publishing {

repositories {
maven {
name = "GitHubPackages"
url = uri("https://maven.pkg.github.com/" + System.getenv("GITHUB_REPOSITORY"))
credentials {
username = System.getenv("GITHUB_ACTOR")
password = System.getenv("GITHUB_TOKEN")
}
}

maven {
name = "OSSRH"
url = uri(
if (project.version.toString().endsWith("-SNAPSHOT"))
"https://s01.oss.sonatype.org/content/repositories/snapshots/"
else
"https://s01.oss.sonatype.org/service/local/staging/deploy/maven2/"
)
credentials {
username = System.getenv("OSSRH_USERNAME")
password = System.getenv("OSSRH_TOKEN")
}
name = "StagingDeploy"
url = uri(layout.buildDirectory.dir("staging-deploy"))
}
}
}

val gpgPassphrase: String? = System.getenv("GPG_PASSPHRASE")
val gpgPrivateKey: String? = System.getenv("GPG_PRIVATE_KEY")
if (gpgPassphrase != null && gpgPrivateKey != null) {
signing {
useInMemoryPgpKeys(gpgPrivateKey, gpgPassphrase)
sign(publishing.publications["release"])
}
}
Loading