Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
eygraber committed Oct 23, 2023
0 parents commit c830116
Show file tree
Hide file tree
Showing 53 changed files with 6,805 additions and 0 deletions.
1 change: 1 addition & 0 deletions .ci-java-version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
20
24 changes: 24 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# noinspection EditorConfigKeyCorrectness
[*.{kt,kts}]
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 = android_studio
ktlint_experimental = enabled
ktlint_ignore_back_ticked_identifier = true
ktlint_standard_annotation = disabled
ktlint_standard_class-signature = disabled
ktlint_standard_comment-wrapping = disabled
ktlint_standard_filename = disabled
ktlint_standard_function-naming = disabled
ktlint_standard_function-signature = disabled
ktlint_standard_keyword-spacing = disabled
ktlint_standard_package-name = disabled
ktlint_standard_property-naming = disabled
ktlint_standard_spacing-between-declarations-with-annotations = disabled
ktlint_standard_trailing-comma-on-call-site = disabled
ktlint_standard_trailing-comma-on-declaration-site = disabled
max_line_length = 120
100 changes: 100 additions & 0 deletions .github/workflows/pr.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
name: Check

on:
pull_request

jobs:
danger:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4

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

detekt:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4

- 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: Run detekt
run: ./detekt

detektIos:
runs-on: macos-latest
steps:
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4

- 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: Build for iOS
run: ./gradlew detektIosMain

lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4

- 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: Run checks
run: ./gradlew lintRelease

test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4

- 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: Run checks
run: ./gradlew allTests

env:
GRADLE_OPTS: -Dorg.gradle.daemon=false -Dkotlin.incremental=false -Dorg.gradle.jvmargs="-Xmx4g -Xms512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8 -XX:MaxMetaspaceSize=1024m"
145 changes: 145 additions & 0 deletions .github/workflows/publish_release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,145 @@
name: Publish a release

on:
workflow_dispatch:

env:
VERSION_FILE: gradle.properties
VERSION_EXTRACT_PATTERN: '(?<=version=).+'
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_artifacts:
runs-on: macos-latest

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

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

- 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: Publish the artifacts
env:
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 }}
run: ./gradlew publishAllPublicationsToMavenCentralRepository -Pversion=${{ env.RELEASE_VERSION }}

publish_release:
needs: publish_artifacts

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # 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@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: `${GIT_HEAD}`
})
- name: Build changelog
id: build_changelog
uses: mikepenz/release-changelog-builder-action@v4
with:
configuration: "changelog_config.json"
toTag: ${{ env.RELEASE_VERSION }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Create release
id: create_release
uses: ncipollo/[email protected]
with:
body: ${{ steps.build_changelog.outputs.changelog }}
name: Release ${{ env.RELEASE_VERSION }}
tag: ${{ env.RELEASE_VERSION }}
token: ${{ secrets.PUSH_PAT }}

- uses: actions/checkout@v4
with:
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/(compose-placeholder.*:)[0-9]+\.[0-9]+\.[0-9]+"/\1${{ env.RELEASE_VERSION }}"/g' README.md && \
sed -i -E -e 's/(compose-placeholder.*:)[0-9]+\.[0-9]+\.[0-9]+-SNAPSHOT/\1${{ env.NEXT_VERSION }}-SNAPSHOT/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"
36 changes: 36 additions & 0 deletions .github/workflows/publish_snapshot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
name: Publish a snapshot release

on:
push:
branches:
- master

jobs:
publish_snapshot:
runs-on: macos-latest
steps:
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4

- 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
dependency-graph: generate-and-submit

- name: Publish the artifacts
env:
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 }}
run: ./gradlew 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
12 changes: 12 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
*.iml
.gradle
/local.properties
/.idea
# Make an exception for the code style
!.idea/codeStyles/
.DS_Store
build/
/captures
.externalNativeBuild
.cxx
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()) {
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)")
}
}
Loading

0 comments on commit c830116

Please sign in to comment.