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

Update GitHub actions #66

Draft
wants to merge 7 commits into
base: main
Choose a base branch
from
Draft
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
42 changes: 17 additions & 25 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,36 +1,28 @@
# This is a basic workflow to help you get started with Actions

name: CI

# Controls when the action will run. Triggers the workflow on push or pull request
# events but only for the master branch
on:
push:
branches: [ main ]
pull_request:
branches: [ main ]
workflow_call:

# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
# This workflow contains a single job called "build"
build:
# The type of runner that the job will run on
runs-on: ubuntu-latest
concurrency:
group: "CI: ${{ github.workflow }} @ ${{ github.event.pull_request.head.label || github.head_ref || github.ref }}"
cancel-in-progress: true

# Steps represent a sequence of tasks that will be executed as part of the job
steps:
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- uses: actions/checkout@v3

- name: Setup Java JDK
uses: actions/setup-java@v3
with:
distribution: temurin
java-version: 8

- name: Assemble
run: ./gradlew assemble
jobs:

- name: Check
run: ./gradlew check
build:
strategy:
matrix:
include:
- os: macos-latest
- os: ubuntu-latest
- os: windows-latest
fail-fast: false
uses: ./.github/workflows/run_gradle.yml
with:
runs-on: ${{ matrix.os }}
ref: ${{ inputs.ref }}
task: check
47 changes: 19 additions & 28 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
@@ -1,39 +1,30 @@

name: Deploy to central

on: workflow_dispatch
on:
workflow_dispatch:
inputs:
checkout-ref:
description: "The branch, tag or SHA to checkout. See actions/checkout 'ref'."
required: false
type: string

permissions:
contents: read

concurrency:
group: "Deploy: ${{ github.workflow }} @ ${{ github.event.pull_request.head.label || github.head_ref || github.ref }}"
cancel-in-progress: false

jobs:

build:
uses: ./.github/workflows/ci.yml

deploy:
runs-on: ubuntu-latest
needs: build
steps:
- uses: actions/checkout@v3

- name: Setup Java JDK
uses: actions/setup-java@v3
with:
distribution: temurin
java-version: 8

- name: Import GPG key
uses: crazy-max/ghaction-import-gpg@v5
with:
gpg_private_key: ${{ secrets.GPG_PRIVATE_KEY }}
passphrase: ${{ secrets.GPG_PRIVATE_PASSWORD }}

- name: Gradle publish
uses: gradle/gradle-build-action@ce999babab2de1c4b649dc15f0ee67e6246c994f
with:
arguments: |
publish
closeSonatypeStagingRepository
-Psigning.gnupg.passphrase='${{secrets.GPG_PRIVATE_PASSWORD}}'
-Psigning.gnupg.keyName='${{secrets.GPG_PRIVATE_KEY_ID}}'
-PsonatypeUsername='${{secrets.SONATYPE_USERNAME}}'
-PsonatypePassword='${{secrets.SONATYPE_PASSWORD}}'
uses: ./.github/workflows/run_gradle.yml
with:
runs-on: macos-latest
ref: ${{ inputs.checkout-ref || github.ref }}
task: publish closeSonatypeStagingRepository
gpgKeyImport: true
98 changes: 98 additions & 0 deletions .github/workflows/run_gradle.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
# A re-usable workflow for running a Gradle task.
# Should not be called directly, instead use it in other workflows.

name: Gradle Task
run-name: "Gradle Task ${{ inputs.task }}, ${{ inputs.runs-on }}, ${{ inputs.ref }}"

on:
workflow_call:
inputs:
runs-on:
description: "The platform to run tests on"
required: true
type: string
ref:
description: "The git branch, tag or SHA to checkout"
required: false
type: string
task:
description: "The Gradle task to run"
required: true
type: string
gpgKeyImport:
default: false
type: boolean

permissions:
contents: read

jobs:
run-tests:
runs-on: ${{ inputs.runs-on }}
name: "gradle ${{ inputs.gradle-task}}"
steps:
- name: "Redirect caches to fast D: drive for Windows runners"
if: runner.os == 'Windows'
shell: cmd
run: |
mkdir D:\.konan
mklink /D C:\Users\runneradmin\.konan D:\.konan
echo KONAN_DATA_DIR=D:\.konan>>%GITHUB_ENV%

- name: "Set KONAN_DATA_DIR (bash)"
if: runner.os != 'Windows'
shell: bash
run: echo "KONAN_DATA_DIR=${HOME}/.konan" >> $GITHUB_ENV

- name: Checkout the repo
uses: actions/checkout@v4
with:
ref: ${{ github.event.inputs.ref }}

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

- name: Setup Gradle
uses: gradle/actions/setup-gradle@v4
with:
cache-cleanup: always
cache-encryption-key: ${{ secrets.GRADLE_CONFIGURATION_CACHE_ENCRYPTION_KEY }}

- name: Cache Kotlin Konan
uses: actions/cache@v4
with:
path: ${{ env.KONAN_DATA_DIR }}
key: kotlin-konan-${{ runner.os }}
enableCrossOsArchive: true
restore-keys: |
kotlin-konan-

- name: Import GPG key
uses: crazy-max/ghaction-import-gpg@v6
if: inputs.gpgKeyImport
with:
gpg_private_key: ${{ secrets.GPG_PRIVATE_KEY }}
passphrase: ${{ secrets.GPG_PRIVATE_PASSWORD }}

- name: Run task ${{ inputs.task }}
shell: bash
run: ./gradlew ${{ inputs.task }} --scan --stacktrace
env:
"ORG_GRADLE_PROJECT_signing.gnupg.passphrase": ${{ secrets.GPG_PRIVATE_PASSWORD }}
"ORG_GRADLE_PROJECT_signing.gnupg.keyName": ${{ secrets.GPG_PRIVATE_KEY_ID }}
ORG_GRADLE_PROJECT_sonatypeUsername: ${{ secrets.SONATYPE_USERNAME }}
ORG_GRADLE_PROJECT_sonatypePassword: ${{ secrets.SONATYPE_PASSWORD }}

- name: Upload build reports
if: failure()
uses: actions/upload-artifact@v4
with:
name: build-reports-${{ runner.os }}-${{ github.action }}-${{ github.run_id }}
path: |
**/build/reports/
**/*.hprof
**/*.log
if-no-files-found: ignore
5 changes: 2 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
.gradle
gradle.properties
.gradle/
build/
.idea
out
out/
19 changes: 17 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,17 @@ dependencies {
}
```

Similarly in Maven:
Similarly, in Maven:

> [!IMPORTANT]
> Maven must add a `-jvm` suffix to the `kotlin-xml-builder` dependency.\
> A suffix is not required for Gradle.

```xml
<dependencies>
<dependency>
<groupId>org.redundent</groupId>
<artifactId>kotlin-xml-builder</artifactId>
<artifactId>kotlin-xml-builder-jvm</artifactId>
<version>[VERSION]</version>
</dependency>
</dependencies>
Expand Down Expand Up @@ -276,6 +281,16 @@ It includes many more features for consuming documents.

Release Notes
=============
Version 2.0.0
-
* `kotlin-xml-builder` has been updated to support Kotlin Multiplatform.

**BREAKING CHANGES**
* Maven users must add a `-jvm` suffix to the artifact ID to select the JVM variant.\
Old: `<artifactId>kotlin-xml-builder</artifactId>`\
New: `<artifactId>kotlin-xml-builder-jvm</artifactId>`.\
No change is necessary for Gradle users.

Version 1.9.1
-
* Adding `addElement`, `addElements`, `addElementsBefore`, `addElementsAfter`, `removeElement`,
Expand Down
58 changes: 1 addition & 57 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,67 +1,11 @@
plugins {
kotlin("jvm") version "1.6.20" apply false
id("com.bmuschko.nexus") version "2.3.1" apply false
id("io.github.gradle-nexus.publish-plugin") version "2.0.0-rc-1"
id("org.jlleitschuh.gradle.ktlint") version "11.6.1"
}

extra["kotlinVersion"] = "1.6.20"

allprojects {
group = "org.redundent"
version = "1.9.1"

repositories {
mavenCentral()
}
//id("org.jlleitschuh.gradle.ktlint") version "11.6.1"
}

nexusPublishing {
repositories {
sonatype()
}
}

subprojects {
afterEvaluate {
configure<PublishingExtension> {
publications.withType<MavenPublication> {
artifact(
tasks.register("${name}JavadocJar", Jar::class) {
archiveClassifier.set("javadoc")
archiveAppendix.set([email protected])
}
)

pom {
name.set("Kotlin XML Builder")
description.set("A lightweight type safe builder to build xml documents in Kotlin")
url.set("https://github.com/redundent/kotlin-xml-builder")

licenses {
license {
name.set("Apache 2.0")
url.set("https://www.apache.org/licenses/LICENSE-2.0")
}
}
developers {
developer {
id.set("redundent")
name.set("Jason Blackwell")
}
}
scm {
url.set("https://github.com/redundent/kotlin-xml-builder")
}
}
}
}

configure<SigningExtension> {
if (project.hasProperty("signing.gnupg.keyName")) {
useGpgCmd()
sign(extensions.getByType(PublishingExtension::class).publications)
}
}
}
}
7 changes: 7 additions & 0 deletions buildSrc/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
plugins {
`kotlin-dsl`
}

dependencies {
implementation("org.jetbrains.kotlin:kotlin-gradle-plugin:1.9.23")
}
16 changes: 16 additions & 0 deletions buildSrc/settings.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
rootProject.name = "buildSrc"

pluginManagement {
repositories {
mavenCentral()
gradlePluginPortal()
}
}

@Suppress("UnstableApiUsage")
dependencyResolutionManagement {
repositories {
mavenCentral()
gradlePluginPortal()
}
}
11 changes: 11 additions & 0 deletions buildSrc/src/main/kotlin/conventions/base.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package conventions

plugins {
base
}

tasks.withType<AbstractArchiveTask>().configureEach {
// https://docs.gradle.org/current/userguide/working_with_files.html#sec:reproducible_archives
isPreserveFileTimestamps = false
isReproducibleFileOrder = true
}
24 changes: 24 additions & 0 deletions buildSrc/src/main/kotlin/conventions/kotlin-jvm.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package conventions

import org.jetbrains.kotlin.gradle.dsl.KotlinVersion

plugins {
id("conventions.base")
kotlin("jvm")
}

kotlin {
jvmToolchain(8)

compilerOptions {
languageVersion = KotlinVersion.KOTLIN_1_6
}
}

java {
withSourcesJar()
}

tasks.withType<Test>().configureEach {
useJUnitPlatform()
}
Loading
Loading