-
Notifications
You must be signed in to change notification settings - Fork 14
Expand file tree
/
Copy path.gitlab-ci.yml
More file actions
102 lines (93 loc) · 3.04 KB
/
.gitlab-ci.yml
File metadata and controls
102 lines (93 loc) · 3.04 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
# Use OpenJDK 8 provided by Eclipse Temurin since the main jdk images have been
# deprecated for a while now. Let's also use Ubuntu Jammy (22.04), which is the
# most recent LTS release.
# Upstream reference: https://github.com/adoptium/containers
default:
image: eclipse-temurin:8-jdk-jammy
stages:
- format
- build
- deploy
- pages
before_script:
- export GRADLE_USER_HOME=`pwd`/.gradle
- apt-get update --quiet --assume-yes
- apt-get install --quiet --assume-yes git make
# git rev-list --count does not work correctly with the default settings.
variables:
GIT_STRATEGY: clone
GIT_DEPTH: 0
# Invalidate cache if the gradle-wrapper.properties file changes.
# All wrapper binaries, dependency caches & release changelog notifications
# (that bit of text that appears when the wrapper is updated) are cached
# for use in later invocations of the CI.
cache:
key:
files:
- gradle/wrapper/gradle-wrapper.properties
paths:
- .gradle/wrapper
- .gradle/caches
- .gradle/notifications
# Check if source code is formatted properly.
format:
stage: format
script:
- make check-format
# Explicitly state to gradle wrapper that we want the cache to be enabled,
# build a release zip, then upload the zip artifact to Gitlab CI for end-users
# to download.
build:
stage: build
script:
- set -e # error out immediately
- make release
- mv *.zip IdleRSC.zip
artifacts:
name: IdleRSC
paths:
- IdleRSC.zip
expire_in: 1 month
# Upload build to Generic Packages Registry
upload_package:
stage: deploy
dependencies:
- build
script:
- |
# Determine the package version. Prioritize commit tag if present.
if [ -n "$CI_COMMIT_TAG" ]; then
PACKAGE_VERSION="$CI_COMMIT_TAG"
else
PACKAGE_VERSION="$CI_COMMIT_SHORT_SHA-$(date +%Y%m%d%H%M%S)"
fi
echo "---"
echo "Calculated PACKAGE_VERSION: '$PACKAGE_VERSION'" # Keep this debug line!
echo "---"
# Upload the package using curl.
# Corrected: Use PACKAGE_VERSION consistently in the URL path.
curl --fail-with-body \
--header "JOB-TOKEN: $CI_JOB_TOKEN" \
--upload-file IdleRSC.zip \
"${CI_API_V4_URL}/projects/${CI_PROJECT_ID}/packages/generic/IdleRSC/${PACKAGE_VERSION}/IdleRSC-${PACKAGE_VERSION}.zip"
echo "---"
echo "Package upload command executed."
echo "---"
rules:
# Always run if the branch is "update_git_workflows", uncomment for testing this code.
# - if: $CI_COMMIT_BRANCH == "update_git_workflows"
# when: on_success # Only if previous stages succeed
# Run only if a Git tag exists AND it's on the default branch
- if: '$CI_COMMIT_TAG && $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH'
when: on_success # Only if previous stages succeed
artifacts:
# This artifact configuration ensures the uploaded package URL is always available in job logs.
expire_in: never
# Upload Javadoc API documentationls to Gitlab pages.
pages:
stage: pages
script:
- make build-javadoc
artifacts:
paths:
- public