Skip to content

Commit

Permalink
First attempt to make it useful
Browse files Browse the repository at this point in the history
  • Loading branch information
sbglasius committed Sep 17, 2024
1 parent 5605c7c commit 59f45cb
Show file tree
Hide file tree
Showing 16 changed files with 561 additions and 4 deletions.
53 changes: 53 additions & 0 deletions .github/workflows/github-pages.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
name: Deploy docs to Pages

on:
# Runs on pushes targeting the default branch
push:
branches: [ master, main ]

# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:


# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages
permissions:
contents: read
pages: write
id-token: write

# Allow only one concurrent deployment, skipping runs queued between the run in-progress and latest queued.
# However, do NOT cancel in-progress runs as we want to allow these production deployments to complete.
concurrency:
group: "pages"
cancel-in-progress: false

jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-java@v4
with:
distribution: temurin
java-version: 11
- uses: dhkatz/[email protected]
id: get_version
- uses: gradle/gradle-build-action@v2
env:
RELEASE_VERSION: ${{ steps.get_version.outputs.version-without-v }}
with:
arguments: -Pversion=${RELEASE_VERSION} :docs:asciidoctor
- uses: actions/configure-pages@v4
- uses: actions/upload-pages-artifact@v3
with:
path: 'docs/build/docs'
deploy:
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
runs-on: ubuntu-latest
needs: build
steps:
- uses: actions/deploy-pages@v4
id: deployment

27 changes: 27 additions & 0 deletions .github/workflows/gradle-check.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# This workflow will build a Java project with Gradle
# For more information see: https://help.github.com/actions/language-and-framework-guides/building-and-testing-java-with-gradle

name: Check and publish snapshot

on:
push:
branches: [ master, main ]
pull_request:
branches: [ master, main ]

jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-java@v4
with:
distribution: temurin
java-version: 11
- uses: gradle/gradle-build-action@v2
env:
SONATYPE_USERNAME: ${{ secrets.SONATYPE_USERNAME }}
SONATYPE_PASSWORD: ${{ secrets.SONATYPE_PASSWORD }}
SONATYPE_STAGING_PROFILE_ID: ${{ secrets.SONATYPE_STAGING_PROFILE_ID }}
with:
arguments: publish
122 changes: 122 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,122 @@
name: Release
on:
release:
types: [ published ]
permissions:
contents: write
jobs:
get-version:
name: Get version
runs-on: ubuntu-latest
env:
GIT_USER_NAME: ${{ vars.GIT_USER_NAME }}
GIT_USER_EMAIL: ${{ vars.GIT_USER_EMAIL }}
outputs:
version: ${{ steps.get_version.outputs.version-without-v }}
next-patch-version: ${{ steps.version.outputs.inc-patch }}
steps:
- uses: actions/checkout@v4
with:
token: ${{ secrets.GITHUB_TOKEN }}
- uses: dhkatz/[email protected]
id: get_version
- uses: madhead/semver-utils@latest
id: version
with:
version: ${{ steps.get_version.outputs.version-without-v }}
release:
name: Release to SONATYPE
runs-on: ubuntu-latest
needs: get-version
env:
GIT_USER_NAME: ${{ vars.GIT_USER_NAME }}
GIT_USER_EMAIL: ${{ vars.GIT_USER_EMAIL }}
steps:
- uses: actions/checkout@v4
with:
token: ${{ secrets.GITHUB_TOKEN }}
- uses: actions/setup-java@v4
with:
java-version: 11
distribution: temurin
- uses: micronaut-projects/github-actions/pre-release@master
with:
token: ${{ secrets.GITHUB_TOKEN }}
- name: Publish to Sonatype OSSRH
# if: ${{ false }} # prevent deploy
env:
SONATYPE_USERNAME: ${{ secrets.SONATYPE_USERNAME }}
SONATYPE_PASSWORD: ${{ secrets.SONATYPE_PASSWORD }}
SONATYPE_STAGING_PROFILE_ID: ${{ secrets.SONATYPE_STAGING_PROFILE_ID }}
SECRING_FILE: ${{ secrets.SECRING_FILE }}
SIGNING_KEY_ID: ${{ secrets.SIGNING_KEY_ID }}
SIGNING_PASSPHRASE: ${{ secrets.SIGNING_PASSPHRASE }}
SIGNING_FILE: ${{ github.workspace }}/secring.pgp
RELEASE_VERSION: ${{ needs.get-version.outputs.version }}
run: |
echo "${SECRING_FILE}" | base64 -d > "${SIGNING_FILE}"
echo "Publishing Artifacts for $RELEASE_VERSION"
(set -x; ./gradlew -Pversion="${RELEASE_VERSION}" publishToSonatype closeAndReleaseSonatypeStagingRepository --no-daemon)
rm "${SIGNING_FILE}"
bump-snapshot-version:
runs-on: ubuntu-latest
needs: [ get-version, release ]
env:
GIT_USER_NAME: ${{ vars.GIT_USER_NAME }}
GIT_USER_EMAIL: ${{ vars.GIT_USER_EMAIL }}
NEXT_VERSION: ${{ needs.get-version.outputs.next-patch-version }}
steps:
- uses: actions/checkout@v4
with:
token: ${{ secrets.GITHUB_TOKEN }}
- uses: actions/setup-java@v4
with:
java-version: 8
distribution: temurin
- name: Set version in gradle.properties
run: |
echo "Preparing next snapshot as ${NEXT_VERSION}"
./gradlew snapshotVersion -Pversion="${NEXT_VERSION}"
- uses: actions-js/push@master
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
author_name: ${{ vars.GIT_USER_NAME }}
author_email: $${ vars.GIT_USER_EMAIL }}
branch: master
message: Set project version to ${{ env.NEXT_VERSION }}-SNAPSHOT
documenation:
runs-on: ubuntu-latest
needs: [ get-version, release ]
env:
GIT_USER_NAME: ${{ vars.GIT_USER_NAME }}
GIT_USER_EMAIL: ${{ vars.GIT_USER_EMAIL }}
RELEASE_VERSION: ${{ needs.get-version.outputs.version }}
steps:
- uses: actions/checkout@v4
with:
token: ${{ secrets.GITHUB_TOKEN }}
- uses: actions/setup-java@v4
with:
java-version: 8
distribution: temurin
- uses: micronaut-projects/github-actions/export-gradle-properties@master
id: asciidoctor
- uses: gradle/gradle-build-action@v2
with:
arguments: -Pversion="${{ env.RELEASE_VERSION }}" asciidoctor
- uses: micronaut-projects/github-pages-deploy-action@master
if: success()
env:
BETA: false
TARGET_REPOSITORY: ${{ github.repository }}
GH_TOKEN: ${{ secrets.GH_TOKEN }}
BRANCH: gh-pages
FOLDER: build/asciidoc
DOC_FOLDER: latest
COMMIT_EMAIL: ${{ vars.GIT_USER_EMAIL }}
COMMIT_NAME: ${{ vars.GIT_USER_NAME }}
VERSION: ${{ env.RELEASE_VERSION }}
- uses: micronaut-projects/github-actions/post-release@master
if: success()
with:
token: ${{ secrets.GH_TOKEN }}
20 changes: 20 additions & 0 deletions .github/workflows/stale.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
name: Mark stale issues and pull requests

on:
schedule:
- cron: "30 1 * * *"

jobs:
stale:

runs-on: ubuntu-latest

steps:
- uses: actions/stale@v3
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}
stale-issue-message: 'Stale issue. Marked automatically'
stale-pr-message: 'Stale pull request. Marked automatically'
stale-issue-label: 'no-issue-activity'
stale-pr-label: 'no-pr-activity'
days-before-stale: 120
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,4 @@ out/
.settings
.classpath
.factorypath
sonatype.env
146 changes: 143 additions & 3 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,13 @@ plugins {
id "idea"
id "org.grails.grails-plugin"
id "application"
id "eclipse"
id 'org.asciidoctor.jvm.convert'
id 'maven-publish'
id 'signing'
id "io.github.gradle-nexus.publish-plugin"
}

group = "release.demo"
group 'io.github.gpc'

repositories {
mavenCentral()
Expand Down Expand Up @@ -41,6 +44,8 @@ dependencies {
testImplementation("org.grails:grails-gorm-testing-support")
testImplementation("org.spockframework:spock-core")
testImplementation("io.micronaut:micronaut-http-client")

runtimeOnly 'org.grails:grails-shell:6.1.2'

}

Expand All @@ -52,6 +57,141 @@ java {
sourceCompatibility = JavaVersion.toVersion("11")
}

tasks.withType(Test) {
tasks.withType(Test).configureEach {
useJUnitPlatform()
}

publishing {
publications {
maven(MavenPublication) {
groupId = project.group
artifactId = 'release-demo'
version = project.version

from components.java
artifact sourcesJar
artifact javadocJar

pom {
name = 'Release Demo'
description = 'Release Demo for the GPC'
url = 'https://github.com/gpc/release-demo'
licenses {
license {
name = 'The Apache License, Version 2.0'
url = 'https://www.apache.org/licenses/LICENSE-2.0.txt'
}
}
developers {
developer {
id = 'sbglasius'
name = 'Søren Berg Glasius'
email = '[email protected]'
}
}
scm {
connection = 'scm:git:git://github.com/gpc/release-demo.git'
developerConnection = 'scm:git:https://github.com/gpc/release-demo.git'
url = 'https://github.com/gpc/release-demo'
}
}
}
}
}
ext.isReleaseVersion = !version.endsWith("SNAPSHOT")

if (System.getenv('SIGNING_KEY_ID')) {
ext["signing.keyId"] = System.getenv('SIGNING_KEY_ID')
ext["signing.password"] = System.getenv('SIGNING_PASSPHRASE')
ext["signing.secretKeyRingFile"] = System.getenv('SIGNING_FILE')
}

afterEvaluate {
signing {
if (System.getenv('SIGN_ARMORED_KEY')) {
String signingKey = System.getenv('SIGN_ARMORED_KEY')
String signingPassword = System.getenv('SIGN_PASSWORD')
useInMemoryPgpKeys(signingKey, signingPassword)
}
required {
isReleaseVersion
}

sign publishing.publications.maven
}
}

tasks.withType(Sign).configureEach {
onlyIf { isReleaseVersion }
}

import io.github.gradlenexus.publishplugin.InitializeNexusStagingRepository

import java.lang.management.ManagementFactory

tasks.withType(InitializeNexusStagingRepository).configureEach {
shouldRunAfter(tasks.withType(Sign))
}

tasks.register('log-debug') {
doFirst {
println "-----"
println "${System.getenv()}"
println "-----"
}
}

tasks.named('publish').configure {
dependsOn('log-debug')
}

nexusPublishing {
repositories {
sonatype {
def ossUser = System.getenv("SONATYPE_USERNAME") ?: project.hasProperty("sonatypeOssUsername") ? project.sonatypeOssUsername : ''
def ossPass = System.getenv("SONATYPE_PASSWORD") ?: project.hasProperty("sonatypeOssPassword") ? project.sonatypeOssPassword : ''
def ossStagingProfileId = System.getenv("SONATYPE_STAGING_PROFILE_ID") ?: project.hasProperty("sonatypeOssStagingProfileIdExternalConfig") ? project.sonatypeOssStagingProfileIdExternalConfig : ''

nexusUrl = uri("https://s01.oss.sonatype.org/service/local/")
snapshotRepositoryUrl = uri("https://s01.oss.sonatype.org/content/repositories/snapshots/")
username = ossUser
password = ossPass
stagingProfileId = ossStagingProfileId
}
}
}

asciidoctor {
resources {
from('src/docs/images')
into "./images"
}
sources {
include 'index.adoc'
}
attributes 'experimental': 'true',
'compat-mode': 'true',
'toc': 'left',
'icons': 'font',
'version': project.version,
'sourcedir': 'src/main/groovy'
baseDirFollowsSourceDir()
outputDir = "${buildDir}/asciidoc"
}

tasks.register('apiDocs', Copy) {
from groovydoc.outputs.files
into file("${buildDir}/asciidoc/api")
}

asciidoctor.dependsOn(apiDocs)

tasks.register('snapshotVersion') {
doLast {
if (isReleaseVersion) {
ant.propertyfile(file: "gradle.properties") {
entry(key: "version", value: "${project.version}-SNAPSHOT")
}
}
}
}
Loading

0 comments on commit 59f45cb

Please sign in to comment.