Skip to content

Commit

Permalink
Merge pull request #25 from KPMP/develop
Browse files Browse the repository at this point in the history
Release v1.5
  • Loading branch information
rlreamy committed Apr 11, 2024
2 parents d9b6f1b + 5307f7c commit fa338e9
Show file tree
Hide file tree
Showing 3 changed files with 76 additions and 12 deletions.
49 changes: 49 additions & 0 deletions .github/workflows/build-gradle-project.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
name: Build cassiopeia-data docker image

on:
push:

jobs:
build-gradle-project:
env:
IMAGE_TAG: 1.5
runs-on: ubuntu-latest
steps:
- name: Get branch names
id: branch-names
uses: tj-actions/branch-names@v8

- name: Get current branch name
if: steps.branch-names.outputs.is_default == 'false'
run: |
echo "Running on branch: ${{ steps.branch-names.outputs.current_branch }}"
- name: Checkout project sources
uses: actions/checkout@v3
- uses: actions/setup-java@v3
with:
java-version: '8'
distribution: 'temurin'
- name: Setup Gradle
uses: gradle/gradle-build-action@v2
with:
gradle-version: 7.4

- name: Login to Docker Hub
uses: docker/login-action@f4ef78c080cd8ba55a85445d5b36e214a81df20a
with:
username: ${{ secrets.ENV_DOCKER_USER }}
password: ${{ secrets.ENV_DOCKER_PASS }}

- name: Run build with Gradle Wrapper
run: |
./gradlew build docker
- name: Push to Docker Hub if branch is develop
if: steps.branch-names.outputs.current_branch == 'develop'
run: |
docker push "kingstonduo/cassiopeia-data:$IMAGE_TAG"
- name: Push to Docker Hub if branch is not develop
if: ${{ !steps.branch-names.outputs.current_branch == 'develop' }}
run: |
docker push "kingstonduo/cassiopeia-data:${{ steps.branch-names.outputs.current_branch }}"
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@ Repo for the WSI viewer backend.
# Build

`./gradlew build docker`
The default tag is `latest` if no verison is provided
The default tag is the branch name if no verison is provided
To pass a version when building the docker image execute
`./gradlew build docker -Ptag=<tagNumber>`
37 changes: 26 additions & 11 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -11,18 +11,18 @@ plugins {
id 'com.palantir.docker' version '0.22.1'
}

group = 'kingstonduo'

apply plugin: 'java'
apply plugin: 'eclipse'
apply plugin: 'idea'
apply plugin: 'org.springframework.boot'
apply plugin: 'io.spring.dependency-management'
apply plugin: 'com.palantir.docker'

group = 'kingstonduo'

bootJar {
archiveBaseName = 'cassiopeia-data'
archiveVersion = '1.2'
jar {
baseName = 'cassiopeia-data'
version = '1.5'
}

repositories {
Expand Down Expand Up @@ -57,16 +57,31 @@ task unpack(type: Copy) {
}

def getTagInfo() {
if (project.hasProperty('tag')) {
def tagValue = project.property('tag')
return tagValue
} else {
return "latest"
if (project.hasProperty('tag')) {
def tagValue = project.property('tag')
return tagValue
} else {
def gitBranch = "Unknown branch"
try {
def workingDir = new File("${project.projectDir}")
def result = 'git rev-parse --abbrev-ref HEAD'.execute(null, workingDir)
result.waitFor()
if (result.exitValue() == 0) {
gitBranch = result.text.trim()
}
} catch (e) {
}
if (gitBranch == "develop" || gitBranch == "master"){
return "${jar.version}"
}else{
return gitBranch
}
return gitBranch
}
}

docker {
name "${project.group}/${jar.baseName}:" + getTagInfo()
name "kingstonduo/cassiopeia-data:" + getTagInfo()
copySpec.from(tasks.unpack.outputs).into("dependency")
buildArgs(['DEPENDENCY': "dependency"])
}

0 comments on commit fa338e9

Please sign in to comment.