From a390682fa5df40301bd8195d38640e6e3876183b Mon Sep 17 00:00:00 2001 From: AJ Alt Date: Wed, 28 Feb 2024 20:54:47 +0000 Subject: [PATCH] Update publishing workflows (#52) - 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 --- .github/workflows/build.yml | 87 +++++++++++++++ .github/workflows/publish.yml | 101 ------------------ .github/workflows/release.yml | 44 ++++++++ .github/workflows/test.yml | 71 ------------ .gitignore | 1 + build.gradle.kts | 17 ++- .../gradle.properties | 2 +- .../gradle.properties | 2 +- gradle/libs.versions.toml | 2 +- deploy_website.sh => prepare_docs.sh | 14 +-- test/build.gradle.kts | 3 - 11 files changed, 148 insertions(+), 196 deletions(-) create mode 100644 .github/workflows/build.yml delete mode 100644 .github/workflows/publish.yml create mode 100755 .github/workflows/release.yml delete mode 100644 .github/workflows/test.yml rename deploy_website.sh => prepare_docs.sh (81%) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 00000000..ccd0f426 --- /dev/null +++ b/.github/workflows/build.yml @@ -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" diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml deleted file mode 100644 index f94f6244..00000000 --- a/.github/workflows/publish.yml +++ /dev/null @@ -1,101 +0,0 @@ -name: Publish - -on: - push: - paths-ignore: - - 'docs/**' - - '*.md' - branches: - - master - -jobs: - linux-tests: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - - uses: actions/setup-java@v3 - with: - distribution: 'zulu' - java-version: 21 - - uses: gradle/gradle-build-action@v2 - with: - arguments: | - :test:jsNodeTest - :test:jvmTest - :test:linuxX64Test - :colormath:compileKotlinLinuxArm64 - :colormath:compileKotlinWasmJs - :extensions:colormath-ext-jetpack-compose:check - :extensions:colormath-ext-android-colorint:check - :extensions:colormath-ext-android-color:check - --stacktrace - - 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 - macos-tests: - runs-on: macos-latest - steps: - - uses: actions/checkout@v4 - - uses: actions/setup-java@v3 - with: - distribution: 'zulu' - java-version: 21 - - uses: gradle/gradle-build-action@v2 - with: - arguments: | - macosX64Test - :colormath:compileKotlinMacosArm64 - iosX64Test - tvosX64Test - iosSimulatorArm64Test - tvosSimulatorArm64Test - watchosSimulatorArm64Test - --stacktrace - windows-tests: - runs-on: windows-latest - steps: - - uses: actions/checkout@v4 - - uses: actions/setup-java@v3 - with: - distribution: 'zulu' - java-version: 21 - - uses: gradle/gradle-build-action@v2 - with: - arguments: mingwX64Test --stacktrace - - deploy: - needs: [ linux-tests, macos-tests, windows-tests ] - runs-on: macos-latest - steps: - - uses: actions/checkout@v4 - - uses: actions/setup-java@v3 - with: - distribution: 'zulu' - java-version: 21 - - name: Fetch git tags - run: git fetch origin +refs/tags/*:refs/tags/* - - name: Deploy to sonatype - uses: gradle/gradle-build-action@v2 - with: - arguments: | - :colormath:assemble - :extensions:colormath-ext-android-color:assemble - :extensions:colormath-ext-android-colorint:assemble - :extensions:colormath-ext-jetpack-compose:assemble - :colormath:publish - :extensions:colormath-ext-android-color:publish - :extensions:colormath-ext-android-colorint:publish - :extensions:colormath-ext-jetpack-compose:publish - -PinferVersion=true - -env: - GRADLE_OPTS: -Dorg.gradle.configureondemand=true -Dorg.gradle.parallel=true -Dkotlin.incremental=false -Dorg.gradle.project.kotlin.incremental.multiplatform=false -Dorg.gradle.project.kotlin.native.disableCompilerDaemon=true -Dorg.gradle.jvmargs="-Xmx5g -Dfile.encoding=UTF-8" - 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 }} diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100755 index 00000000..bff44101 --- /dev/null +++ b/.github/workflows/release.yml @@ -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 diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml deleted file mode 100644 index 07261bcc..00000000 --- a/.github/workflows/test.yml +++ /dev/null @@ -1,71 +0,0 @@ -name: Test - -on: - pull_request: - paths-ignore: - - 'docs/**' - - '*.md' - -jobs: - linux-tests: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - - uses: actions/setup-java@v3 - with: - distribution: 'zulu' - java-version: 21 - - uses: gradle/gradle-build-action@v2 - with: - arguments: | - :test:jsNodeTest - :test:jvmTest - :test:linuxX64Test - :colormath:compileKotlinLinuxArm64 - :colormath:compileKotlinWasmJs - :extensions:colormath-ext-jetpack-compose:check - :extensions:colormath-ext-android-colorint:check - :extensions:colormath-ext-android-color:check - --stacktrace - - 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 - macos-tests: - runs-on: macos-latest - steps: - - uses: actions/checkout@v4 - - uses: actions/setup-java@v3 - with: - distribution: 'zulu' - java-version: 21 - - uses: gradle/gradle-build-action@v2 - with: - arguments: | - macosX64Test - :colormath:compileKotlinMacosArm64 - iosX64Test - tvosX64Test - iosSimulatorArm64Test - tvosSimulatorArm64Test - watchosSimulatorArm64Test - --stacktrace - windows-tests: - runs-on: windows-latest - steps: - - uses: actions/checkout@v4 - - uses: actions/setup-java@v3 - with: - distribution: 'zulu' - java-version: 21 - - uses: gradle/gradle-build-action@v2 - with: - arguments: mingwX64Test --stacktrace - -env: - GRADLE_OPTS: -Dorg.gradle.configureondemand=true -Dorg.gradle.parallel=true -Dkotlin.incremental=false -Dorg.gradle.project.kotlin.incremental.multiplatform=false -Dorg.gradle.project.kotlin.native.disableCompilerDaemon=true -Dorg.gradle.jvmargs="-Xmx5g -Dfile.encoding=UTF-8" diff --git a/.gitignore b/.gitignore index 799534ae..5294f07f 100644 --- a/.gitignore +++ b/.gitignore @@ -13,3 +13,4 @@ docs/index.md site/ docs/js/gradient.js docs/js/converter.js +kotlin-js-store/ diff --git a/build.gradle.kts b/build.gradle.kts index 4ab9f974..e53ab95b 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -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 @@ -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" @@ -55,6 +50,10 @@ subprojects { pluginManager.withPlugin("com.vanniktech.maven.publish") { apply(plugin = "org.jetbrains.dokka") + extensions.configure("mavenPublishing") { + @Suppress("UnstableApiUsage") + configure(KotlinMultiplatform(JavadocJar.Empty())) + } tasks.named("dokkaHtml") { val dir = if (project.name == "colormath") "" else "/${project.name}" outputDirectory.set(rootProject.rootDir.resolve("docs/api$dir")) diff --git a/extensions/colormath-ext-android-color/gradle.properties b/extensions/colormath-ext-android-color/gradle.properties index 1c7d534a..75a9d8e0 100644 --- a/extensions/colormath-ext-android-color/gradle.properties +++ b/extensions/colormath-ext-android-color/gradle.properties @@ -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 diff --git a/extensions/colormath-ext-android-colorint/gradle.properties b/extensions/colormath-ext-android-colorint/gradle.properties index 67f6de62..bb0bd591 100644 --- a/extensions/colormath-ext-android-colorint/gradle.properties +++ b/extensions/colormath-ext-android-colorint/gradle.properties @@ -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 diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 14438d44..f24b87e2 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -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" diff --git a/deploy_website.sh b/prepare_docs.sh similarity index 81% rename from deploy_website.sh rename to prepare_docs.sh index 0bda8a26..5de82f89 100755 --- a/deploy_website.sh +++ b/prepare_docs.sh @@ -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 \ @@ -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 diff --git a/test/build.gradle.kts b/test/build.gradle.kts index f34d94ed..6df04b13 100644 --- a/test/build.gradle.kts +++ b/test/build.gradle.kts @@ -1,8 +1,5 @@ -import org.jetbrains.kotlin.gradle.targets.js.dsl.ExperimentalWasmDsl - plugins { kotlin("multiplatform") - alias(libs.plugins.publish) } repositories {