Skip to content

Commit

Permalink
ci: added workflows, updated subprojects gradle builds
Browse files Browse the repository at this point in the history
  • Loading branch information
mikeplotean committed Oct 22, 2023
1 parent 54c2e18 commit 27c8fab
Show file tree
Hide file tree
Showing 8 changed files with 241 additions and 30 deletions.
47 changes: 47 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
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
${{ env.release_version }}
- run: |
git tag v${{ env.release_version }}
git push --tags
- name: Setup java
uses: actions/[email protected]
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/[email protected]
env:
MAVEN_USERNAME: ${{ secrets.MAVEN_USERNAME }}
MAVEN_PASSWORD: ${{ secrets.MAVEN_PASSWORD }}
with:
arguments: build publish --no-daemon
66 changes: 66 additions & 0 deletions .github/workflows/lint-pr.yml
Original file line number Diff line number Diff line change
@@ -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/[email protected]
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 <b>or</b> the PR title follow that convention.
You have the <b>following possibilities to proceed</b> 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/).
<b>Further information:</b>
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 <b>or</b> PR title contain the necessary and relevant information describing the changes of this pull request.
<b>Commit message details:</b>
```
${{ toJSON(fromJSON(steps.lint_commit_messages.outputs.results)) }}
```
<b>PR title details:</b>
```
${{ 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
75 changes: 75 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -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/[email protected]
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 }}
13 changes: 13 additions & 0 deletions .github/workflows/stale.yml
Original file line number Diff line number Diff line change
@@ -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.'
10 changes: 10 additions & 0 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
26 changes: 13 additions & 13 deletions waltid-credentials/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -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<Test>().configureEach {
Expand Down Expand Up @@ -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
}
}
}
Expand Down
18 changes: 9 additions & 9 deletions waltid-crypto/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}
}
Expand Down
16 changes: 8 additions & 8 deletions waltid-did/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}
}
Expand Down

0 comments on commit 27c8fab

Please sign in to comment.