Skip to content

Commit

Permalink
add release pipeline and publishing using gpr
Browse files Browse the repository at this point in the history
  • Loading branch information
vahidlazio committed Jul 12, 2023
1 parent 7668aa1 commit 7c8520d
Show file tree
Hide file tree
Showing 5 changed files with 91 additions and 29 deletions.
11 changes: 0 additions & 11 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,17 +12,6 @@ jobs:
Tests:
runs-on: ubuntu-latest
steps:
# Fetch and publish the OpenFeature SDK locally, using remote "main" branch
# This should be removed once the SDK artifacts are openly deployed
- name: webfactory/ssh-agent
uses: webfactory/ssh-agent@v0.7.0
with:
ssh-private-key: ${{ secrets.SDK_REPO_PRIVATE_KEY }}
- name: Clone OpenFeature SDK dependency
run: git clone git@github.com:spotify/openfeature-kotlin-sdk.git
- name: Publish OpenFeature SDK locally
run: ./openfeature-kotlin-sdk/gradlew publishToMavenLocal -p openfeature-kotlin-sdk

- name: Checkout
uses: actions/checkout@v3
- name: Run checks
Expand Down
54 changes: 54 additions & 0 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
name: Release
on:
push:
tags:
- 'v*'

jobs:
publish:
name: Release Spotify Confidence Provider
runs-on: ubuntu-latest

steps:
- name: Cache Gradle and wrapper
uses: actions/cache@v2
with:
path: |
~/.gradle/caches
~/.gradle/wrapper
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*') }}
restore-keys: |
${{ runner.os }}-gradle-
- uses: actions/checkout@v1

- name: Set up JDK 12
uses: actions/setup-java@v1
with:
java-version: 12

- name: Grant Permission for Gradlew to Execute
run: chmod +x gradlew

- name: Build AAR ⚙️🛠
run: bash ./gradlew :provider:assemble

- name: Create Release ✅
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.TOKEN_PUBLISH }}
with:
tag_name: ${{ github.ref }}
release_name: ${{ github.ref }}
draft: true
prerelease: false

- name: Upload Confidence Provider AAR 🗳
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.TOKEN_PUBLISH }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: Provider/build/outputs/aar/Provider-release.aar
asset_name: provider-release.aar
asset_content_type: application/aar
46 changes: 31 additions & 15 deletions Provider/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
// ktlint-disable max-line-length

configurations.all {
resolutionStrategy.cacheChangingModulesFor(0, "seconds")
}

plugins {
id("com.android.library")
Expand Down Expand Up @@ -45,17 +50,12 @@ android {
kotlinOptions {
jvmTarget = JavaVersion.VERSION_1_8.toString()
}

publishing {
singleVariant("release") {
withSourcesJar()
withJavadocJar()
}
}
}

dependencies {
api("dev.openfeature:kotlin-sdk:${Versions.openFeatureSDK}")
api("com.github.spotify:openfeature-kotlin-sdk:release-pipeline-SNAPSHOT") {
isChanging = true
}
implementation("com.squareup.okhttp3:okhttp:${Versions.okHttp}")
implementation(
"org.jetbrains.kotlinx:kotlinx-serialization-json:${Versions.kotlinxSerialization}"
Expand All @@ -67,15 +67,31 @@ dependencies {
testImplementation("com.squareup.okhttp3:mockwebserver:${Versions.mockWebServer}")
}

publishing {
publications {
register<MavenPublication>("release") {
groupId = "dev.openfeature.contrib.providers"
artifactId = "confidence"
version = Versions.providerVersion
afterEvaluate {
afterEvaluate {
publishing {
publications {
register<MavenPublication>("release") {
groupId = "dev.openfeature.contrib.providers"
artifactId = "confidence"
version = Versions.providerVersion

from(components["release"])
artifact(androidSourcesJar.get())

pom {
name.set("SpotifyConfidenceProvider")
}
}
}
}
}

val androidSourcesJar by tasks.registering(Jar::class) {
archiveClassifier.set("sources")
from(android.sourceSets.getByName("main").java.srcDirs)
}

// Assembling should be performed before publishing package
tasks.named("publish") {
dependsOn("assemble")
}
4 changes: 1 addition & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
# OpenFeature Kotlin Confidence Provider

Kotlin implementation of the Confidence feature provider, to be used in conjunction with the OpenFeature SDK.

## Usage

### Adding the package dependency

### Adding the package dependency [![](https://jitpack.io/v/spotify/confidence-openfeature-provider-kotlin.svg)](https://jitpack.io/#spotify/confidence-openfeature-provider-kotlin)
Add the following dependency to your gradle file:
```
implementation("dev.openfeature.contrib.providers:confidence:<LATEST>")
Expand Down
5 changes: 5 additions & 0 deletions settings.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,12 @@ dependencyResolutionManagement {
google()
mavenCentral()
mavenLocal()

maven {
url = uri("https://jitpack.io")
}
}
}

rootProject.name = "Provider"
include(":Provider")

0 comments on commit 7c8520d

Please sign in to comment.