Skip to content

Commit

Permalink
Add CI and publishing config
Browse files Browse the repository at this point in the history
  • Loading branch information
gesellix committed Feb 27, 2022
1 parent 88eab3a commit 2c96c25
Show file tree
Hide file tree
Showing 14 changed files with 397 additions and 9 deletions.
10 changes: 10 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
root = true

[*]
end_of_line = lf
insert_final_newline = true
charset = utf-8
indent_size = 2
indent_style = space
trim_trailing_whitespace = true
continuation_indent_size = 4
4 changes: 3 additions & 1 deletion .gitattributes
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
*.bat text eol=crlf
* text=auto
*.bat text eol=crlf
gradlew text eol=lf
17 changes: 17 additions & 0 deletions .github/actions/docker-install-macos/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
---
name: "Install Docker on macOS"
description: "Performs an unattended install of Docker Desktop for MacOS"
runs:
using: "composite"
steps:
# From https://github.com/docker/for-mac/issues/2359#issuecomment-943131345
- run: |
brew install --cask docker
sudo /Applications/Docker.app/Contents/MacOS/Docker --unattended --install-privileged-components
open -a /Applications/Docker.app --args --unattended --accept-license
while ! /Applications/Docker.app/Contents/Resources/bin/docker info &>/dev/null; do sleep 1; done
shell: bash
branding:
icon: "tag"
color: "blue"
...
11 changes: 11 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
version: 2
updates:
- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: "daily"
- package-ecosystem: "gradle"
directory: "/"
schedule:
interval: "daily"
open-pull-requests-limit: 20
33 changes: 33 additions & 0 deletions .github/workflows/cd.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
---
name: Publish
on:
push:
branches:
- main
jobs:
publish:
runs-on: ubuntu-latest
timeout-minutes: 20
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 1
- name: Set up JDK
uses: actions/setup-java@v3
with:
distribution: 'zulu'
java-version: 8
cache: 'gradle'
- name: build publish
run: ./gradlew clean build publish --info --stacktrace
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
ORG_GRADLE_PROJECT_signingKey: ${{ secrets.GPG_SIGNING_KEY }}
ORG_GRADLE_PROJECT_signingPassword: ${{ secrets.GPG_SIGNING_PASSWORD }}
- name: Publish Test Report
if: ${{ always() }}
uses: scacap/action-surefire-report@v1
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
report_paths: '**/build/test-results/test/TEST-*.xml'
...
48 changes: 48 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
---
name: CI
on:
workflow_dispatch:
push:
branches-ignore:
- main
jobs:
ci-build:
strategy:
matrix:
os: [ ubuntu-latest, windows-latest, macos-latest ]
java: [ 8, 11, 17 ]
runs-on: ${{ matrix.os }}
timeout-minutes: 20
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 1
- name: Set up JDK
uses: actions/setup-java@v3
with:
distribution: 'zulu'
java-version: ${{ matrix.java }}
cache: 'gradle'
- name: Install Docker on macOS
if: matrix.os == 'macos-latest'
uses: ./.github/actions/docker-install-macos
- name: Login to Docker Hub
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: docker version
run: docker version
- name: docker info
run: docker info
- name: java version
run: java -version
- name: clean build
run: ./gradlew clean build --info --stacktrace
- name: Publish Test Report
if: ${{ always() }}
uses: scacap/action-surefire-report@v1
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
report_paths: '**/build/test-results/test/TEST-*.xml'
...
41 changes: 41 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
---
name: Release
on:
release:
types:
- released
# - published

jobs:
release:
runs-on: ubuntu-latest
timeout-minutes: 20
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 1
- name: Set up JDK
uses: actions/setup-java@v3
with:
distribution: 'zulu'
java-version: 8
cache: 'gradle'
- name: Set artifact version
run: |
echo "RELEASE_VERSION=$(echo '${{ github.event.release.tag_name }}' | sed -e s/^v//)" >> $GITHUB_ENV
- name: build publish
run: ./gradlew clean build publish closeAndReleaseStagingRepository --info --stacktrace -Pversion="${{ env.RELEASE_VERSION }}"
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
ORG_GRADLE_PROJECT_signingKey: ${{ secrets.GPG_SIGNING_KEY }}
ORG_GRADLE_PROJECT_signingPassword: ${{ secrets.GPG_SIGNING_PASSWORD }}
SONATYPE_STAGING_PROFILE_ID: ${{ secrets.SONATYPE_STAGING_PROFILE_ID }}
SONATYPE_USERNAME: ${{ secrets.SONATYPE_USERNAME }}
SONATYPE_PASSWORD: ${{ secrets.SONATYPE_PASSWORD }}
- name: Publish Test Report
if: ${{ always() }}
uses: scacap/action-surefire-report@v1
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
report_paths: '**/build/test-results/test/TEST-*.xml'
...
18 changes: 18 additions & 0 deletions .github/workflows/update-gradle-wrapper.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
name: Update Gradle Wrapper

on:
workflow_dispatch:
schedule:
# "weekly" https://crontab.guru/every-week
- cron: "0 0 * * 0"

jobs:
update-gradle-wrapper:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Update Gradle Wrapper
uses: gradle-update/update-gradle-wrapper-action@v1
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}
- uses: gradle/wrapper-validation-action@v1
10 changes: 9 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
.gradle
build
.idea
*.iml
build/
classes/
.DS_Store
out/
*.settings
*.project
*bin/
*.classpath
15 changes: 15 additions & 0 deletions RELEASE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
## Publishing

Packages are automatically published from the `main` branch to the GitHub Package Registry.
Manually cut releases will be published to both GitHub Package Registry and Maven Central.

## Release Workflow

There are multiple GitHub Action Workflows for the different steps in the package's lifecycle:

- CI: Builds and checks incoming changes on a pull request
- triggered on every push to a non-default branch
- CD: Publishes the Gradle artifacts to GitHub Package Registry
- triggered only on pushes to the default branch
- Release: Publishes Gradle artifacts to Sonatype and releases them to Maven Central
- triggered on a published GitHub release using the underlying tag as artifact version, e.g. via `git tag -m "$MESSAGE" v$(date +"%Y-%m-%dT%H-%M-%S")`
66 changes: 66 additions & 0 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
import java.text.SimpleDateFormat
import java.util.*

rootProject.extra.set("artifactVersion", SimpleDateFormat("yyyy-MM-dd\'T\'HH-mm-ss").format(Date()))

plugins {
id("maven-publish")
id("com.github.ben-manes.versions") version "0.42.0"
id("net.ossindex.audit") version "0.4.11"
id("io.freefair.maven-central.validate-poms") version "6.4.1"
id("io.github.gradle-nexus.publish-plugin") version "1.1.0"
}

val dependencyVersions = listOf(
"org.jetbrains:annotations:23.0.0"
)

val dependencyVersionsByGroup = mapOf<String, String>(
)

subprojects {
repositories {
// mavenLocal()
// fun findProperty(s: String) = project.findProperty(s) as String?
// maven {
// name = "github"
// setUrl("https://maven.pkg.github.com/docker-client/*")
// credentials {
// username = System.getenv("PACKAGE_REGISTRY_USER") ?: findProperty("github.package-registry.username")
// password = System.getenv("PACKAGE_REGISTRY_TOKEN") ?: findProperty("github.package-registry.password")
// }
// }
mavenCentral()
}
}

allprojects {
configurations.all {
resolutionStrategy {
failOnVersionConflict()
force(dependencyVersions)
eachDependency {
val forcedVersion = dependencyVersionsByGroup[requested.group]
if (forcedVersion != null) {
useVersion(forcedVersion)
}
}
}
}
}

fun findProperty(s: String) = project.findProperty(s) as String?

val isSnapshot = project.version == "unspecified"
nexusPublishing {
repositories {
if (!isSnapshot) {
sonatype {
// 'sonatype' is pre-configured for Sonatype Nexus (OSSRH) which is used for The Central Repository
stagingProfileId.set(System.getenv("SONATYPE_STAGING_PROFILE_ID") ?: findProperty("sonatype.staging.profile.id")) //can reduce execution time by even 10 seconds
username.set(System.getenv("SONATYPE_USERNAME") ?: findProperty("sonatype.username"))
password.set(System.getenv("SONATYPE_PASSWORD") ?: findProperty("sonatype.password"))
}
}
}
}
14 changes: 14 additions & 0 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
org.gradle.daemon=true

group=de.gesellix

github.package-registry.owner=docker-client
github.package-registry.repository=docker-registry
github.package-registry.username=
github.package-registry.password=

sonatype.snapshot.url=https://oss.sonatype.org/content/repositories/snapshots/
sonatype.staging.url=https://oss.sonatype.org/service/local/staging/deploy/maven2/
sonatype.staging.profile.id=
sonatype.username=
sonatype.password=
Empty file modified gradlew
100644 → 100755
Empty file.
Loading

0 comments on commit 2c96c25

Please sign in to comment.