Skip to content

Commit

Permalink
Merge pull request #3 from wiremock/release-flow
Browse files Browse the repository at this point in the history
Adopt WireMock Extension Gradle convention plugin + Automate releases
  • Loading branch information
oleg-nenashev authored Nov 30, 2023
2 parents 8bd3709 + 261557b commit 472eff0
Show file tree
Hide file tree
Showing 5 changed files with 77 additions and 97 deletions.
2 changes: 2 additions & 0 deletions .github/release-drafter.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Use https://github.com/wiremock/.github/blob/main/.github/release_drafter.yml
_extends: .github
22 changes: 22 additions & 0 deletions .github/workflows/changelog-draft.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
name: Release Drafter

on:
push:
branches:
- develop
workflow_dispatch:

jobs:
update_release_draft:
permissions:
contents: write
pull-requests: write
runs-on: ubuntu-latest
steps:
- uses: release-drafter/release-drafter@v5
with:
name: next
tag: next
version: next
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
40 changes: 40 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
name: Release

on:
release:
types: [published]

jobs:
publish:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
- uses: actions/checkout@v3
- name: Set up Java
uses: actions/setup-java@v3
with:
java-version: '11'
distribution: 'adopt'
- name: Validate Gradle wrapper
uses: gradle/wrapper-validation-action@v1

- name: Determine new version
id: new_version
run: |
NEW_VERSION=$(echo "${GITHUB_REF}" | cut -d "/" -f3)
echo "new_version=${NEW_VERSION}" >> $GITHUB_OUTPUT
- name: Publish package
id: publish_package
uses: gradle/[email protected]
with:
arguments: -Pversion=${{ steps.new_version.outputs.new_version }} publish closeAndReleaseStagingRepository

env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
OSSRH_USERNAME: ${{ secrets.OSSRH_USERNAME }}
OSSRH_TOKEN: ${{ secrets.OSSRH_TOKEN }}
OSSRH_GPG_SECRET_KEY: ${{ secrets.OSSRH_GPG_SECRET_KEY }}
OSSRH_GPG_SECRET_KEY_PASSWORD: ${{ secrets.OSSRH_GPG_SECRET_KEY_PASSWORD }}
103 changes: 6 additions & 97 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -8,52 +8,23 @@ buildscript {
}

plugins {
id 'java-library'
id 'signing'
id 'maven-publish'
id 'idea'
id 'eclipse'
id 'project-report'
id 'com.diffplug.spotless' version '6.21.0'
id 'org.wiremock.tools.gradle.wiremock-extension-convention' version '0.1.1'
}

repositories {
mavenLocal()
mavenCentral()
}

group 'org.wiremock'
version = "0.1.0"

allprojects {
sourceCompatibility = 11
targetCompatibility = 11

projects {
ext {
versions = [
wiremock: "3.2.0"
wiremock: "3.3.1"
]

repoUser = this.hasProperty('sonatypeUser') ? sonatypeUser : 'default'
repoPassword = this.hasProperty('sonatypePassword') ? sonatypePassword : 'default'

pomInfo = {
name 'WireMock Extension for Faker'
url 'https://wiremock.org'
scm {
// TODO setup
connection 'https://github.com/wiremock/wiremock-grpc-extension.git'
developerConnection 'https://github.com/wiremock/wiremock-grpc-extension.git'
url 'https://github.com/wiremock/wiremock-grpc-extension'
}
licenses {
license {
name 'The Apache Software License, Version 2.0'
url 'http://www.apache.org/license/LICENSE-2.0.txt'
distribution 'repo'
}
}
}
}
}

Expand Down Expand Up @@ -88,66 +59,16 @@ dependencies {
// 1.x is not maintained but we need to use to support Java 11. It is in a better state than java-faker, which is also not maintained. Bump to 2.x once we deprecate support for Java 11.
implementation 'net.datafaker:datafaker:1.7.0'

// testImplementation project(":")
testImplementation(platform('org.junit:junit-bom:5.10.0'))
testImplementation "org.junit.jupiter:junit-jupiter"
testImplementation "org.hamcrest:hamcrest-core:2.2"
testImplementation "org.hamcrest:hamcrest-library:2.2"
testImplementation 'org.awaitility:awaitility:4.2.0'
testImplementation("org.wiremock:wiremock:$versions.wiremock") {
artifact {
classifier = 'tests'
}
}
}

task sourcesJar(type: Jar, dependsOn: classes) {
archiveClassifier.set('sources')
from sourceSets.main.allSource
}

task javadocJar(type: Jar, dependsOn: javadoc) {
archiveClassifier.set('javadoc')
from javadoc.destinationDir
}

task testJar(type: Jar, dependsOn: testClasses) {
archiveClassifier.set('tests')
from sourceSets.test.output
}

signing {
required {
!version.toString().contains("SNAPSHOT") && (gradle.taskGraph.hasTask("uploadArchives") || gradle.taskGraph.hasTask("publish"))
}
sign publishing.publications
}

publishing {
repositories {
maven {
url 'https://oss.sonatype.org/service/local/staging/deploy/maven2'
credentials {
username repoUser
password repoPassword
}
}
}

publications {
main(MavenPublication) { publication ->
from components.java
artifact sourcesJar
artifact javadocJar
artifact testJar

pom.packaging 'jar'
pom.withXml {
asNode().appendNode('description', 'Add fake data to WireMock responses')
asNode().children().last() + pomInfo
}
}
}
shadowJar {
relocate "com.github.jknack", 'wiremock.com.github.jknack'
relocate "net.datafaker", 'wiremock.net.datafaker'
}

test {
Expand All @@ -157,15 +78,3 @@ test {
exceptionFormat "full"
}
}

project.tasks.signMainPublication.dependsOn jar

assemble.dependsOn clean, jar

task release {
dependsOn clean, assemble, publishAllPublicationsToMavenRepository
}

task localRelease {
dependsOn clean, assemble, publishToMavenLocal
}
7 changes: 7 additions & 0 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
baseArtifact = wiremock-faker-extension
version = 1.0.0-SNAPSHOT
description = Uses https://github.com/datafaker-net/datafaker to generate random, fake data for using in WireMock responses
githubRepo = wiremock-faker-extension
developer.id=Shreya-7
developer.name=Shreya Agarwal
developer.email[email protected]

0 comments on commit 472eff0

Please sign in to comment.