Skip to content

Commit

Permalink
setup workflow to deploy on release
Browse files Browse the repository at this point in the history
  • Loading branch information
chrisjenx committed Oct 21, 2024
1 parent 304be13 commit 17242c7
Show file tree
Hide file tree
Showing 7 changed files with 82 additions and 24 deletions.
24 changes: 24 additions & 0 deletions .github/workflows/deploy-to-github.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
name: Create and publish a release to Github Packages

on:
workflow_dispatch:
release:
types: [published] # Will trigger on (pre)release creation

jobs:
build-and-publish:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Setup Java JDK
uses: actions/setup-java@v4
with:
distribution: 'zulu'
java-version: '21'
- name: Setup Gradle
uses: gradle/actions/setup-gradle
- name: Build and publish
run: ./gradlew publishAllPublicationsToGitHubPackagesRepository
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
RELEASE_VERSION: ${{ github.event.release.tag_name }}
22 changes: 8 additions & 14 deletions README.MD
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ SQLite and JSONB.
```kotlin
// Create a new instance of Sqkon
val sqkon = Sqkon(
context = context // (only for Android)
context = context // (only for Android)
)

// Create a Store for each type/entity you want to create
Expand Down Expand Up @@ -43,21 +43,15 @@ data class Merchant(

**TODO PUBLISH TO MAVEN CENTRAL GH ACTIONS**

1) Registering a Sonatype account as described here:
https://dev.to/kotlin/how-to-build-and-publish-a-kotlin-multiplatform-library-going-public-4a8k
2) Add developer id, name, email and the project url to
`/convention-plugins/src/main/kotlin/convention.publication.gradle.kts`
3) Add the secrets to `local.properties`:
### Publish to github packages

```
signing.keyId=...
signing.password=...
signing.secretKeyRingFile=...
ossrhUsername=...
ossrhPassword=...
```
Creating a new release will publish the artifacts to GitHub Packages.

If publishing locally you will need `GITHUB_ACTOR` and `GITHUB_TOKEN` environment variables set with
repository write permissions.

`./gradlew publishToGitHubPackages`

4) Run `./gradlew :core:publishAllPublicationsToSonatypeRepository`

### Build platform artifacts

Expand Down
37 changes: 30 additions & 7 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,18 +1,41 @@
import com.vanniktech.maven.publish.MavenPublishPlugin

plugins {
alias(libs.plugins.multiplatform).apply(false)
alias(libs.plugins.android.library).apply(false)
alias(libs.plugins.kotlinx.serialization).apply(false)
alias(libs.plugins.sqlDelight).apply(false)
alias(libs.plugins.axion.release)
alias(libs.plugins.maven.publish)
}

scmVersion {
nextVersion { suffix.set("alpha") }
versionCreator("versionWithCommitHash")
allprojects {
group = findProperty("GROUP").toString()
version = System.getenv("RELEASE_VERSION")?.takeIf { it.isNotBlank() }
?: findProperty("VERSION_NAME").toString()
}

version = scmVersion.version

subprojects {
project.version = rootProject.version
plugins.withType<MavenPublishPlugin>().configureEach {
extensions.findByType<PublishingExtension>()?.also { publishing ->
logger.lifecycle("Publishing ${project.group}:${project.name}:${project.version}")
publishing.repositories {
// GitHub Packages
maven {
name = "GitHubPackages"
url = uri("https://maven.pkg.github.com/MercuryTechnologies/sqkon")
credentials {
username = System.getenv("GITHUB_ACTOR")
password = System.getenv("GITHUB_TOKEN")
}
}
}
}
}
}

tasks.register("version") {
notCompatibleWithConfigurationCache("Version task is not compatible with configuration cache")
doLast {
println("Version: $version")
}
}
15 changes: 15 additions & 0 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,21 @@ org.gradle.configuration-cache=true
org.gradle.daemon=true
org.gradle.parallel=true

# Maven
GROUP=com.mercury.sqkon
VERSION_NAME=1.0.0-alpha01
POM_NAME=Sqkon
POM_INCEPTION_YEAR=2024
POM_URL=https://github.com/MercuryTechnologies/sqkon/
POM_LICENSE_NAME=The Apache Software License, Version 2.0
POM_LICENSE_URL=https://www.apache.org/licenses/LICENSE-2.0.txt
POM_LICENSE_DIST=repo
POM_SCM_URL=https://github.com/MercuryTechnologies/sqkon/
POM_SCM_CONNECTION=scm:git:git://github.com/MercuryTechnologies/sqkon.git
POM_SCM_DEV_CONNECTION=scm:git:ssh://[email protected]/MercuryTechnologies/sqkon.git
POM_DEVELOPER_NAME=MercuryTechnologies
POM_DEVELOPER_URL=https://github.com/MercuryTechnologies/

#Kotlin
kotlin.code.style=official
kotlin.daemon.jvmargs=-Xmx4G
Expand Down
2 changes: 1 addition & 1 deletion gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ sqlDelight-driver-js = { module = "app.cash.sqldelight:web-worker-driver", versi

[plugins]
android-library = { id = "com.android.library", version.ref = "agp" }
axion-release = { id = "pl.allegro.tech.build.axion-release", version = "1.18.12" }
maven-publish = { id = "com.vanniktech.maven.publish", version = "0.30.0" }
multiplatform = { id = "org.jetbrains.kotlin.multiplatform", version.ref = "kotlin" }
kotlinx-serialization = { id = "org.jetbrains.kotlin.plugin.serialization", version.ref = "kotlin" }
sqlDelight = { id = "app.cash.sqldelight", version.ref = "sqlDelight" }
3 changes: 1 addition & 2 deletions library/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,9 @@ plugins {
alias(libs.plugins.android.library)
alias(libs.plugins.kotlinx.serialization)
alias(libs.plugins.sqlDelight)
alias(libs.plugins.maven.publish)
}

group = "com.mercury.sqkon"

kotlin {
applyDefaultHierarchyTemplate()
jvmToolchain(11)
Expand Down
3 changes: 3 additions & 0 deletions library/gradle.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
POM_ARTIFACT_ID=library
POM_NAME=Library
POM_DESCRIPTION=Core library for Sqkon, includes runtime and code used to make sqkon work.

0 comments on commit 17242c7

Please sign in to comment.