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 379940b commit 0d448ec
Show file tree
Hide file tree
Showing 2 changed files with 89 additions and 14 deletions.
65 changes: 65 additions & 0 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
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-
# 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

- 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
38 changes: 24 additions & 14 deletions Provider/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// ktlint-disable max-line-length

plugins {
id("com.android.library")
Expand Down Expand Up @@ -46,13 +47,6 @@ android {
kotlinOptions {
jvmTarget = JavaVersion.VERSION_11.toString()
}

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

dependencies {
Expand All @@ -68,15 +62,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")
}

0 comments on commit 0d448ec

Please sign in to comment.