Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add publish module #7

Merged
merged 1 commit into from
Mar 16, 2024
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
14 changes: 14 additions & 0 deletions .github/workflows/Build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,13 @@ jobs:
cache-encryption-key: ${{ secrets.GradleEncryptionKey }}
dependency-graph: generate

- name: Restore Kotlin Native Cache
uses: actions/cache/restore@v4
with:
path: ~/.konan
key: ${{ runner.os }}-konan-${{ hashFiles('**/*.gradle.kts', 'buildSrc') }}
restore-keys: ${{ runner.os }}-konan-

- name: Assemble debug build, run tests
run: >
./gradlew -Pkotlin.daemon.jvmargs="${{ env.KOTLIN_DAEMON_JVMARGS }}"
Expand Down Expand Up @@ -95,6 +102,13 @@ jobs:
name: test-reports
path: test-reports.tar.zst

- name: Save Kotlin Native Cache
uses: actions/cache/save@v4
if: github.ref_name == 'main'
with:
path: ~/.konan
key: ${{ runner.os }}-konan-${{ hashFiles('**/*.gradle.kts', 'buildSrc') }}

static-analysis:
name: Style check
runs-on: ubuntu-latest
Expand Down
62 changes: 62 additions & 0 deletions .github/workflows/Publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
name: publish

on:
workflow_dispatch:

env:
CI: true
TERM: dumb
GRADLE_OPTS: >-
-Dorg.gradle.jvmargs="-Xmx3G -XX:MaxMetaspaceSize=1g -XX:SoftRefLRUPolicyMSPerMB=10 -XX:+UseParallelGC -XX:NewRatio=1"
-Dorg.gradle.dependency.verification.console=verbose
KOTLIN_DAEMON_JVMARGS: >-
-Xmx2G -XX:MaxMetaspaceSize=320M -XX:SoftRefLRUPolicyMSPerMB=10 -XX:+UseParallelGC -XX:NewRatio=1

jobs:
publish:
name: Assemble, publish to Sonatype
runs-on: macos-latest
timeout-minutes: 60

steps:
- name: Checkout sources
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Setup Java
uses: actions/setup-java@v4
with:
distribution: 'temurin'
java-version: '21'

- name: Setup Gradle
uses: gradle/actions/setup-gradle@v3
with:
cache-encryption-key: ${{ secrets.GradleEncryptionKey }}
dependency-graph: generate

- name: Restore Kotlin Native Cache
uses: actions/cache/restore@v4
with:
path: ~/.konan
key: ${{ runner.os }}-konan-${{ hashFiles('**/*.gradle.kts', 'buildSrc') }}
restore-keys: ${{ runner.os }}-konan-

- name: Assemble, run tests, publish
env:
YANDEX_S3_ACCESS_KEY_ID: ${{ secrets.YANDEX_S3_ACCESS_KEY_ID }}
YANDEX_S3_SECRET_ACCESS_KEY: ${{ secrets.YANDEX_S3_SECRET_ACCESS_KEY }}
ORG_GRADLE_PROJECT_signingInMemoryKey: ${{ secrets.SIGNING_IN_MEMORY_KEY }}
ORG_GRADLE_PROJECT_signingInMemoryKeyId: FCF62075
ORG_GRADLE_PROJECT_signingInMemoryKeyPassword: ${{ secrets.SIGNING_IN_MEMORY_KEY_PASSWORD }}
run: >
./gradlew --scan -Pkotlin.daemon.jvmargs="${{ env.KOTLIN_DAEMON_JVMARGS }}"
build publishAllPublicationsToPixnewsS3Repository --stacktrace

- name: Upload build artifacts
uses: actions/upload-artifact@v4
if: ${{ failure() }}
with:
name: build-outputs
path: '**/build/outputs'
22 changes: 12 additions & 10 deletions RELEASING.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
# Releasing

1. Change the version in `core/build.gradle.kts` to a non-SNAPSHOT version.
2. Update the `CHANGELOG.md` for the impending release.
3. Update the `README.md` with the new version.
4. `git commit -am "Prepare for release X.Y.Z."` (where X.Y.Z is the new version)
5. `git tag -a X.Y.Z -m "Version X.Y.Z"` (where X.Y.Z is the new version)
6. `. /gradlew clean build publishAllPublicationsToPixnewsRepository`
Or `git push` and trigger publish workflow in GitHub Actions
7. Update the `core/build.gradle.kts` to the next SNAPSHOT version.
8. `git commit -am "Prepare next development version."`
9. `git push && git push --tags`
1. Create a local release branch from main: `git checkout -b vX.Y.Z`
2. Change the version in `config/version.properties` to a non-SNAPSHOT version.
3. Update the `CHANGELOG.md` for the impending release.
4. Update the `README.md` with the new version.
5. `git commit -am "Prepare for release X.Y.Z."` (where X.Y.Z is the new version)
6. `git tag -a X.Y.Z -m "Version X.Y.Z"` (where X.Y.Z is the new version)
7. `git push origin`, open pull-request
8. Merge pull-request and trigger publish workflow in GitHub Actions
9. `git checkout main && git pull origin`
10. Update the `config/version.properties` to the next SNAPSHOT version.
11. `git commit -am "Prepare next development version."`
12. `git push && git push --tags`
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import com.vanniktech.maven.publish.JavadocJar
import com.vanniktech.maven.publish.KotlinMultiplatform
import org.jetbrains.dokka.gradle.DokkaTask
import ru.pixnews.sqlite.open.helper.gradle.publish.createWasmSqliteVersionsExtension

/*
* Convention plugin with publishing defaults
Expand All @@ -17,6 +18,8 @@ plugins {
id("org.jetbrains.dokka")
}

createWasmSqliteVersionsExtension()

tasks.withType<AbstractArchiveTask>().configureEach {
isPreserveFileTimestamps = false
isReproducibleFileOrder = true
Expand All @@ -43,7 +46,7 @@ mavenPublishing {
signAllPublications()

configure(
KotlinMultiplatform(javadocJar = JavadocJar.Dokka("dokkaHtml")),
KotlinMultiplatform(javadocJar = JavadocJar.Dokka("dokkaGfm")),
)

pom {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
/*
* Copyright 2024, the wasm-sqlite-open-helper project authors and contributors. Please see the AUTHORS file
* for details. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
* SPDX-License-Identifier: Apache-2.0
*/

package ru.pixnews.sqlite.open.helper.gradle.publish

import org.gradle.api.Project
import org.gradle.api.file.RegularFile
import org.gradle.api.file.RegularFileProperty
import org.gradle.api.provider.Provider
import org.gradle.api.provider.ProviderFactory
import org.gradle.api.provider.ValueSource
import org.gradle.api.provider.ValueSourceParameters
import org.gradle.kotlin.dsl.create
import ru.pixnews.sqlite.open.helper.gradle.publish.PropertiesValueSource.Parameters
import java.util.Properties
import javax.inject.Inject

private const val VERSION_PROPERTIES_PATH = "config/version.properties"

internal fun Project.createWasmSqliteVersionsExtension(): WasmSqliteVersionsExtension {
val configFilePath: RegularFile = project.rootProject.layout.projectDirectory.file(VERSION_PROPERTIES_PATH)
return extensions.create<WasmSqliteVersionsExtension>("wasmSqliteVersions", configFilePath)
}

open class WasmSqliteVersionsExtension @Inject constructor(
private val providers: ProviderFactory,
private val propertiesFile: RegularFile,
) {
private val propertiesProvider: Provider<Map<String, String>> = providers.of(PropertiesValueSource::class.java) {
parameters.configFilePath.set(propertiesFile)
}.orElse(providers.provider { error("File $propertiesFile not found") })
private val rootVersion: Provider<String> = providers.gradleProperty("version")
.orElse(providers.environmentVariable("WSOH_VERSION"))
.orElse(
propertiesProvider.map { props ->
props["wsoh_version"]
?: error("No `wsoh_version` in $propertiesFile")
},
)

fun getSubmoduleVersionProvider(
propertiesFileKey: String,
envVariableName: String,
gradleKey: String = propertiesFileKey,
): Provider<String> = providers.gradleProperty(gradleKey)
.orElse(providers.environmentVariable(envVariableName))
.orElse(
propertiesProvider.map { props ->
props[propertiesFileKey] ?: rootVersion.get()
},
)
}

private abstract class PropertiesValueSource : ValueSource<Map<String, String>, Parameters> {
override fun obtain(): Map<String, String> {
val propsFile = parameters.configFilePath.get().asFile
val props = Properties().apply {
propsFile.bufferedReader().use { load(it) }
}
return props.map { it.key.toString() to it.value.toString() }.toMap()
}

interface Parameters : ValueSourceParameters {
val configFilePath: RegularFileProperty
}
}
10 changes: 6 additions & 4 deletions common-api/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,14 @@

plugins {
id("ru.pixnews.sqlite.open.helper.gradle.multiplatform.kotlin")
id("ru.pixnews.sqlite.open.helper.gradle.multiplatform.publish")
}

group = "ru.pixnews.sqlite.open.helper.common.api"

dependencies {
}
group = "ru.pixnews.sqlite.open.helper"
version = wasmSqliteVersions.getSubmoduleVersionProvider(
propertiesFileKey = "wsoh_common_api_version",
envVariableName = "WSOH_COMMON_API_VERSION",
).get()

kotlin {
jvm()
Expand Down
14 changes: 14 additions & 0 deletions config/version.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#
# Copyright 2024, the wasm-sqlite-open-helper project authors and contributors. Please see the AUTHORS file
# for details. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
# SPDX-License-Identifier: Apache-2.0
#

wsoh_version = 0.1-alpha01-SNAPSHOT

# wsoh_common_api_version = 0.1-alpha01-SNAPSHOT
# wsoh_sqlite_common_api_version = 0.1-alpha01-SNAPSHOT
# wsoh_sqlite_embedder_graalvm_version = 0.1-alpha01-SNAPSHOT
# wsoh_sqlite_main_version = 0.1-alpha01-SNAPSHOT
# wsoh_sqlite_wasm_version = 0.1-alpha01-SNAPSHOT
# wsoh_wasi_emscripten_host_version = 0.1-alpha01-SNAPSHOT
Loading