diff --git a/.github/workflows/publish_artifact.yml b/.github/workflows/publish_artifact.yml new file mode 100644 index 00000000..a48a5f1f --- /dev/null +++ b/.github/workflows/publish_artifact.yml @@ -0,0 +1,26 @@ +trigger: + tags: + include: + - '*' + +pr: none + +pool: + vmImage: 'ubuntu-latest' + +variables: + artifactVersion: $[replace(variables['Build.SourceBranch'], 'refs/tags/', '')] + +resources: + repositories: + - repository: cnp-azuredevops-libraries + type: github + ref: refs/heads/azure-artifact-stage + name: hmcts/cnp-azuredevops-libraries + endpoint: 'hmcts' + +jobs: + - job: PublishToAzureArtifacts + displayName: 'Publish to Azure Artifacts' + steps: + - template: steps/publish-ado-artifact.yaml@cnp-azuredevops-libraries \ No newline at end of file diff --git a/build.gradle b/build.gradle index a813f854..ca8cd2f9 100644 --- a/build.gradle +++ b/build.gradle @@ -3,7 +3,18 @@ plugins { id 'com.github.ben-manes.versions' version '0.52.0' } -def buildNumber = System.getenv("RELEASE_VERSION")?.replace("refs/tags/", "") ?: "DEV-SNAPSHOT" +def buildNumber + +if (System.getenv("BUILD_REASON")?.contains("Manual")) { + def id = System.currentTimeMillis() + // Need to add a timestamp for dev builds as ADO artifacts are immutable, subsequent manual runs would cause build failure + buildNumber = "DEV-SNAPSHOT-${id}" +} else { + // If building based on new tag + buildNumber = System.getenv("RELEASE_VERSION")?.replace("refs/tags/", "") ?: "DEV-SNAPSHOT" +} + +println("Version to be published is: ${buildNumber}") allprojects { group 'com.github.hmcts.java-logging' @@ -109,6 +120,17 @@ publishing { version project.version } } + + repositories { + maven { + name = "AzureArtifacts" + url = uri("https://pkgs.dev.azure.com/hmcts/Artifacts/_packaging/hmcts-lib/maven/v1") + credentials { + username = System.getenv("AZURE_DEVOPS_ARTIFACT_USERNAME") + password = System.getenv("AZURE_DEVOPS_ARTIFACT_TOKEN") + } + } + } } dependencies {