Skip to content
This repository was archived by the owner on Jan 8, 2024. It is now read-only.

Commit f6d13c6

Browse files
authored
DW-3544 - Added Circle step to upload to packages (#3)
* DW-3544 - Added Circle step to upload to packages * DW-3544 - temporarily remove pipeline dependency * DW-3544 - Fix syntax * DW-3544 - Make package upload only run on master
1 parent d74771b commit f6d13c6

4 files changed

Lines changed: 45 additions & 2 deletions

File tree

.circleci/config.yml

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,22 @@ jobs:
113113
-c ${CIRCLE_SHA1} -delete \
114114
${VERSION} ./artifacts/
115115
116+
publish-github-package:
117+
docker:
118+
- image: circleci/openjdk:11.0.3-jdk-stretch
119+
steps:
120+
- checkout
121+
- run:
122+
name: Run gradle publish
123+
command: |
124+
set -u
125+
set +o pipefail
126+
LATEST_VERSION=$(curl --silent "https://api.github.com/repos/${CIRCLE_PROJECT_USERNAME}/${CIRCLE_PROJECT_REPONAME}/releases/latest" | grep '"tag_name":' | sed -E 's/.*"([^"]+)".*/\1/')
127+
set -o pipefail
128+
[ -z "$LATEST_VERSION" ] && LATEST_VERSION="0.0.0"
129+
VERSION=$(echo $LATEST_VERSION | awk -F. '{$NF = $NF + 1;} 1' | sed 's/ /./g')
130+
./gradlew publish
131+
116132
workflows:
117133
version: 2
118134
build-and-deploy:
@@ -133,3 +149,9 @@ workflows:
133149
filters:
134150
branches:
135151
only: master
152+
- publish-github-package:
153+
requires:
154+
- publish-github-release
155+
filters:
156+
branches:
157+
only: master

README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
[![dwp](https://circleci.com/gh/dwp/dataworks-common-logging.svg?style=shield)](https://app.circleci.com/pipelines/github/dwp/dataworks-common-logging)
2+
13
# dataworks-common-logging
24
Kotlin utility library to be used in Dataworks applications to ensure common logging format.
35

@@ -17,7 +19,7 @@ repositories {
1719
}
1820
}
1921
```
20-
Where `gpr.user` or `USERNAME` resolves to your GH username and `gpr.key` or `TOKEN` resolves to a GH PAT code.
22+
Where `gpr.user` or `USERNAME` resolves to your GitHub username and `gpr.key` or `TOKEN` resolves to a GitHub PAT code with the `read:packages` privilege.
2123

2224
#### Logger configuration
2325
To utilise this library in your project, you will need to include the compiled this projects`.jar` file. You are also required to add a logback XML file in the resources for your project, and add the following code as an `appender`. This will inform the logging framework to use `LoggerLayoutAppender` to parse messages into our format.

build.gradle.kts

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
22

33
plugins {
44
kotlin("jvm") version "1.3.21"
5+
`maven-publish`
56
}
67

78
group = "uk.gov.dwp.dataworks"
@@ -11,6 +12,24 @@ repositories {
1112
jcenter()
1213
}
1314

15+
publishing {
16+
repositories {
17+
maven {
18+
name = "GitHubPackages"
19+
url = uri("https://maven.pkg.github.com/dwp/dataworks-common-logging")
20+
credentials {
21+
username = project.findProperty("gpr.user") as String? ?: System.getenv("GITHUB_USERNAME")
22+
password = project.findProperty("gpr.key") as String? ?: System.getenv("GITHUB_TOKEN")
23+
}
24+
}
25+
}
26+
publications {
27+
register("gpr", MavenPublication::class) {
28+
from(components["java"])
29+
}
30+
}
31+
}
32+
1433
configurations.all {
1534
exclude(group="org.slf4j", module="slf4j-log4j12")
1635
}

gradle.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
version=0.0.1
1+
version=1.0.0

0 commit comments

Comments
 (0)