Skip to content

Commit

Permalink
Migrate plugin to Gradle build and GH actions release
Browse files Browse the repository at this point in the history
  • Loading branch information
chadlwilson committed Nov 12, 2022
1 parent ce8ff05 commit 153a80d
Show file tree
Hide file tree
Showing 16 changed files with 548 additions and 158 deletions.
9 changes: 7 additions & 2 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,13 @@
version: 2
updates:
- package-ecosystem: maven
- package-ecosystem: gradle
directory: "/"
schedule:
interval: weekly
day: friday
open-pull-requests-limit: 99
- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: weekly
day: friday
open-pull-requests-limit: 10
19 changes: 19 additions & 0 deletions .github/workflows/pr_workflow.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# 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: Testing For PRs

on: [ pull_request ]

jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Set up JDK
uses: actions/setup-java@v3
with:
java-version: 17
distribution: temurin
- name: Build with Gradle
run: ./gradlew assemble check
32 changes: 32 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@

name: Create Stable Release

# Controls when the action will run. Workflow runs when manually triggered using the UI
# or API.
on:
workflow_dispatch:
# Inputs the workflow accepts.
inputs:
prerelease:
description: 'The release should be an experimental release'
default: 'NO'
required: true

jobs:
build_and_release:
runs-on: ubuntu-latest
env:
GITHUB_USER: "gocd-contrib"
GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
PRERELEASE: "${{ github.event.inputs.prerelease }}"
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Set up JDK
uses: actions/setup-java@v3
with:
java-version: 17
distribution: temurin
- name: Release
run: ./gradlew githubRelease
38 changes: 38 additions & 0 deletions .github/workflows/test_and_build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# 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: Test and Build

on:
push:
branches: [ master ]

jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Set up JDK
uses: actions/setup-java@v3
with:
java-version: 17
distribution: temurin
- name: Test with Gradle
run: ./gradlew assemble check
previewGithubRelease:
needs: test
runs-on: ubuntu-latest
env:
GITHUB_USER: "gocd-contrib"
GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Set up JDK
uses: actions/setup-java@v3
with:
java-version: 17
distribution: temurin
- name: Test with Gradle
run: ./gradlew githubRelease
14 changes: 14 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,17 @@ hs_err_pid*
log/
target/
dist/


# gradle's output dir
build/

# the gradle temp dir
.gradle

# Avoid ignoring Gradle wrapper jar file (.jar files are usually ignored)
!gradle-wrapper.jar

classes/
out
src/main/resources-generated
84 changes: 84 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
/*
* Copyright 2022 Thoughtworks, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

apply plugin: 'java'
apply from: "https://raw.githubusercontent.com/gocd/gocd-plugin-gradle-task-helpers/master/helper.gradle?_=${(int) (new Date().toInstant().epochSecond / 60)}"

gocdPlugin {
id = 'script-executor'
pluginVersion = '1.0.2'
goCdVersion = '20.1.0'
name = 'Script Executor'
description = 'Thoughtworks GoCD plugin to run scripts'
vendorName = 'Srinivas Upadhya'
vendorUrl = 'https://github.com/gocd-contrib/script-executor-task'

githubRepo {
owner = System.getenv('GITHUB_USER') ?: 'bob'
repo = 'script-executor-task'
token = System.getenv('GITHUB_TOKEN') ?: 'bad-token'
}

pluginProject = project

prerelease = !"No".equalsIgnoreCase(System.getenv('PRERELEASE'))
assetsToRelease = [project.tasks.jar]
}

sourceCompatibility = 1.11
targetCompatibility = 1.11

allprojects {
group = 'cd.go.contrib'
version = gocdPlugin.fullVersion(project)
}

repositories {
mavenCentral()
}

ext {
deps = [
gocdPluginApi: 'cd.go.plugin:go-plugin-api:22.3.0',
]

versions = project.ext.deps.collectEntries { lib, libGav -> [lib, libGav.split(':').last()] }
}

dependencies {
compileOnly project.deps.gocdPluginApi
implementation group: 'com.google.code.gson', name: 'gson', version: '2.10'
implementation group: 'commons-io', name: 'commons-io', version: '2.11.0'

testImplementation platform('org.junit:junit-bom:5.9.1')
testImplementation group: 'org.junit.jupiter', name: 'junit-jupiter-api'
testImplementation group: 'org.junit.jupiter', name: 'junit-jupiter-params'
testRuntimeOnly group: 'org.junit.jupiter', name: 'junit-jupiter-engine'

testImplementation group: 'org.mockito', name: 'mockito-core', version: '4.8.1'
testImplementation group: 'org.assertj', name: 'assertj-core', version: '3.23.1'
testImplementation group: 'cd.go.plugin', name: 'go-plugin-api', version: project.versions.gocdPluginApi
}

test {
useJUnitPlatform()
}

jar {
from(configurations.runtimeClasspath) {
into "lib/"
}
}
Binary file added gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
6 changes: 6 additions & 0 deletions gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionSha256Sum=97a52d145762adc241bad7fd18289bf7f6801e08ece6badf80402fe2b9f250b1
distributionUrl=https\://services.gradle.org/distributions/gradle-7.5-all.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
Loading

0 comments on commit 153a80d

Please sign in to comment.