1
0
Fork 1
mirror of https://gitlab.com/mangadex-pub/mangadex_at_home.git synced 2024-01-19 02:48:37 +00:00

Update CI

This commit is contained in:
carbotaniuman 2021-10-02 03:54:09 +00:00
parent baecff51be
commit ce94b21b03
2 changed files with 67 additions and 21 deletions

View file

@ -1,14 +1,19 @@
stages: stages:
- build - build
- publish - publish
- publish_docker - docker
- push
build: Gradle Build:
image: openjdk:8 image: openjdk:8
stage: build stage: build
only:
- branches
- tags
- merge_requests
before_script: before_script:
- export VERSION="$CI_COMMIT_REF_NAME" - export VERSION="${CI_COMMIT_TAG:-$CI_COMMIT_SHORT_SHA}"
script: script:
- ./gradlew build - ./gradlew build
artifacts: artifacts:
@ -16,18 +21,20 @@ build:
paths: paths:
- "build/libs/mangadex_at_home-*-all.jar" - "build/libs/mangadex_at_home-*-all.jar"
publish: Publish Artifacts:
image: alpine image: alpine
stage: publish stage: publish
needs:
- Gradle Build
variables:
GIT_STRATEGY: none
before_script: before_script:
- apk update && apk add zip - apk update && apk add zip
- export VERSION="$CI_COMMIT_REF_NAME" - export VERSION="${CI_COMMIT_TAG:-$CI_COMMIT_SHORT_SHA}"
script: script:
- cp build/libs/mangadex_at_home-${VERSION}-all.jar ./ - cp build/libs/mangadex_at_home-${VERSION}-all.jar ./
- zip -r9 mangadex_at_home-${VERSION}.zip mangadex_at_home-${VERSION}-all.jar settings.sample.yaml - zip -r9 mangadex_at_home-${VERSION}.zip mangadex_at_home-${VERSION}-all.jar settings.sample.yaml
dependencies:
- build
artifacts: artifacts:
name: "mangadex_at_home" name: "mangadex_at_home"
paths: paths:
@ -35,20 +42,55 @@ publish:
- "mangadex_at_home-*.zip" - "mangadex_at_home-*.zip"
- "settings.sample.yaml" - "settings.sample.yaml"
publish_docker: Docker Build:
image: docker:20.10.8 image: docker:20.10.8
services: services:
- docker:20.10.8-dind - docker:20.10.8-dind
stage: publish stage: docker
only: needs:
- tags - Gradle Build
before_script: before_script:
- echo "$CI_REGISTRY_PASSWORD" | docker login -u "$CI_REGISTRY_USER" --password-stdin ${CI_REGISTRY} - echo "$CI_REGISTRY_PASSWORD" | docker login -u "$CI_REGISTRY_USER" --password-stdin ${CI_REGISTRY}
- export VERSION="$CI_COMMIT_REF_NAME" - export VERSION="${CI_COMMIT_TAG:-$CI_COMMIT_SHORT_SHA}"
dependencies: - export BASE_TAG="$CI_COMMIT_SHORT_SHA"
- build
script: script:
- mv build/libs/mangadex_at_home-${VERSION}-all.jar build/libs/mangadex_at_home.jar - mv build/libs/mangadex_at_home-${VERSION}-all.jar build/libs/mangadex_at_home.jar
- docker build . -t ${CI_REGISTRY_IMAGE}:${VERSION} - docker build . -t $CI_REGISTRY_IMAGE:$BASE_TAG
- docker push ${CI_REGISTRY_IMAGE}:${VERSION} - docker push $CI_REGISTRY_IMAGE:$BASE_TAG
.docker_push: &docker_push
image: docker:20.10.8
services:
- docker:20.10.8-dind
stage: push
variables:
GIT_STRATEGY: none
before_script:
- echo "$CI_REGISTRY_PASSWORD" | docker login -u "$CI_REGISTRY_USER" --password-stdin ${CI_REGISTRY}
- export BASE_TAG="$CI_COMMIT_SHORT_SHA"
script:
- docker pull $CI_REGISTRY_IMAGE:$BASE_TAG
- docker tag $CI_REGISTRY_IMAGE:$BASE_TAG $CI_REGISTRY_IMAGE:$NEW_TAG
- docker push $CI_REGISTRY_IMAGE:$NEW_TAG
Push Latest:
<<: *docker_push
needs:
- Docker Build
only:
- master
variables:
NEW_TAG: latest
Push Tags:
<<: *docker_push
needs:
- Docker Build
only:
- tags
variables:
NEW_TAG: $CI_COMMIT_TAG

View file

@ -1,17 +1,21 @@
plugins { plugins {
id "jacoco" id "jacoco"
id "java" id "java"
id "org.jetbrains.kotlin.jvm" version "1.5.21" id "org.jetbrains.kotlin.jvm" version "1.5.31"
id "org.jetbrains.kotlin.kapt" version "1.5.21" id "org.jetbrains.kotlin.kapt" version "1.5.31"
id "application" id "application"
id "com.github.johnrengelman.shadow" version "5.2.0" id "com.github.johnrengelman.shadow" version "7.0.0"
id "com.diffplug.spotless" version "5.8.2" id "com.diffplug.spotless" version "5.8.2"
id "net.afanasev.sekret" version "0.1.0" id "net.afanasev.sekret" version "0.1.0"
id "com.palantir.git-version" version "0.12.3"
} }
group = "com.mangadex" group = "com.mangadex"
version = System.getenv().getOrDefault("VERSION", 'git describe --tags --dirty'.execute().text.trim()) version = System.getenv("VERSION") ?: gitVersion()
mainClassName = "mdnet.MainKt"
application {
mainClass = "mdnet.MainKt"
}
repositories { repositories {
mavenCentral() mavenCentral()