Skip to content

Commit

Permalink
Update publishing workflows (#52)
Browse files Browse the repository at this point in the history
- Update publish plugin
- Combine test workflows
- Add new workflow that triggers when a tag is pushed to deploy a release version and the docs website
  • Loading branch information
ajalt authored Feb 28, 2024
1 parent f478a47 commit a390682
Show file tree
Hide file tree
Showing 11 changed files with 148 additions and 196 deletions.
87 changes: 87 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
name: Build

on:
pull_request:
paths-ignore:
- 'docs/**'
- 'samples/**'
- '*.md'
push:
branches:
- 'master'
paths-ignore:
- 'docs/**'
- 'samples/**'
- '*.md'
jobs:
test:
strategy:
matrix:
os: [macos-14, windows-latest, ubuntu-latest]
include:
- os: ubuntu-latest
GRADLE_ARGS: |
:test:check
:colormath:compileKotlinLinuxArm64
:colormath:compileKotlinWasmJs
:extensions:colormath-ext-jetpack-compose:check
:extensions:colormath-ext-android-colorint:check
:extensions:colormath-ext-android-color:check
--stacktrace
- os: macos-14
GRADLE_ARGS: |
macosX64Test
:colormath:compileKotlinMacosArm64
iosX64Test
tvosX64Test
iosSimulatorArm64Test
tvosSimulatorArm64Test
watchosSimulatorArm64Test
--stacktrace
- os: windows-latest
GRADLE_ARGS: mingwX64Test --stacktrace
runs-on: ${{matrix.os}}
steps:
- uses: actions/checkout@v4
- uses: graalvm/setup-graalvm@v1
with:
java-version: 17
distribution: 'graalvm-community'
set-java-home: false
- uses: actions/setup-java@v4
with:
distribution: 'zulu'
java-version: 21
- uses: gradle/actions/setup-gradle@v3
with:
arguments: ${{matrix.GRADLE_ARGS}}
- name: Bundle the build report
if: failure()
run: find . -type d -name 'reports' | zip -@ -r build-reports.zip
- name: Upload the build report
if: failure()
uses: actions/upload-artifact@master
with:
name: error-report
path: build-reports.zip
publish:
needs: test
runs-on: macos-14
if: ${{ github.ref == 'refs/heads/master' && github.repository == 'ajalt/colormath' }}
steps:
- uses: actions/checkout@v4
- uses: actions/setup-java@v4
with:
distribution: 'zulu'
java-version: 21
- name: Deploy to sonatype
uses: gradle/actions/setup-gradle@v3
with:
# disable configuration cache due to https://github.com/gradle/gradle/issues/22779
arguments: publishToMavenCentral -PsnapshotVersion=true --no-configuration-cache
env:
ORG_GRADLE_PROJECT_mavenCentralPassword: ${{ secrets.ORG_GRADLE_PROJECT_mavenCentralPassword }}
ORG_GRADLE_PROJECT_signingInMemoryKey: ${{ secrets.ORG_GRADLE_PROJECT_signingInMemoryKey }}
ORG_GRADLE_PROJECT_mavenCentralUsername: ${{ secrets.ORG_GRADLE_PROJECT_mavenCentralUsername }}
env:
GRADLE_OPTS: -Dorg.gradle.configureondemand=true -Dorg.gradle.parallel=false -Dkotlin.incremental=false -Dorg.gradle.project.kotlin.incremental.multiplatform=false -Dorg.gradle.project.kotlin.native.disableCompilerDaemon=true -Dorg.gradle.jvmargs="-Dfile.encoding=UTF-8"
101 changes: 0 additions & 101 deletions .github/workflows/publish.yml

This file was deleted.

44 changes: 44 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
name: release

on:
push:
tags:
- '**'

jobs:
release:
runs-on: macos-14
steps:
- uses: actions/checkout@v4
- uses: actions/setup-java@v4
with:
distribution: 'zulu'
java-version: 21
- uses: actions/setup-python@v5
with:
python-version: '3.12'
- run: ./gradlew publishToMavenCentral
env:
ORG_GRADLE_PROJECT_mavenCentralPassword: ${{ secrets.ORG_GRADLE_PROJECT_mavenCentralPassword }}
ORG_GRADLE_PROJECT_signingInMemoryKey: ${{ secrets.ORG_GRADLE_PROJECT_signingInMemoryKey }}
ORG_GRADLE_PROJECT_mavenCentralUsername: ${{ secrets.ORG_GRADLE_PROJECT_mavenCentralUsername }}
- name: Extract release notes
id: extract-release-notes
uses: ffurrer2/extract-release-notes@v2
- name: Create release
uses: ncipollo/release-action@v1
with:
body: ${{ steps.extract-release-notes.outputs.release_notes }}
- name: Dokka
uses: gradle/actions/setup-gradle@v3
with:
arguments: dokkaHtml jsBrowserDistribution
- name: Build mkdocs
run: |
pip install mkdocs-material
mkdocs build
- name: Deploy docs to website
uses: JamesIves/github-pages-deploy-action@v4
with:
branch: gh-pages
folder: site
71 changes: 0 additions & 71 deletions .github/workflows/test.yml

This file was deleted.

1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,4 @@ docs/index.md
site/
docs/js/gradient.js
docs/js/converter.js
kotlin-js-store/
17 changes: 8 additions & 9 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
import com.android.build.gradle.BaseExtension
import com.vanniktech.maven.publish.JavadocJar
import com.vanniktech.maven.publish.KotlinMultiplatform
import com.vanniktech.maven.publish.MavenPublishBaseExtension
import org.jetbrains.dokka.gradle.DokkaTask
import org.jetbrains.kotlin.gradle.dsl.JvmTarget
import org.jetbrains.kotlin.gradle.tasks.KotlinJvmCompile
Expand All @@ -17,15 +20,7 @@ fun getPublishVersion(): String {

// Call gradle with -PinferVersion to set the dynamic version name.
// Otherwise, we skip it to save time.
if (!project.hasProperty("inferVersion")) return versionName

val stdout = ByteArrayOutputStream()
project.exec {
commandLine = listOf("git", "tag", "--points-at", "master")
standardOutput = stdout
}
val tag = String(stdout.toByteArray()).trim()
if (tag.isNotEmpty()) return tag
if (!project.hasProperty("snapshotVersion")) return versionName

val buildNumber = System.getenv("GITHUB_RUN_NUMBER") ?: "0"
return "$versionName.$buildNumber-SNAPSHOT"
Expand Down Expand Up @@ -55,6 +50,10 @@ subprojects {

pluginManager.withPlugin("com.vanniktech.maven.publish") {
apply(plugin = "org.jetbrains.dokka")
extensions.configure<MavenPublishBaseExtension>("mavenPublishing") {
@Suppress("UnstableApiUsage")
configure(KotlinMultiplatform(JavadocJar.Empty()))
}
tasks.named<DokkaTask>("dokkaHtml") {
val dir = if (project.name == "colormath") "" else "/${project.name}"
outputDirectory.set(rootProject.rootDir.resolve("docs/api$dir"))
Expand Down
2 changes: 1 addition & 1 deletion extensions/colormath-ext-android-color/gradle.properties
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
POM_ARTIFACT_ID=colormath-ext-android-color
POM_NAME=Andoird Color Extensions for Colormath
POM_NAME=Android Color Extensions for Colormath
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
POM_ARTIFACT_ID=colormath-ext-android-colorint
POM_NAME=Andoird ColorInt Extensions for Colormath
POM_NAME=Android ColorInt Extensions for Colormath
2 changes: 1 addition & 1 deletion gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ robolectric = "org.robolectric:robolectric:4.10"

[plugins]
dokka = "org.jetbrains.dokka:1.9.10"
publish = "com.vanniktech.maven.publish:0.25.3"
publish = "com.vanniktech.maven.publish:0.27.0"
# used in extensions
android-library = "com.android.library:7.4.0"

Expand Down
14 changes: 5 additions & 9 deletions deploy_website.sh → prepare_docs.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,13 @@
# It requires Python to run.
# Install the packages with the following command:
# pip install mkdocs mkdocs-material
# Build the samples and api docs with
# ./gradlew dokkaHtml jsBrowserDistribution
# Then run this script to prepare the docs for the website.
# Finally, run `mkdocs serve` to preview the site locally or `mkdocs build` to build the site.

set -ex

# Generate API docs and picker js
./gradlew dokkaHtml jsBrowserDistribution
set -ex

# Copy the changelog into the site, omitting the unreleased section
cat CHANGELOG.md \
Expand Down Expand Up @@ -38,9 +40,3 @@ cat README.md \
mkdir -p docs/js
cp website/converter/build/dist/js/productionExecutable/converter.js docs/js/converter.js
cp website/gradient/build/dist/js/productionExecutable/gradient.js docs/js/gradient.js

# Build and deploy the new site to github pages
mkdocs gh-deploy

# Remove the file copies
rm docs/index.md docs/changelog.md
Loading

0 comments on commit a390682

Please sign in to comment.