Skip to content

Commit 1dbeb30

Browse files
duncancrawfordmaheshsubramanian
authored andcommitted
Publish to public Azure Artefact
1 parent 166adc5 commit 1dbeb30

File tree

3 files changed

+38
-23
lines changed

3 files changed

+38
-23
lines changed

.github/workflows/ci-draft.yml

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,8 @@ jobs:
136136
- name: Gradle Build and Publish on Push [Merge]
137137
env:
138138
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
139+
AZURE_DEVOPS_ARTIFACT_USERNAME: ${{ secrets.AZURE_DEVOPS_ARTIFACT_USERNAME }}
140+
AZURE_DEVOPS_ARTIFACT_TOKEN: ${{ secrets.AZURE_DEVOPS_ARTIFACT_TOKEN }}
139141
run: |
140142
VERSION=${{ needs.Artefact-Version.outputs.draft_version }}
141143
@@ -151,7 +153,9 @@ jobs:
151153
-DAPI_SPEC_VERSION=$VERSION \
152154
-DGITHUB_REPOSITORY=${{ github.repository }} \
153155
-DGITHUB_ACTOR=${{ github.actor }} \
154-
-DGITHUB_TOKEN=$GITHUB_TOKEN
156+
-DGITHUB_TOKEN=$GITHUB_TOKEN \
157+
-DAZURE_DEVOPS_ARTIFACT_USERNAME=$HMCTS_ARTEFACT_ACTOR \
158+
-DAZURE_DEVOPS_ARTIFACT_TOKEN=$AZURE_DEVOPS_ARTIFACT_TOKEN
155159
else
156160
echo "Skipping publish because this is a pull_request"
157-
fi
161+
fi

.github/workflows/ci-released.yml

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -89,11 +89,15 @@ jobs:
8989
- name: Gradle Build and Publish
9090
env:
9191
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
92+
AZURE_DEVOPS_ARTIFACT_USERNAME: ${{ secrets.AZURE_DEVOPS_ARTIFACT_USERNAME }}
93+
AZURE_DEVOPS_ARTIFACT_TOKEN: ${{ secrets.AZURE_DEVOPS_ARTIFACT_TOKEN }}
9294
run: |
9395
VERSION=${{ needs.Artefact-Version.outputs.RELEASED_VERSION }}
9496
95-
gradle build publish \
96-
-DAPI_SPEC_VERSION=$VERSION \
97-
-DGITHUB_REPOSITORY=${{ github.repository }} \
98-
-DGITHUB_ACTOR=${{ github.actor }} \
99-
-DGITHUB_TOKEN=$GITHUB_TOKEN
97+
gradle publish \
98+
-DAPI_SPEC_VERSION=$VERSION \
99+
-DGITHUB_REPOSITORY=${{ github.repository }} \
100+
-DGITHUB_ACTOR=${{ github.actor }} \
101+
-DGITHUB_TOKEN=$GITHUB_TOKEN \
102+
-DAZURE_DEVOPS_ARTIFACT_USERNAME=$HMCTS_ARTEFACT_ACTOR \
103+
-DAZURE_DEVOPS_ARTIFACT_TOKEN=$AZURE_DEVOPS_ARTIFACT_TOKEN

build.gradle

Lines changed: 23 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ plugins {
55
id 'jacoco'
66
id 'maven-publish'
77
id "com.github.ben-manes.versions" version "0.52.0"
8-
id "org.cyclonedx.bom" version "2.3.0"
8+
id "org.cyclonedx.bom" version "2.3.1"
99
}
1010

1111
group = 'uk.gov.hmcts.dcs'
@@ -15,25 +15,17 @@ def githubToken = project.findProperty("github.token") ?: System.getenv("GITHUB_
1515
def githubRepo = System.getenv("GITHUB_REPOSITORY")
1616

1717
def formatterUrl = 'https://raw.githubusercontent.com/hmcts/api-cp-code-style/refs/heads/master/config/formatter/eclipse-formatter.xml'
18-
def formatterPath = "$buildDir/eclipse-formatter.xml"
18+
def formatterPath = "${layout.buildDirectory.get().asFile.absolutePath}/eclipse-formatter.xml"
1919

2020
java {
2121
sourceCompatibility = JavaVersion.VERSION_17
2222
targetCompatibility = JavaVersion.VERSION_17
2323
}
2424

25-
repositories {
26-
mavenLocal()
27-
mavenCentral()
28-
maven {
29-
url = 'https://jitpack.io'
30-
}
31-
}
32-
3325
openApiGenerate {
3426
generatorName = "java"
3527
inputSpec = "${rootDir}/src/main/resources/openapi/dcs-caseadmin.openapi.yml"
36-
outputDir = "$buildDir/generated/sources/openapi"
28+
outputDir = "${layout.buildDirectory.get().asFile.absolutePath}/generated/sources/openapi"
3729
modelPackage = "uk.gov.hmcts.dcs.openapi.model"
3830

3931
// Configuration options for the Java generator
@@ -55,7 +47,7 @@ openApiGenerate {
5547
sourceSets {
5648
main {
5749
java {
58-
srcDir "$buildDir/generated/sources/openapi/src/main/java"
50+
srcDir "${layout.buildDirectory.get().asFile.absolutePath}/generated/sources/openapi/src/main/java"
5951
}
6052
}
6153
}
@@ -127,6 +119,14 @@ tasks.named("dependencyUpdates").configure {
127119
}
128120
}
129121

122+
repositories {
123+
mavenLocal()
124+
mavenCentral()
125+
maven {
126+
url = azureADOArtifactRepository
127+
}
128+
}
129+
130130
publishing {
131131
publications {
132132
mavenJava(MavenPublication) {
@@ -142,6 +142,14 @@ publishing {
142142
password = githubToken
143143
}
144144
}
145+
maven {
146+
name = "AzureArtifacts"
147+
url = uri(azureADOArtifactRepository)
148+
credentials {
149+
username = azureADOArtifactActor
150+
password = azureADOArtifactToken
151+
}
152+
}
145153
}
146154
}
147155

@@ -153,7 +161,7 @@ cyclonedxBom {
153161
skipConfigs = ["test", "testImplementation"]
154162
schemaVersion = "1.6"
155163
componentVersion = providers.provider { project.version.toString() }
156-
destination = file("$buildDir/reports")
164+
destination = file("${layout.buildDirectory.get().asFile.absolutePath}/reports")
157165
includeBuildSystem = true
158166
outputName = "bom"
159167
outputFormat = "json"
@@ -169,8 +177,7 @@ jar {
169177
} else {
170178
println "⚠️ CHANGELOG.md not found, skipping inclusion in JAR"
171179
}
172-
173-
def sbomFile = file("$buildDir/reports/bom.json")
180+
def sbomFile = file("${layout.buildDirectory.get().asFile.absolutePath}/reports/bom.json")
174181
if (sbomFile.exists()) {
175182
println "✅ Including SBOM from ${sbomFile} in JAR"
176183
from(sbomFile) {
@@ -216,7 +223,7 @@ tasks.register('downloadFormatter') {
216223
}
217224

218225
tasks.withType(Checkstyle).configureEach {
219-
def generatedDir = file("${buildDir}/generated/sources/openapi/src/main/java").canonicalPath
226+
def generatedDir = file("${layout.buildDirectory.get().asFile.absolutePath}/generated/sources/openapi/src/main/java").canonicalPath
220227
source = source.filter { file ->
221228
!file.canonicalPath.startsWith(generatedDir)
222229
}

0 commit comments

Comments
 (0)