Skip to content

Commit

Permalink
Add github action workflows
Browse files Browse the repository at this point in the history
  • Loading branch information
domi-b committed Dec 5, 2023
1 parent 3015c07 commit a71b173
Show file tree
Hide file tree
Showing 4 changed files with 216 additions and 0 deletions.
25 changes: 25 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
name: CI/CD

on: push

jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- uses: actions/cache@v3
with:
path: ~/.gradle/caches
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle') }}
restore-keys: |
${{ runner.os }}-gradle-
- name: Set up JDK 21
uses: actions/setup-java@v4
with:
java-version: 21
distribution: temurin

- name: Build with Gradle
run: ./gradlew build
64 changes: 64 additions & 0 deletions .github/workflows/prerelease.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
name: Prerelease

on:
push:
branches:
- main
workflow_dispatch:

jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Get next Version
id: tag_version
uses: mathieudutour/github-tag-action@fcfbdceb3093f6d85a3b194740f8c6cec632f4e2
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
release_branches: .*
dry_run: true

- uses: actions/cache@v3
with:
path: ~/.gradle/caches
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle') }}
restore-keys: |
${{ runner.os }}-gradle-
- name: Set up JDK 21
uses: actions/setup-java@v4
with:
java-version: 21
distribution: temurin

- name: Build jar with Gradle
run: ./gradlew -Pversion='${{ steps.tag_version.outputs.new_version }}-SNAPSHOT' jar

- name: Publish to GitHub Maven with Gradle
run: ./gradlew -Pversion='${{ steps.tag_version.outputs.new_version }}-SNAPSHOT' publishGeowerkstattTestbedRunnerPublicationToGitHubPackagesRepository
env:
ORG_GRADLE_PROJECT_GITHUB_ACTOR: ${{ github.actor }}
ORG_GRADLE_PROJECT_GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
ORG_GRADLE_PROJECT_SIGNING_KEY: ${{ secrets.SIGNING_KEY }}
ORG_GRADLE_PROJECT_SIGNING_PASSWORD: ${{ secrets.SIGNING_PASSWORD }}

- name: Publish to OSSRH Maven with Gradle
run: ./gradlew -Pversion='${{ steps.tag_version.outputs.new_version }}-SNAPSHOT' publishToSonatype
env:
ORG_GRADLE_PROJECT_OSSRH_USER: ${{ secrets.OSSRH_USER }}
ORG_GRADLE_PROJECT_OSSRH_PASSWORD: ${{ secrets.OSSRH_PASSWORD }}
ORG_GRADLE_PROJECT_SIGNING_KEY: ${{ secrets.SIGNING_KEY }}
ORG_GRADLE_PROJECT_SIGNING_PASSWORD: ${{ secrets.SIGNING_PASSWORD }}

- uses: ncipollo/release-action@6c75be85e571768fa31b40abf38de58ba0397db5
with:
artifacts: "build/libs/*.jar"
allowUpdates: true
name: ${{ steps.tag_version.outputs.new_tag }}-SNAPSHOT
tag: ${{ steps.tag_version.outputs.new_tag }}-SNAPSHOT-${{ github.run_id }}
commit: ${{ github.sha }}
body: ${{ steps.tag_version.outputs.changelog }}
prerelease: true
token: ${{ secrets.GITHUB_TOKEN }}
58 changes: 58 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
name: Release

on:
workflow_dispatch:

jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Bump version and push tag
id: tag_version
uses: mathieudutour/github-tag-action@fcfbdceb3093f6d85a3b194740f8c6cec632f4e2
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
release_branches: .*

- uses: actions/cache@v3
with:
path: ~/.gradle/caches
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle') }}
restore-keys: |
${{ runner.os }}-gradle-
- name: Set up JDK 21
uses: actions/setup-java@v4
with:
java-version: 21
distribution: temurin

- name: Build jar with Gradle
run: ./gradlew -Pversion='${{ steps.tag_version.outputs.new_version }}' jar

- name: Publish to GitHub Maven with Gradle
run: ./gradlew -Pversion='${{ steps.tag_version.outputs.new_version }}' publishGeowerkstattTestbedRunnerPublicationToGitHubPackagesRepository
env:
ORG_GRADLE_PROJECT_GITHUB_ACTOR: ${{ github.actor }}
ORG_GRADLE_PROJECT_GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
ORG_GRADLE_PROJECT_SIGNING_KEY: ${{ secrets.SIGNING_KEY }}
ORG_GRADLE_PROJECT_SIGNING_PASSWORD: ${{ secrets.SIGNING_PASSWORD }}

- name: Publish to OSSRH Maven with Gradle
run: ./gradlew -Pversion='${{ steps.tag_version.outputs.new_version }}' publishToSonatype closeAndReleaseSonatypeStagingRepository
env:
ORG_GRADLE_PROJECT_OSSRH_USER: ${{ secrets.OSSRH_USER }}
ORG_GRADLE_PROJECT_OSSRH_PASSWORD: ${{ secrets.OSSRH_PASSWORD }}
ORG_GRADLE_PROJECT_SIGNING_KEY: ${{ secrets.SIGNING_KEY }}
ORG_GRADLE_PROJECT_SIGNING_PASSWORD: ${{ secrets.SIGNING_PASSWORD }}

- uses: ncipollo/release-action@6c75be85e571768fa31b40abf38de58ba0397db5
with:
artifacts: "build/libs/*.jar"
makeLatest: true
name: ${{ steps.tag_version.outputs.new_tag }}
tag: ${{ steps.tag_version.outputs.new_tag }}
body: ${{ steps.tag_version.outputs.changelog }}
token: ${{ secrets.GITHUB_TOKEN }}
69 changes: 69 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@ plugins {
id 'java'
id 'application'
id 'checkstyle'
id 'maven-publish'
id 'signing'
id("io.github.gradle-nexus.publish-plugin") version "1.3.0"
}

group = 'ch.geowerkstatt.interlis.testbed.runner'
Expand All @@ -19,6 +22,72 @@ application {
mainClass = 'ch.geowerkstatt.interlis.testbed.runner.Main'
}

java {
withSourcesJar()
withJavadocJar()
}

test {
useJUnitPlatform()
}

publishing {
publications {
GeowerkstattTestbedRunner(MavenPublication) {
from components.java
pom {
name = 'interlis-testbed-runner'
description = 'Testbed runner to test INTERLIS constraint definitions.'
url = 'https://github.com/GeoWerkstatt/interlis-testbed-runner'
licenses {
license {
name = 'MIT License'
url = 'https://github.com/GeoWerkstatt/interlis-testbed-runner/blob/master/LICENSE'
}
}
developers {
developer {
id = 'GeoWerkstatt'
name = 'GeoWerkstatt GmbH'
email = '[email protected]'
}
}
scm {
connection = 'scm:git:git:https://github.com/GeoWerkstatt/interlis-testbed-runner.git'
developerConnection = 'scm:git:git:https://github.com/GeoWerkstatt/interlis-testbed-runner.git'
url = 'https://github.com/GeoWerkstatt/interlis-testbed-runner/'
}
}
}
}

repositories {
maven {
name = 'GitHubPackages'
url = uri('https://maven.pkg.github.com/GeoWerkstatt/interlis-testbed-runner')
credentials {
username = findProperty("GITHUB_ACTOR")
password = findProperty("GITHUB_TOKEN")
}
}
}
}

nexusPublishing {
repositories {
sonatype { //only for users registered in Sonatype after 24 Feb 2021
username = findProperty("OSSRH_USER")
password = findProperty("OSSRH_PASSWORD")
nexusUrl.set(uri("https://s01.oss.sonatype.org/service/local/"))
snapshotRepositoryUrl.set(uri("https://s01.oss.sonatype.org/content/repositories/snapshots/"))
}
}
}

signing {
def key = findProperty("SIGNING_KEY")
def password = findProperty("SIGNING_PASSWORD")

useInMemoryPgpKeys(key, password)
sign(publishing.publications.GeowerkstattTestbedRunner)
}

0 comments on commit a71b173

Please sign in to comment.