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

Migrate to Kotlin Multiplatform and kotlinx.serialization #31

Closed
wants to merge 2 commits into from
Closed
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
1 change: 1 addition & 0 deletions .ci-java-version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
20
14 changes: 14 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# noinspection EditorConfigKeyCorrectness
[*.{kt,kts}]
root=true
ij_kotlin_allow_trailing_comma = true
ij_kotlin_allow_trailing_comma_on_call_site = true
ij_kotlin_imports_layout=*,java.**,javax.**,kotlin.**,^
indent_size = 2
indent_style = space
insert_final_newline = true
ktlint_code_style = intellij_idea
ktlint_experimental = enabled
ktlint_standard_class-signature = disabled
ktlint_standard_function-signature = disabled
max_line_length = 120
12 changes: 0 additions & 12 deletions .github/dependabot.yml

This file was deleted.

31 changes: 24 additions & 7 deletions .github/workflows/check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,27 +6,44 @@ on:
branches: [master]

jobs:
check:
danger:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8
- uses: actions/checkout@v4

- uses: actions/setup-java@a18c333f3f14249953dab3e186e5e21bf3390f1d
- name: Danger
uses: docker://ghcr.io/danger/danger-kotlin:1.2.0
with:
args: --failOnErrors --no-publish-check
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

check:
runs-on: macos-latest
steps:
- uses: actions/checkout@3df4ab11eba7bda6032a0b82a6bb43b11571feac # v4

- uses: actions/[email protected]
with:
distribution: 'zulu'
java-version: 17
java-version-file: .ci-java-version

- uses: gradle/wrapper-validation-action@e6e38bacfdf1a337459f332974bb2327a31aaf4b
- uses: gradle/wrapper-validation-action@v1.1.0

- name: Setup Gradle
uses: gradle/gradle-build-action@fd32ae908111fe31afa48827bd1ee909540aa971
uses: gradle/gradle-build-action@v2.8.0
with:
gradle-version: wrapper

- name: Run gradle check
run: ./gradlew check

- uses: codecov/codecov-action@d9f34f8cd5cb3b3eb79b3e4b5dae3a16df499a70
- name: Run ktlint and detekt
run: ./format --no-format && ./gradlew detektAppleMain detektJvmMain detektJsMain detektMetadataMain

- uses: codecov/[email protected]
with:
files: build/reports/test/jacocoTestReport.xml
fail_ci_if_error: true
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
107 changes: 81 additions & 26 deletions .github/workflows/publish_release.yml
Original file line number Diff line number Diff line change
@@ -1,38 +1,39 @@
name: Publish a release

on:
push:
branches:
- release
workflow_dispatch:

env:
VERSION_FILE: gradle.properties
VERSION_EXTRACT_PATTERN: '(?<=VERSION_NAME=).+'
GH_USER_NAME: github.actor
GRADLE_OPTS: -Dorg.gradle.daemon=false -Dkotlin.incremental=false -Dorg.gradle.jvmargs="-Xmx4g -Xms512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8 -XX:MaxMetaspaceSize=1024m"

jobs:
publish_release:
runs-on: ubuntu-latest
publish_artifacts:
runs-on: macos-latest

steps:
- uses: actions/checkout@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8
- uses: actions/checkout@3df4ab11eba7bda6032a0b82a6bb43b11571feac # v4
with:
token: ${{ secrets.PUSH_PAT }}

- name: Generate versions
uses: HardNorth/github-version-generate@996e8c5b6ec9cd3e825caf5502d5176238f1109e
uses: HardNorth/github-version-generate@v.1.3.0
with:
version-source: file
version-file: ${{ env.VERSION_FILE }}
version-file-extraction-pattern: ${{ env.VERSION_EXTRACT_PATTERN }}

- uses: actions/setup-java@a18c333f3f14249953dab3e186e5e21bf3390f1d
- uses: actions/setup-java@v3.12.0
with:
distribution: 'zulu'
java-version: 17
java-version-file: .ci-java-version

- uses: gradle/wrapper-validation-action@e6e38bacfdf1a337459f332974bb2327a31aaf4b
- uses: gradle/wrapper-validation-action@v1.1.0

- name: Setup Gradle
uses: gradle/gradle-build-action@fd32ae908111fe31afa48827bd1ee909540aa971
uses: gradle/gradle-build-action@v2.8.0
with:
gradle-version: wrapper

Expand All @@ -41,24 +42,73 @@ jobs:
ORG_GRADLE_PROJECT_mavenCentralUsername: ${{ secrets.SONATYPE_NEXUS_USERNAME }}
ORG_GRADLE_PROJECT_mavenCentralPassword: ${{ secrets.SONATYPE_NEXUS_PASSWORD }}
ORG_GRADLE_PROJECT_signingInMemoryKey: ${{ secrets.ARTIFACT_SIGNING_PRIVATE_KEY }}
ORG_GRADLE_PROJECT_signingInMemoryKeyPassword: ${{ secrets.ARTIFACT_SIGNING_PRIVATE_KEY_PASSWORD }}
run: ./gradlew publish -PVERSION_NAME=${{ env.RELEASE_VERSION }}
run: ./gradlew publishAllPublicationsToMavenCentralRepository -Pversion=${{ env.RELEASE_VERSION }}

publish_release:
needs: publish_artifacts

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@3df4ab11eba7bda6032a0b82a6bb43b11571feac # v4
with:
token: ${{ secrets.PUSH_PAT }}

- uses: actions/[email protected]
with:
distribution: 'zulu'
java-version-file: .ci-java-version

- uses: gradle/[email protected]

- name: Setup Gradle
uses: gradle/[email protected]
with:
gradle-version: wrapper

- name: Generate versions
uses: HardNorth/[email protected]
with:
version-source: file
version-file: ${{ env.VERSION_FILE }}
version-file-extraction-pattern: ${{ env.VERSION_EXTRACT_PATTERN }}

- name: Create, checkout, and push release branch
run: |
git config user.name eygraber
git config user.email [email protected]
git checkout -b releases/${{ env.RELEASE_VERSION }}
git push origin releases/${{ env.RELEASE_VERSION }}

- name: Import GPG Key
uses: crazy-max/ghaction-import-gpg@82a020f1f7f605c65dd2449b392a52c3fcfef7ef # v6.0.0
with:
gpg_private_key: ${{ secrets.GIT_SIGNING_PRIVATE_KEY }}
passphrase: ${{ secrets.GIT_SIGNING_PRIVATE_KEY_PASSWORD }}
git_user_signingkey: true
git_commit_gpgsign: true
git_tag_gpgsign: true

- name: Store SHA of HEAD commit on ENV
run: echo "GIT_HEAD=$(git rev-parse HEAD)" >> $GITHUB_ENV

- name: Create tag
id: create_tag
uses: actions/github-script@7dff1a87643417cf3b95bb10b29f4c4bc60d8ebd
uses: actions/github-script@v6
with:
github-token: ${{ secrets.PUSH_PAT }}
script: |
const {GIT_HEAD} = process.env
github.rest.git.createRef({
owner: context.repo.owner,
repo: context.repo.repo,
ref: "refs/tags/${{ env.RELEASE_VERSION }}",
sha: context.sha
sha: `${GIT_HEAD}`
})

- name: Build changelog
id: build_changelog
uses: mikepenz/release-changelog-builder-action@000e44613cdb6c340ac98cb1582f99e8d3230058
uses: mikepenz/release-changelog-builder-action@v4
with:
configuration: "changelog_config.json"
toTag: ${{ env.RELEASE_VERSION }}
Expand All @@ -67,23 +117,28 @@ jobs:

- name: Create release
id: create_release
uses: ncipollo/release-action@4c75f0f2e4ae5f3c807cf0904605408e319dcaac
uses: ncipollo/release-action@v1.13.0
with:
body: ${{ steps.build_changelog.outputs.changelog }}
commit: release
name: Release ${{ env.RELEASE_VERSION }}
tag: ${{ env.RELEASE_VERSION }}
token: ${{ secrets.GITHUB_TOKEN }}
token: ${{ secrets.PUSH_PAT }}

- uses: actions/checkout@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8
- uses: actions/checkout@v4
with:
ref: 'master'
ref: ${{ github.event.head_ref }}
token: ${{ secrets.PUSH_PAT }}

- name: Prepare next dev version
id: prepare_next_dev
run: |
sed -i -e 's/${{ env.CURRENT_VERSION }}/${{ env.NEXT_VERSION }}/g' gradle.properties
sed -i -E -e 's/[0-9]+\.[0-9]+\.[0-9]+/${{ env.RELEASE_VERSION }}/g' README.md
git add gradle.properties
git commit -m "Prepare next dev version (${{ env.NEXT_VERSION }})"
git push origin master
sed -i -e 's/${{ env.CURRENT_VERSION }}/${{ env.NEXT_VERSION }}/g' gradle.properties && \
sed -i -E -e 's/uri-kmp(:|\/)[0-9]+\.[0-9]+\.[0-9]+/uri-kmp\1${{ env.RELEASE_VERSION }}/g' README.md

- name: Commit next dev version
id: commit_next_dev
uses: EndBug/add-and-commit@v9
with:
add: "['gradle.properties', 'README.md']"
default_author: github_actions
message: "Prepare next dev version"
19 changes: 12 additions & 7 deletions .github/workflows/publish_snapshot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,20 +7,20 @@ on:

jobs:
publish_snapshot:
runs-on: ubuntu-latest
runs-on: macos-latest

steps:
- uses: actions/checkout@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8
- uses: actions/checkout@3df4ab11eba7bda6032a0b82a6bb43b11571feac # v4

- uses: actions/setup-java@a18c333f3f14249953dab3e186e5e21bf3390f1d
- uses: actions/setup-java@v3.12.0
with:
distribution: 'zulu'
java-version: 17
java-version-file: .ci-java-version

- uses: gradle/wrapper-validation-action@e6e38bacfdf1a337459f332974bb2327a31aaf4b
- uses: gradle/wrapper-validation-action@v1.1.0

- name: Setup Gradle
uses: gradle/gradle-build-action@fd32ae908111fe31afa48827bd1ee909540aa971
uses: gradle/gradle-build-action@v2.8.0
with:
gradle-version: wrapper

Expand All @@ -29,4 +29,9 @@ jobs:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
ORG_GRADLE_PROJECT_mavenCentralUsername: ${{ secrets.SONATYPE_NEXUS_USERNAME }}
ORG_GRADLE_PROJECT_mavenCentralPassword: ${{ secrets.SONATYPE_NEXUS_PASSWORD }}
run: ./gradlew publish
ORG_GRADLE_PROJECT_signingInMemoryKey: ${{ secrets.ARTIFACT_SIGNING_PRIVATE_KEY }}
run: ./gradlew :uri:publishAllPublicationsToMavenCentralRepository

env:
GRADLE_OPTS: -Dorg.gradle.daemon=false -Dkotlin.incremental=false -Dorg.gradle.jvmargs="-Xmx4g -Xms512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8 -XX:MaxMetaspaceSize=1024m"
DEPENDENCY_GRAPH_INCLUDE_CONFIGURATIONS: runtimeClasspath|releaseRuntimeClasspath
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@ out/
.idea/
build/
local.properties
tmp
47 changes: 47 additions & 0 deletions Dangerfile.df.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
import systems.danger.kotlin.*
import java.util.Locale

danger(args) {
with(github) {
val labelNames = issue.labels.map { it.name }.toSet()

/*
# --------------------------------------------------------------------------------------------------------------------
# Check if labels were added to the pull request
#--------------------------------------------------------------------------------------------------------------------
*/
val labelsToFilter = setOf("hold", "skip release notes")
val acceptableLabels = labelNames.filter { it !in labelsToFilter }

if(acceptableLabels.isEmpty() && pullRequest.head.ref != "bots/bump-version") {
fail("PR needs labels (hold and skip release notes don't count)")
}

/*
# --------------------------------------------------------------------------------------------------------------------
# Don't merge if there is a WIP or Hold label applied
# --------------------------------------------------------------------------------------------------------------------
*/
if("Hold" in labelNames) fail("This PR cannot be merged with a hold label applied")

/*
# --------------------------------------------------------------------------------------------------------------------
# Check if merge commits were added to the pull request
# --------------------------------------------------------------------------------------------------------------------
*/
val mergeCommitRegex = Regex("^Merge branch '${pullRequest.base.ref}'.*")
if(git.commits.any { it.message.matches(mergeCommitRegex) }) {
fail("Please rebase to get rid of the merge commits in this PR")
}
}

/*
# --------------------------------------------------------------------------------------------------------------------
# Make sure that no crash files or dumps are in the commit
# --------------------------------------------------------------------------------------------------------------------
*/
val touchedFiles = git.createdFiles + git.modifiedFiles
if(touchedFiles.any { it.startsWith("hs_err_pid") || it.startsWith("java_pid") }) {
fail("Please remove any error logs (hs_err_pid*.log) or heap dumps (java_pid*.hprof)")
}
}
1 change: 1 addition & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
BSD 3-Clause License

Copyright (c) 2019, Nikolay Feldman
Copyright (c) 2023, Eliezer Graber
All rights reserved.

Redistribution and use in source and binary forms, with or without
Expand Down
Loading