2023-03-08 13:50:46 +00:00
|
|
|
image: openjdk:17-jdk-slim
|
2023-03-08 13:46:29 +00:00
|
|
|
|
|
|
|
stages:
|
2023-03-08 14:07:23 +00:00
|
|
|
- prepare
|
2023-03-08 13:46:29 +00:00
|
|
|
- build
|
2023-03-08 14:01:53 +00:00
|
|
|
- release
|
2023-03-08 13:46:29 +00:00
|
|
|
|
|
|
|
before_script:
|
|
|
|
# - echo `pwd` # debug
|
|
|
|
# - echo "$CI_BUILD_NAME, $CI_BUILD_REF_NAME $CI_BUILD_STAGE" # debug
|
|
|
|
- export GRADLE_USER_HOME=`pwd`/.gradle
|
2023-03-08 14:11:09 +00:00
|
|
|
- export VERSION=$CI_COMMIT_TAG
|
2023-03-08 13:46:29 +00:00
|
|
|
|
2023-03-08 14:07:23 +00:00
|
|
|
prepare_job:
|
|
|
|
stage: prepare # This stage must run before the release stage
|
|
|
|
rules:
|
|
|
|
- if: $CI_COMMIT_TAG
|
|
|
|
when: never # Do not run this job when a tag is created manually
|
|
|
|
- if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH # Run this job when commits are pushed or merged to the default branch
|
|
|
|
script:
|
2023-03-08 14:14:04 +00:00
|
|
|
- echo "TAG=RELEASE" >> variables.env # and append to the variables.env file
|
2023-03-08 14:07:23 +00:00
|
|
|
artifacts:
|
|
|
|
reports:
|
|
|
|
dotenv: variables.env # Use artifacts:reports:dotenv to expose the variables to other jobs
|
|
|
|
|
2023-03-08 13:46:29 +00:00
|
|
|
cache:
|
|
|
|
paths:
|
|
|
|
- .gradle/wrapper
|
|
|
|
- .gradle/caches
|
|
|
|
|
|
|
|
build:
|
|
|
|
stage: build
|
2023-03-08 14:00:58 +00:00
|
|
|
rules:
|
2023-03-08 13:46:29 +00:00
|
|
|
script:
|
|
|
|
- ./gradlew assemble
|
|
|
|
artifacts:
|
|
|
|
paths:
|
|
|
|
- build/libs/*.jar
|
|
|
|
expire_in: 1 week
|
|
|
|
only:
|
|
|
|
- master
|
|
|
|
|
2023-03-08 14:01:53 +00:00
|
|
|
release:
|
2023-03-08 14:00:58 +00:00
|
|
|
stage: release
|
|
|
|
image: registry.gitlab.com/gitlab-org/release-cli:latest
|
|
|
|
needs:
|
|
|
|
- job: build
|
|
|
|
artifacts: true
|
|
|
|
rules:
|
|
|
|
- if: $CI_COMMIT_TAG
|
|
|
|
when: never # Do not run this job when a tag is created manually
|
|
|
|
- if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH # Run this job when commits are pushed or merged to the default branch
|
2023-03-08 13:46:29 +00:00
|
|
|
script:
|
2023-03-08 14:07:23 +00:00
|
|
|
- echo "running release for $TAG"
|
2023-03-08 14:00:58 +00:00
|
|
|
release:
|
2023-03-08 14:07:23 +00:00
|
|
|
name: 'Release $TAG'
|
2023-03-08 14:00:58 +00:00
|
|
|
description: 'Created using the release-cli $EXTRA_DESCRIPTION' # $EXTRA_DESCRIPTION and the $TAG
|
2023-03-08 14:07:23 +00:00
|
|
|
tag_name: '$TAG' # variables must be defined elsewhere
|
2023-03-08 14:00:58 +00:00
|
|
|
ref: '$CI_COMMIT_SHA' # in the pipeline. For example, in the
|