From 4c5f1db6d98f9a62cc40494115279326b03f9d37 Mon Sep 17 00:00:00 2001 From: mikeplotean Date: Sun, 22 Oct 2023 15:57:10 +0300 Subject: [PATCH] ci: added workflows, updated subprojects gradle builds --- .github/workflows/build.yml | 46 ++++++++++++++++++ .github/workflows/lint-pr.yml | 66 +++++++++++++++++++++++++ .github/workflows/release.yml | 75 +++++++++++++++++++++++++++++ .github/workflows/stale.yml | 13 +++++ build.gradle.kts | 10 ++++ waltid-credentials/build.gradle.kts | 26 +++++----- waltid-crypto/build.gradle.kts | 18 +++---- waltid-did/build.gradle.kts | 16 +++--- 8 files changed, 240 insertions(+), 30 deletions(-) create mode 100644 .github/workflows/build.yml create mode 100644 .github/workflows/lint-pr.yml create mode 100644 .github/workflows/release.yml create mode 100644 .github/workflows/stale.yml diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 000000000..d5ff10ee1 --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,46 @@ +name: Build on every push + +on: + push: + branches-ignore: + - main + + +jobs: + build: + name: "Build" + runs-on: "ubuntu-latest" + steps: + - uses: actions/checkout@v3 + - name: Calculate release version + run: | + echo "release_version=1.$(date +'%g%m%d%H%M').$(echo ${{ github.ref_name }} | tr / -)" >> $GITHUB_ENV + - name: Set version + run: | + sed -i "s/1.SNAPSHOT/${{ env.release_version }}/g" build.gradle.kts Values.kt + - run: | + git tag v${{ env.release_version }} + git push --tags + - name: Setup java + uses: actions/setup-java@v2.1.0 + with: + distribution: 'adopt-hotspot' + java-version: '15' + - name: Setup cache + uses: actions/cache@v2 + with: + path: | + ~/.gradle/caches + ~/.gradle/wrapper + key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }} + restore-keys: | + ${{ runner.os }}-gradle- + - name: Gradle wrapper validation + uses: gradle/wrapper-validation-action@v1 + - name: Running gradle build + uses: eskatos/gradle-command-action@v1.3.3 + env: + MAVEN_USERNAME: ${{ secrets.MAVEN_USERNAME }} + MAVEN_PASSWORD: ${{ secrets.MAVEN_PASSWORD }} + with: + arguments: build publish --no-daemon \ No newline at end of file diff --git a/.github/workflows/lint-pr.yml b/.github/workflows/lint-pr.yml new file mode 100644 index 000000000..8420f4c26 --- /dev/null +++ b/.github/workflows/lint-pr.yml @@ -0,0 +1,66 @@ +name: "Lint PR" + +on: + pull_request_target: + types: + - opened + - edited + - synchronize + +jobs: + main: + name: Validate PR + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + with: + fetch-depth: 0 + - uses: walt-id/commitlint-github-action@v4 + with: + noMerges: true + id: lint_commit_messages + continue-on-error: true + - name: semantic-pull-request + if: always() && !contains(fromJSON(steps.lint_commit_messages.outputs.results).*.valid, true) + id: lint_pr_title + uses: amannn/action-semantic-pull-request@v5.2.0 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + - uses: marocchino/sticky-pull-request-comment@v2 + # When the previous steps fails, the workflow would stop. By adding this + # condition you can continue the execution with the populated error message. + if: always() && (steps.lint_pr_title.outputs.error_message != null || contains(fromJSON(steps.lint_commit_messages.outputs.results).*.valid, false)) + with: + header: pr-title-lint-error + message: | + Hey there and thank you for opening this pull request! 👋🏼 + + Some or all of your commit messages do not seem to follow the [Conventional Commits specification](https://www.conventionalcommits.org/en/v1.0.0/). + To allow the merge of this pull request, we require that at least one commit message or the PR title follow that convention. + + You have the following possibilities to proceed with this PR: + 1) Make sure at least one commit message complies with the [Conventional Commits specification](https://www.conventionalcommits.org/en/v1.0.0/). + Note, if not all messages comply, the merge will be allowed, but you will still see this warning. + 2) Update the title of this pull request to comply with the [Conventional Commits specification](https://www.conventionalcommits.org/en/v1.0.0/). + + Further information: + The commit messages and PR title will be parsed according to the [Conventional Commits specification](https://www.conventionalcommits.org/en/v1.0.0/), to automatically populate the release notes for the next official release. + Therefore, make sure the commit messages or PR title contain the necessary and relevant information describing the changes of this pull request. + + Commit message details: + + ``` + ${{ toJSON(fromJSON(steps.lint_commit_messages.outputs.results)) }} + ``` + + PR title details: + ``` + ${{ steps.lint_pr_title.outputs.error_message }} + ``` + + # Delete a previous comment when the issue has been resolved + - if: ${{ steps.lint_pr_title.outputs.error_message == null && !contains(fromJSON(steps.lint_commit_messages.outputs.results).*.valid, false) }} + uses: marocchino/sticky-pull-request-comment@v2 + with: + header: pr-title-lint-error + delete: true diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 000000000..df29f2eff --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,75 @@ +name: Release on push to main + +on: + push: + branches: + - main + +jobs: + release: + name: "Release" + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - name: Calculate release version + run: | + echo "release_version=1.$(date +'%g%m%d%H%M').0" >> $GITHUB_ENV + - name: Set version + run: | + sed -i "s/1.SNAPSHOT/${{ env.release_version }}/g" build.gradle.kts src/main/kotlin/id/walt/Values.kt + - run: | + git tag v${{ env.release_version }} + git push --tags + - name: Setup cache + uses: actions/cache@v2 + with: + path: | + ~/.gradle/caches + ~/.gradle/wrapper + key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }} + restore-keys: | + ${{ runner.os }}-gradle- + - name: Gradle wrapper validation + uses: gradle/wrapper-validation-action@v1 + - name: Running gradle build + uses: eskatos/gradle-command-action@v1.3.3 + env: + MAVEN_USERNAME: ${{ secrets.MAVEN_USERNAME }} + MAVEN_PASSWORD: ${{ secrets.MAVEN_PASSWORD }} + with: + arguments: build publish --no-daemon + - name: Changelog + uses: ardalanamini/auto-changelog@v3 + id: changelog + with: + github-token: ${{ github.token }} + commit-types: | + breaking: Breaking Changes + feat: New Features + fix: Bug Fixes + revert: Reverts + perf: Performance Improvements + refactor: Refactors + deps: Dependencies + docs: Documentation Changes + style: Code Style Changes + build: Build System + ci: Continuous Integration + test: Tests + chore: Chores + other: Other Changes + default-commit-type: Other Changes + release-name: v${{ env.release_version }} + mention-authors: true + mention-new-contributors: true + include-compare: true + semver: true + - name: Create Release + uses: softprops/action-gh-release@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + tag_name: v${{ env.release_version }} + body: | + ${{ steps.changelog.outputs.changelog }} + prerelease: ${{ steps.changelog.outputs.prerelease }} diff --git a/.github/workflows/stale.yml b/.github/workflows/stale.yml new file mode 100644 index 000000000..5c25cf3cb --- /dev/null +++ b/.github/workflows/stale.yml @@ -0,0 +1,13 @@ +name: 'Close stale issues and PRs' +on: + schedule: + - cron: '30 20 * * *' + +jobs: + stale: + runs-on: ubuntu-latest + steps: + - uses: actions/stale@v3 + with: + stale-issue-message: 'This issue has been marked as stale.' + stale-pr-message: 'This pull request has been marked as stale.' diff --git a/build.gradle.kts b/build.gradle.kts index 0ebec5c17..322bf3e89 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -12,4 +12,14 @@ plugins { kotlin("multiplatform") version kotlinVersion apply false kotlin("plugin.serialization") version kotlinVersion apply false id("com.github.ben-manes.versions") version "0.48.0" apply false + kotlin("jvm") version "1.9.20-RC" +} +dependencies { + implementation(kotlin("stdlib-jdk8")) +} +repositories { + mavenCentral() +} +kotlin { + jvmToolchain(8) } \ No newline at end of file diff --git a/waltid-credentials/build.gradle.kts b/waltid-credentials/build.gradle.kts index 12c247999..78f863744 100644 --- a/waltid-credentials/build.gradle.kts +++ b/waltid-credentials/build.gradle.kts @@ -13,18 +13,18 @@ repositories { } java { - sourceCompatibility = JavaVersion.VERSION_11 - targetCompatibility = JavaVersion.VERSION_11 + sourceCompatibility = JavaVersion.VERSION_15 + targetCompatibility = JavaVersion.VERSION_15 } kotlin { - jvmToolchain(11) + jvmToolchain(15) } kotlin { jvm { compilations.all { - kotlinOptions.jvmTarget = "11" // JVM got Ed25519 at version 15 + kotlinOptions.jvmTarget = "15" // JVM got Ed25519 at version 15 } withJava() tasks.withType().configureEach { @@ -89,23 +89,23 @@ kotlin { repositories { maven { url = uri("https://maven.walt.id/repository/waltid/") - val envUsername = null //java.lang.System.getenv("MAVEN_USERNAME") - val envPassword = null //java.lang.System.getenv("MAVEN_PASSWORD") + val envUsername = System.getenv("MAVEN_USERNAME") + val envPassword = System.getenv("MAVEN_PASSWORD") - val usernameFile = File("secret_maven_username.txt") - val passwordFile = File("secret_maven_password.txt") - - val secretMavenUsername = envUsername ?: usernameFile.let { if (it.isFile) it.readLines().first() else "" } +// val usernameFile = File("secret_maven_username.txt") +// val passwordFile = File("secret_maven_password.txt") +// +// val secretMavenUsername = envUsername ?: usernameFile.let { if (it.isFile) it.readLines().first() else "" } //println("Deploy username length: ${secretMavenUsername.length}") - val secretMavenPassword = envPassword ?: passwordFile.let { if (it.isFile) it.readLines().first() else "" } +// val secretMavenPassword = envPassword ?: passwordFile.let { if (it.isFile) it.readLines().first() else "" } //if (secretMavenPassword.isBlank()) { // println("WARNING: Password is blank!") //} credentials { - username = secretMavenUsername - password = secretMavenPassword + username = envUsername + password = envPassword } } } diff --git a/waltid-crypto/build.gradle.kts b/waltid-crypto/build.gradle.kts index 4a7b84ebe..51b6d09e2 100644 --- a/waltid-crypto/build.gradle.kts +++ b/waltid-crypto/build.gradle.kts @@ -90,23 +90,23 @@ kotlin { repositories { maven { url = uri("https://maven.walt.id/repository/waltid/") - val envUsername = null //java.lang.System.getenv("MAVEN_USERNAME") - val envPassword = null //java.lang.System.getenv("MAVEN_PASSWORD") + val envUsername = System.getenv("MAVEN_USERNAME") + val envPassword = System.getenv("MAVEN_PASSWORD") - val usernameFile = File("secret_maven_username.txt") - val passwordFile = File("secret_maven_password.txt") - - val secretMavenUsername = envUsername ?: usernameFile.let { if (it.isFile) it.readLines().first() else "" } +// val usernameFile = File("secret_maven_username.txt") +// val passwordFile = File("secret_maven_password.txt") +// +// val secretMavenUsername = envUsername ?: usernameFile.let { if (it.isFile) it.readLines().first() else "" } //println("Deploy username length: ${secretMavenUsername.length}") - val secretMavenPassword = envPassword ?: passwordFile.let { if (it.isFile) it.readLines().first() else "" } +// val secretMavenPassword = envPassword ?: passwordFile.let { if (it.isFile) it.readLines().first() else "" } //if (secretMavenPassword.isBlank()) { // println("WARNING: Password is blank!") //} credentials { - username = secretMavenUsername - password = secretMavenPassword + username = envUsername + password = envPassword } } } diff --git a/waltid-did/build.gradle.kts b/waltid-did/build.gradle.kts index 00dfb89d5..732345d8d 100644 --- a/waltid-did/build.gradle.kts +++ b/waltid-did/build.gradle.kts @@ -94,23 +94,23 @@ kotlin { repositories { maven { url = uri("https://maven.walt.id/repository/waltid/") - val envUsername = null //java.lang.System.getenv("MAVEN_USERNAME") - val envPassword = null //java.lang.System.getenv("MAVEN_PASSWORD") + val envUsername = System.getenv("MAVEN_USERNAME") + val envPassword = System.getenv("MAVEN_PASSWORD") - val usernameFile = File("secret_maven_username.txt") - val passwordFile = File("secret_maven_password.txt") +// val usernameFile = File("secret_maven_username.txt") +// val passwordFile = File("secret_maven_password.txt") - val secretMavenUsername = envUsername ?: usernameFile.let { if (it.isFile) it.readLines().first() else "" } +// val secretMavenUsername = envUsername ?: usernameFile.let { if (it.isFile) it.readLines().first() else "" } //println("Deploy username length: ${secretMavenUsername.length}") - val secretMavenPassword = envPassword ?: passwordFile.let { if (it.isFile) it.readLines().first() else "" } +// val secretMavenPassword = envPassword ?: passwordFile.let { if (it.isFile) it.readLines().first() else "" } //if (secretMavenPassword.isBlank()) { // println("WARNING: Password is blank!") //} credentials { - username = secretMavenUsername - password = secretMavenPassword + username = envUsername + password = envPassword } } }