Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[TH2-4566] Reusable workflow #211

Open
wants to merge 1 commit into
base: version-3.2
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
64 changes: 27 additions & 37 deletions .github/workflows/dev-java-publish-sonatype.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,46 +5,36 @@ on:
branches-ignore:
- master
- version-*
# paths:
# - gradle.properties

jobs:
build:
build-job:
uses: th2-net/.github/.github/workflows/compound-java-dev.yml@main
with:
scanner-enabled: false
build-target: 'Sonatype'
runsOn: ubuntu-latest
secrets:
sonatypeUsername: ${{ secrets.SONATYPE_NEXUS_USERNAME }}
sonatypePassword: ${{ secrets.SONATYPE_NEXUS_PASSWORD }}
sonatypeSigningKey: ${{ secrets.SONATYPE_GPG_ARMORED_KEY }}
sonatypeSigningPassword: ${{ secrets.SONATYPE_SIGNING_PASSWORD }}
scan-job:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
# Prepare custom build version
- name: Get branch name
id: branch
run: echo ::set-output name=branch_name::${GITHUB_REF#refs/*/}
- name: Get release_version
id: ver
uses: christian-draeger/[email protected]
with:
path: gradle.properties
property: release_version
- name: Build custom release version
id: release_ver
run: echo ::set-output name=value::"${{ steps.ver.outputs.value }}-${{ steps.branch.outputs.branch_name }}-${{ github.run_id }}-SNAPSHOT"
- name: Write custom release version to file
uses: christian-draeger/[email protected]
- name: Checkout code
uses: actions/checkout@v3
- name: Create lockfiles
run: ./gradlew createLockFiles
- name: Run Trivy vulnerability scanner in repo mode
uses: aquasecurity/trivy-action@master
with:
path: gradle.properties
property: release_version
value: ${{ steps.release_ver.outputs.value }}
- name: Show custom release version
run: echo ${{ steps.release_ver.outputs.value }}
# Build and publish package
- name: Set up JDK 11
uses: actions/setup-java@v1
scan-type: 'fs'
ignore-unfixed: false
format: 'sarif'
output: 'trivy-results.sarif'
severity: 'CRITICAL,HIGH,MEDIUM'
exit-code: '0'
- name: Upload Trivy scan results to GitHub Security tab
uses: github/codeql-action/upload-sarif@v2
with:
java-version: '11'
- name: Build with Gradle
run: ./gradlew --info clean build publish
env:
ORG_GRADLE_PROJECT_sonatypeUsername: ${{ secrets.SONATYPE_NEXUS_USERNAME }}
ORG_GRADLE_PROJECT_sonatypePassword: ${{ secrets.SONATYPE_NEXUS_PASSWORD }}
ORG_GRADLE_PROJECT_signingKey: ${{ secrets.SONATYPE_GPG_ARMORED_KEY }}
ORG_GRADLE_PROJECT_signingPassword: ${{ secrets.SONATYPE_SIGNING_PASSWORD }}

sarif_file: 'trivy-results.sarif'
40 changes: 27 additions & 13 deletions .github/workflows/java-publish-sonatype.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
name: Build and release Java distributions to sonatype.

on:
push:
branches:
Expand All @@ -10,18 +9,33 @@ on:

jobs:
build:
uses: th2-net/.github/.github/workflows/compound-java.yml@main
with:
scanner-enabled: false
build-target: 'Sonatype'
runsOn: ubuntu-latest
secrets:
sonatypeUsername: ${{ secrets.SONATYPE_NEXUS_USERNAME }}
sonatypePassword: ${{ secrets.SONATYPE_NEXUS_PASSWORD }}
sonatypeSigningKey: ${{ secrets.SONATYPE_GPG_ARMORED_KEY }}
sonatypeSigningPassword: ${{ secrets.SONATYPE_SIGNING_PASSWORD }}
scan-job:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
- name: Set up JDK 11
uses: actions/setup-java@v1
- name: Checkout code
uses: actions/checkout@v3
- name: Create lockfiles
run: ./gradlew createLockFiles
- name: Run Trivy vulnerability scanner in repo mode
uses: aquasecurity/trivy-action@master
with:
scan-type: 'fs'
ignore-unfixed: false
format: 'sarif'
output: 'trivy-results.sarif'
severity: 'CRITICAL,HIGH,MEDIUM'
exit-code: '0'
- name: Upload Trivy scan results to GitHub Security tab
uses: github/codeql-action/upload-sarif@v2
with:
java-version: '11'
- name: Build with Gradle
run: ./gradlew --info clean build publish closeAndReleaseSonatypeStagingRepository
env:
ORG_GRADLE_PROJECT_sonatypeUsername: ${{ secrets.SONATYPE_NEXUS_USERNAME }}
ORG_GRADLE_PROJECT_sonatypePassword: ${{ secrets.SONATYPE_NEXUS_PASSWORD }}
ORG_GRADLE_PROJECT_signingKey: ${{ secrets.SONATYPE_GPG_ARMORED_KEY }}
ORG_GRADLE_PROJECT_signingPassword: ${{ secrets.SONATYPE_SIGNING_PASSWORD }}
sarif_file: 'trivy-results.sarif'
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@
/cradle-cassandra/.project
/cradle-cassandra/.classpath
/cradle-cassandra/build
/cradle-cassandra/gradle/
/cradle-core/gradle/
/gradle/dependency-locks/
/cradle-core/.classpath
/cradle-core/.project
/cradle-core/.settings
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# cradleapi (3.1.0)
# cradleapi (3.2.1)

## Overview

Expand Down
38 changes: 36 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,33 @@ plugins {
}

ext {
slf4j_version = '1.7.26'
jackson_version = '2.9.7'
slf4j_version = '1.7.36'
jackson_version = '2.13.4'

sharedDir = file("${project.rootDir}/shared")
}

allprojects {
version = release_version
group = 'com.exactpro.th2'

configurations {
compileClasspath {
resolutionStrategy.activateDependencyLocking()
}
}

tasks.register('resolveAndLockAll') {
doFirst {
println gradle.startParameter.writeDependencyLocks
}
doLast {
configurations.findAll {
// Add any custom filtering on the configurations to be resolved
it.canBeResolved
}.each { it.resolve() }
}
}
}

subprojects {
Expand All @@ -29,6 +47,22 @@ subprojects {
resolutionStrategy.cacheDynamicVersionsFor 0, 'seconds'
}
}

configurations {
compileClasspath {
resolutionStrategy.activateDependencyLocking()
}
}

tasks.register('createLockFiles', Copy) {
dependsOn('resolveAndLockAll')
from "./gradle/dependency-locks/compileClasspath.lockfile"
into "./.."

rename { String filename ->
return project.name + '-' + filename
}
}


defaultTasks 'build'
Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
release_version = 3.2.0
release_version = 3.2.1
description = 'Cradle API'

vcs_url=https://github.com/th2-net/cradleapi
1 change: 1 addition & 0 deletions settings.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@ include 'cradle-cassandra'
// Defined names will be used for jar and artifact names
project(':cradle-core').name = 'cradle-core'
project(':cradle-cassandra').name = 'cradle-cassandra'
startParameter.setWriteDependencyLocks(true)