Skip to content

Commit

Permalink
Testing, release artefacts, cleanup and README.md
Browse files Browse the repository at this point in the history
  • Loading branch information
sbglasius committed Feb 6, 2024
1 parent 6001034 commit c994bbf
Show file tree
Hide file tree
Showing 18 changed files with 416 additions and 363 deletions.
28 changes: 28 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# This workflow will build a Java project with Gradle and cache/restore any dependencies to improve the workflow execution time
# For more information see: https://help.github.com/actions/language-and-framework-guides/building-and-testing-java-with-gradle

name: Build

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

jobs:
build:

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
- name: Set up JDK 8
uses: actions/setup-java@v2
with:
java-version: '8'
distribution: 'adopt'
cache: gradle
- name: Grant execute permission for gradlew
run: chmod +x gradlew
- name: Build with Gradle
run: ./gradlew build
64 changes: 64 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
name: Release
on:
release:
types: [ published ]
jobs:
release:
runs-on: ubuntu-latest
env:
GIT_USER_NAME: ${{ secrets.GIT_USER_NAME }}
GIT_USER_EMAIL: ${{ secrets.GIT_USER_EMAIL }}
steps:
- name: Checkout repository
uses: actions/checkout@v2
with:
token: ${{ secrets.GH_TOKEN }}
- uses: gradle/wrapper-validation-action@v1
- name: Set up JDK
uses: actions/setup-java@v1
with:
java-version: 8
- name: Get latest release version number
id: get_version
uses: battila7/get-version-action@v2
- name: Run pre-release
uses: micronaut-projects/github-actions/pre-release@master
with:
token: ${{ secrets.GITHUB_TOKEN }}
- name: Publish to Sonatype OSSRH
env:
SONATYPE_USERNAME: ${{ secrets.SONATYPE_USERNAME }}
SONATYPE_PASSWORD: ${{ secrets.SONATYPE_PASSWORD }}
SONATYPE_STAGING_PROFILE_ID: ${{ secrets.SONATYPE_STAGING_PROFILE_ID }}
SIGNING_KEY_ID: ${{ secrets.SIGNING_KEY_ID }}
SIGNING_PASSPHRASE: ${{ secrets.SIGNING_PASSPHRASE }}
SECRING_FILE: ${{ secrets.SECRING_FILE }}
RELEASE_VERSION: ${{ steps.get_version.outputs.version-without-v }}
run: |
echo "${SECRING_FILE}" | base64 -d > "${GITHUB_WORKSPACE}/secring.gpg"
echo "Publishing Artifacts for $RELEASE_VERSION"
(set -x; ./gradlew -Pversion="${RELEASE_VERSION}" -Psigning.secretKeyRingFile="${GITHUB_WORKSPACE}/secring.gpg" publishToSonatype closeAndReleaseSonatypeStagingRepository --no-daemon)
- name: Bump patch version by one
uses: actions-ecosystem/action-bump-semver@v1
id: bump_semver
with:
current_version: ${{steps.get_version.outputs.version-without-v }}
level: patch
- name: Set version in gradle.properties
env:
NEXT_VERSION: ${{ steps.bump_semver.outputs.new_version }}
run: |
echo "Preparing next snapshot"
./gradlew snapshotVersion -Pversion="${NEXT_VERSION}"
- name: Commit & Push changes
uses: actions-js/push@master
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
author_name: ${{ secrets.GIT_USER_NAME }}
author_email: $${ secrets.GIT_USER_EMAIL }}
message: 'Set version to next SNAPSHOT'
- name: Run post-release
if: success()
uses: micronaut-projects/github-actions/post-release@master
with:
token: ${{ secrets.GITHUB_TOKEN }}
116 changes: 96 additions & 20 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -7,32 +7,26 @@ buildscript {
classpath "org.grails:grails-gradle-plugin:$grailsGradlePluginVersion"
}
}
plugins {
id("io.github.gradle-nexus.publish-plugin") version "1.3.0"
id 'maven-publish'
id 'signing'
}
group "io.github.gpc"

version "0.1"
group "dk.glasius.phone"

apply plugin:"org.grails.grails-plugin"
apply plugin: "org.grails.grails-plugin"

repositories {
mavenCentral()
maven { url "https://repo.grails.org/grails/core" }
}

configurations {
developmentOnly
runtimeClasspath {
extendsFrom developmentOnly
}
}

dependencies {
developmentOnly("org.springframework.boot:spring-boot-devtools")
console "org.grails:grails-console"
implementation "org.springframework.boot:spring-boot-starter-logging"
implementation "org.springframework.boot:spring-boot-starter-validation"
implementation "org.springframework.boot:spring-boot-autoconfigure"
implementation "org.grails:grails-core"

compileOnly "org.grails:grails-plugin-domain-class"
implementation 'com.googlecode.libphonenumber:libphonenumber:8.13.29'

Expand All @@ -45,23 +39,105 @@ dependencies {
bootRun {
ignoreExitValue true
jvmArgs(
'-Dspring.output.ansi.enabled=always',
'-noverify',
'-XX:TieredStopAtLevel=1',
'-Xmx1024m')
'-Dspring.output.ansi.enabled=always',
'-noverify',
'-XX:TieredStopAtLevel=1',
'-Xmx1024m')
sourceResources sourceSets.main
String springProfilesActive = 'spring.profiles.active'
systemProperty springProfilesActive, System.getProperty(springProfilesActive)
}

tasks.withType(GroovyCompile) {
tasks.withType(GroovyCompile).configureEach {
configure(groovyOptions) {
forkOptions.jvmArgs = ['-Xmx1024m']
}
}

tasks.withType(Test) {
tasks.withType(Test).configureEach {
useJUnitPlatform()
}
// enable if you wish to package this plugin as a standalone application
bootJar.enabled = false

publishing {
publications {
maven(MavenPublication) {
groupId = project.group
artifactId = 'phone-number-constraint'
version = project.version

from components.java
artifact sourcesJar
artifact javadocJar

pom {
name = 'phone-number-constraint'
description = "This plugin establishes a 'phoneNumber' constraint for validateable objects."
url = 'https://github.com/gpc/grails-phone-number-constraint'
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/grails-phone-number-constraint.git'
developerConnection = 'scm:git:ssh://github.com:gpc/grails-phone-number-constraint.git'
url = 'https://github.com/gpc/grails-phone-number-constraint/tree/main'
}
}
}
}
}

ext."signing.keyId" = project.findProperty('signing.keyId') ?: System.getenv('SIGNING_KEY_ID')
ext."signing.password" = project.findProperty('signing.password') ?: System.getenv('SIGNING_PASSPHRASE')
ext."signing.secretKeyRingFile" = project.findProperty('signing.secretKeyRingFile') ?: (System.getenv('SIGNING_PASSPHRASE') ?: "${System.getProperty('user.home')}/.gnupg/secring.gpg")

ext.isReleaseVersion = !version.endsWith("SNAPSHOT")

afterEvaluate {
signing {
required { isReleaseVersion }
sign publishing.publications.maven
}
}

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

nexusPublishing {
repositories {
sonatype {
def ossUser = System.getenv('SONATYPE_USERNAME') ?: project.findProperty('sonatypeOss2Username') ?: ''
def ossPass = System.getenv('SONATYPE_PASSWORD') ?: project.findProperty("sonatypeOss2Password") ?: ''
def ossStagingProfileId = System.getenv('SONATYPE_STAGING_PROFILE_ID') ?: project.findProperty("sonatypeOssStagingProfileId") ?: ''

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
}
}
}

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

2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
grailsVersion=5.3.6
grailsGradlePluginVersion=5.3.1
groovyVersion=3.0.11
gorm.version=7.3.4
version=1.0.0-SNAPSHOT
org.gradle.daemon=true
org.gradle.parallel=true
org.gradle.jvmargs=-Dfile.encoding=UTF-8 -Xmx1024M
2 changes: 1 addition & 1 deletion grails-app/i18n/messages.properties
Original file line number Diff line number Diff line change
@@ -1 +1 @@
default.invalid.phone.message=Property [{0}] of class [{1}] with value [{2}] does not pass phone number validation
default.invalid.phoneNumber.message=Property [{0}] of class [{1}] with value [{2}] does not pass phone-number validation
5 changes: 3 additions & 2 deletions grails-app/init/dk/glasius/phoneconstraint/Application.groovy
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
package dk.glasius.phoneconstraint

import grails.boot.*
import grails.boot.GrailsApp
import grails.boot.config.GrailsAutoConfiguration
import grails.plugins.metadata.*
import grails.plugins.metadata.PluginSource

@PluginSource
class Application extends GrailsAutoConfiguration {

static void main(String[] args) {
GrailsApp.run(Application, args)
}
Expand Down
9 changes: 0 additions & 9 deletions grails-app/init/dk/glasius/phoneconstraint/BootStrap.groovy

This file was deleted.

Binary file removed grails-wrapper.jar
Binary file not shown.
Loading

0 comments on commit c994bbf

Please sign in to comment.