1
0
mirror of https://gitlab.com/mangadex-pub/mangadex_at_home.git synced 2024-11-16 16:12:32 +01:00
mangadex_at_home/.gitlab-ci.yml

102 lines
2.4 KiB
YAML
Executable File

stages:
- build
- publish
- docker
- push
Gradle Build:
image: openjdk:8
stage: build
only:
- branches
- tags
- merge_requests
before_script:
- export VERSION="${CI_COMMIT_TAG:-$CI_COMMIT_SHORT_SHA}"
script:
- ./gradlew build
variables:
KUBERNETES_MEMORY_REQUEST: 3Gi
KUBERNETES_MEMORY_LIMIT: 3Gi
artifacts:
name: "mangadex_at_home"
paths:
- "build/libs/mangadex_at_home-*-all.jar"
Publish Artifacts:
image: alpine
stage: publish
needs:
- Gradle Build
variables:
GIT_STRATEGY: none
before_script:
- apk update && apk add zip
- export VERSION="${CI_COMMIT_TAG:-$CI_COMMIT_SHORT_SHA}"
script:
- 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
artifacts:
name: "mangadex_at_home"
paths:
- "mangadex_at_home-*-all.jar"
- "mangadex_at_home-*.zip"
- "settings.sample.yaml"
Docker Build:
image: docker:20.10.8
services:
- docker:20.10.8-dind
stage: docker
needs:
- Gradle Build
before_script:
- echo "$CI_REGISTRY_PASSWORD" | docker login -u "$CI_REGISTRY_USER" --password-stdin ${CI_REGISTRY}
- export VERSION="${CI_COMMIT_TAG:-$CI_COMMIT_SHORT_SHA}"
- export BASE_TAG="git-$CI_COMMIT_SHORT_SHA"
script:
- mv build/libs/mangadex_at_home-${VERSION}-all.jar build/libs/mangadex_at_home.jar
- docker build . -t $CI_REGISTRY_IMAGE:$BASE_TAG
- 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="git-$CI_COMMIT_SHORT_SHA"
- export SHORT_TAG="$(echo $CI_COMMIT_TAG | cut -d "." -f1)"
script:
- docker pull $CI_REGISTRY_IMAGE:$BASE_TAG
- docker tag $CI_REGISTRY_IMAGE:$BASE_TAG $CI_REGISTRY_IMAGE:$NEW_TAG
- docker tag $CI_REGISTRY_IMAGE:$BASE_TAG $CI_REGISTRY_IMAGE:$SHORT_TAG
- docker push $CI_REGISTRY_IMAGE --all-tags
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