add gradle task for creating release
This commit is contained in:
parent
18a0830c33
commit
14efdae873
2 changed files with 39 additions and 42 deletions
|
@ -56,28 +56,6 @@ test:
|
|||
reports:
|
||||
junit: build/test-results/test/TEST-*.xml
|
||||
|
||||
uberjar:
|
||||
stage: package
|
||||
rules:
|
||||
- if: $CI_PIPELINE_SOURCE != "push"
|
||||
when: never
|
||||
- if: $CI_COMMIT_TAG =~ /^release-[0-9]+[.][0-9]+([.][0-9]+)?$/
|
||||
script:
|
||||
- ./gradlew -x assemble -x test -x jar uberjarDesktop
|
||||
- ./gradlew -x assemble -x test -x jar uberjarServer
|
||||
- ./gradlew -x assemble -x test -x jar uberjarSyspec
|
||||
- cd build/libs/
|
||||
- find . -type f -exec sha256sum {} \; | sort > sha256sum.lst
|
||||
- find . -type f -exec sha512sum {} \; | sort > sha512sum.lst
|
||||
artifacts:
|
||||
paths:
|
||||
- 'build/libs/provs-desktop.jar'
|
||||
- 'build/libs/provs-server.jar'
|
||||
- 'build/libs/provs-syspec.jar'
|
||||
- 'build/libs/sha256sum.lst'
|
||||
- 'build/libs/sha512sum.lst'
|
||||
expire_in: never
|
||||
|
||||
|
||||
publish-maven-package:
|
||||
stage: publish
|
||||
|
@ -94,31 +72,14 @@ publish-maven-package:
|
|||
|
||||
|
||||
release:
|
||||
image: registry.gitlab.com/gitlab-org/release-cli:latest
|
||||
stage: release
|
||||
rules:
|
||||
- if: $CI_PIPELINE_SOURCE != "push"
|
||||
when: never
|
||||
- if: $CI_COMMIT_TAG =~ /^release-[0-9]+[.][0-9]+([.][0-9]+)?$/
|
||||
artifacts:
|
||||
paths:
|
||||
- 'build/libs/provs-desktop.jar'
|
||||
- 'build/libs/provs-server.jar'
|
||||
- 'build/libs/provs-syspec.jar'
|
||||
- 'build/libs/sha256sum.lst'
|
||||
- 'build/libs/sha512sum.lst'
|
||||
script:
|
||||
- apk --no-cache add curl
|
||||
# release to repo.meissa
|
||||
- chmod +x ./release/create-release-in-repo.sh && sh ./release/create-release-in-repo.sh
|
||||
# release to gitlab
|
||||
- |
|
||||
release-cli create --name "Release $CI_COMMIT_TAG" --tag-name $CI_COMMIT_TAG \
|
||||
--assets-link "{\"name\":\"provs-desktop.jar\",\"url\":\"https://gitlab.com/domaindrivenarchitecture/provs/-/jobs/${CI_JOB_ID}/artifacts/file/build/libs/provs-desktop.jar\"}" \
|
||||
--assets-link "{\"name\":\"provs-server.jar\",\"url\":\"https://gitlab.com/domaindrivenarchitecture/provs/-/jobs/${CI_JOB_ID}/artifacts/file/build/libs/provs-server.jar\"}" \
|
||||
--assets-link "{\"name\":\"provs-syspec.jar\",\"url\":\"https://gitlab.com/domaindrivenarchitecture/provs/-/jobs/${CI_JOB_ID}/artifacts/file/build/libs/provs-syspec.jar\"}" \
|
||||
--assets-link "{\"name\":\"sha256sum.lst\",\"url\":\"https://gitlab.com/domaindrivenarchitecture/provs/-/jobs/${CI_JOB_ID}/artifacts/file/build/libs/sha256sum.lst\"}" \
|
||||
--assets-link "{\"name\":\"sha512sum.lst\",\"url\":\"https://gitlab.com/domaindrivenarchitecture/provs/-/jobs/${CI_JOB_ID}/artifacts/file/build/libs/sha512sum.lst\"}" \
|
||||
- ./gradlew createReleaseAndUploadAssets
|
||||
|
||||
|
||||
after_script:
|
||||
- echo "---------- End CI ----------"
|
||||
|
|
38
build.gradle
38
build.gradle
|
@ -18,7 +18,7 @@ apply plugin: "maven-publish"
|
|||
|
||||
|
||||
group = "org.domaindrivenarchitecture.provs"
|
||||
version = "release-0.22.10"
|
||||
version = "release-0.22.11"
|
||||
|
||||
repositories {
|
||||
mavenCentral()
|
||||
|
@ -215,3 +215,39 @@ publishing {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
tasks.register('createReleaseAndUploadAssets') {
|
||||
dependsOn(uberjarServer, uberjarDesktop, uberjarSyspec)
|
||||
doLast {
|
||||
|
||||
def token = project.properties.get("RELEASE_TOKEN") ?: System.getenv("RELEASE_TOKEN")
|
||||
if (token == null) {
|
||||
throw new GradleException('No token found.')
|
||||
}
|
||||
|
||||
def output1 = new ByteArrayOutputStream()
|
||||
exec {
|
||||
standardOutput = output1
|
||||
def TAG = project.version
|
||||
commandLine("sh", "-c", "curl -X 'POST' 'https://repo.prod.meissa.de/api/v1/repos/meissa/provs/releases' -H 'accept: application/json' -H 'Content-Type: application/json' -d '{ \"body\": \"Provides jar-files for release $TAG\\nAttention: The \\\"Source Code\\\"-files below are not up-to-date!\", \"tag_name\": \"$TAG\" }' -H \"Authorization: token $token\"")
|
||||
}
|
||||
|
||||
def matches = output1 =~ /\{"id":(\d+?),/
|
||||
if (!matches) {
|
||||
throw new GradleException('id of release could not be parsed in: ' + output1)
|
||||
}
|
||||
|
||||
def releaseId = matches.group(1)
|
||||
println "Release=$releaseId"
|
||||
|
||||
def releaseApiUrl = "https://repo.prod.meissa.de/api/v1/repos/meissa/provs/releases"
|
||||
exec { commandLine("sh", "-c", "find build/libs/ -type f -exec sha256sum {} \\; | sort > build/libs/sha256sum.lst") }
|
||||
exec { commandLine("sh", "-c", "find build/libs/ -type f -exec sha512sum {} \\; | sort > build/libs/sha512sum.lst") }
|
||||
exec { commandLine("sh", "-c", "curl -X 'POST' '$releaseApiUrl/$releaseId/assets' -H 'accept: application/json' -H \"Authorization: token $token\" -H 'Content-Type: multipart/form-data' -F 'attachment=@/usr/local/bin/provs-desktop.jar;type=application/x-java-archive'") }
|
||||
exec { commandLine("sh", "-c", "curl -X 'POST' '$releaseApiUrl/$releaseId/assets' -H 'accept: application/json' -H \"Authorization: token $token\" -H 'Content-Type: multipart/form-data' -F 'attachment=@/usr/local/bin/provs-server.jar;type=application/x-java-archive'") }
|
||||
exec { commandLine("sh", "-c", "curl -X 'POST' '$releaseApiUrl/$releaseId/assets' -H 'accept: application/json' -H \"Authorization: token $token\" -H 'Content-Type: multipart/form-data' -F 'attachment=@build/libs/provs-syspec.jar;type=application/x-java-archive'") }
|
||||
exec { commandLine("sh", "-c", "curl -X 'POST' '$releaseApiUrl/$releaseId/assets' -H 'accept: application/json' -H \"Authorization: token $token\" -H 'Content-Type: multipart/form-data' -F 'attachment=@build/libs/sha256sum.lst;type=text/plain'") }
|
||||
exec { commandLine("sh", "-c", "curl -X 'POST' '$releaseApiUrl/$releaseId/assets' -H 'accept: application/json' -H \"Authorization: token $token\" -H 'Content-Type: multipart/form-data' -F 'attachment=@build/libs/sha512sum.lst;type=text/plain'") }
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue