Skip to content
This repository has been archived by the owner on Sep 13, 2023. It is now read-only.

Commit

Permalink
add the publishing to gpr and release pipeline
Browse files Browse the repository at this point in the history
  • Loading branch information
vahidlazio committed Jul 7, 2023
1 parent d6ab025 commit 97f7fb7
Show file tree
Hide file tree
Showing 2 changed files with 113 additions and 13 deletions.
66 changes: 66 additions & 0 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
name: Release
on:
# push:
# tags:
# - 'v*'
pull_request:
branches:
- '*'

jobs:
publish:
name: Release Openfeature SDK
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 :openfeature:assemble

- name: Publish to GitHub Package Registry 🚀
run: bash ./gradlew :openfeature:publish
env:
# todo, change this to something more generic
# check if we can use the spotify account for this
GPR_USER: vahidlazio
GPR_KEY: ${{ secrets.TOKEN_PUBLISH }}

- 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 Openfeature SDK AAR 🗳
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.TOKEN_PUBLISH }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: OpenFeature/build/outputs/aar/OpenFeature-release.aar
asset_name: openfeature-sdk.aar
asset_content_type: application/aar
60 changes: 47 additions & 13 deletions OpenFeature/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
// ktlint-disable max-line-length
import java.util.Properties

plugins {
id("com.android.library")
id("org.jetbrains.kotlin.android")
Expand Down Expand Up @@ -33,12 +36,6 @@ android {
kotlinOptions {
jvmTarget = JavaVersion.VERSION_1_8.toString()
}
publishing {
singleVariant("release") {
withSourcesJar()
withJavadocJar()
}
}
}

dependencies {
Expand All @@ -48,16 +45,53 @@ dependencies {
testImplementation("org.jetbrains.kotlinx:kotlinx-coroutines-test:1.7.1")
}

publishing {
publications {
register<MavenPublication>("release") {
groupId = "dev.openfeature"
artifactId = "kotlin-sdk"
version = "0.0.1-SNAPSHOT"
afterEvaluate {
publishing {
publications {
register<MavenPublication>("release") {
groupId = "dev.openfeature"
artifactId = "kotlin-sdk"
version = "0.0.1-SNAPSHOT"

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

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

repositories {
maven {
name = "GitHubPackages"
url = uri(
"https://maven.pkg.github.com/spotify/confidence-openfeature-provider-kotlin"
)
credentials {
val localProperties = Properties()
val localPropertiesFile = rootProject.file("local.properties")
if (localPropertiesFile.exists()) {
localProperties.load(rootProject.file("local.properties").inputStream())
}

username = localProperties.getProperty(
"GPR_USER",
System.getenv("GPR_USER")
)
password = localProperties.getProperty("GPR_KEY", System.getenv("GPR_KEY"))
}
}
}
}
}
}

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")
}

0 comments on commit 97f7fb7

Please sign in to comment.