BlueGit

timfa chestpreviews

Files

chestpreviews / .gitlab-ci.yml

.gitlab-ci.yml

.gitlab-ci.yml 3.4 KiB Download Raw
1# GitLab-backup: test draait eerst; daarna de bestaande tag-release.
2# Release pipeline: runs when a version tag is created (e.g. v1.0.10 or 1.0.10).
3#
4# Required CI/CD variable:
5# CI_PUSH_TOKEN — Project Access Token (Maintainer) with scopes:
6# `write_repository`, `self_rotate` (or `api`), and `api`
7# (api is required to write the rotated token back to this variable).
8#
9# Flow:
10# 1. validate — reject invalid or non-increasing versions
11# 2. bump — update version in project files and push commit (ci.skip; tag unchanged)
12# 3. build — produce ChestPreview-<version>.jar and upload to Package Registry
13# 4. release — publish a GitLab Release with the jar attached
14# 5. rotate-token — self-rotate CI_PUSH_TOKEN and update the CI/CD variable
15
16workflow:
17 rules:
18 - if: $CI_COMMIT_TAG
19
20variables:
21 GIT_DEPTH: "0"
22 GIT_FETCH_EXTRA_FLAGS: "--tags"
23 GRADLE_OPTS: "-Dorg.gradle.daemon=false"
24
25stages:
26 - test
27 - validate
28 - bump
29 - build
30 - release
31 - rotate
32
33test:
34 stage: test
35 image: gradle:jdk25
36 script:
37 - gradle --no-daemon test
38
39.validate_image:
40 image: alpine:3.20
41 before_script:
42 - apk add --no-cache bash git grep coreutils
43 - git fetch --tags --force origin
44 - chmod +x scripts/release.sh
45
46validate:version:
47 extends: .validate_image
48 stage: validate
49 needs: [test]
50 script:
51 - ./scripts/release.sh validate
52 artifacts:
53 reports:
54 dotenv: version.env
55 paths:
56 - version.env
57
58bump:version:
59 extends: .validate_image
60 stage: bump
61 needs:
62 - job: validate:version
63 artifacts: true
64 script:
65 - ./scripts/release.sh bump
66 artifacts:
67 reports:
68 dotenv: version.env
69 paths:
70 - version.env
71 - build.gradle.kts
72 - src/main/resources/plugin.yml
73 - README.md
74 - src/README-*.md
75 - src/main/java/nl/timfalken/chestpreview/ChestPreviewPlugin.java
76
77build:jar:
78 stage: build
79 image: gradle:jdk25
80 needs:
81 - job: bump:version
82 artifacts: true
83 before_script:
84 - apt-get update -qq && apt-get install -y -qq curl >/dev/null
85 - chmod +x scripts/release.sh
86 # Checkout may still contain a previous src/README-*.md; keep only the bumped one.
87 - find src -maxdepth 1 -name 'README-*.md' ! -name "README-${VERSION}.md" -delete
88 script:
89 - test -n "${VERSION}"
90 - gradle --no-daemon clean shadowJar
91 - test -f "build/libs/ChestPreview-${VERSION}.jar"
92 - ls -la "build/libs/ChestPreview-${VERSION}.jar"
93 - ./scripts/release.sh upload
94 artifacts:
95 reports:
96 dotenv: version.env
97 paths:
98 - "build/libs/ChestPreview-*.jar"
99 - version.env
100 expire_in: 30 days
101
102release:gitlab:
103 stage: release
104 image: registry.gitlab.com/gitlab-org/release-cli:latest
105 needs:
106 - job: build:jar
107 artifacts: true
108 script:
109 - echo "Publishing GitLab Release for ${TAG} (version ${VERSION})"
110 release:
111 name: "ChestPreview $VERSION"
112 tag_name: "$TAG"
113 description: "Release $VERSION of ChestPreview."
114 assets:
115 links:
116 - name: "ChestPreview-$VERSION.jar"
117 url: "$CI_API_V4_URL/projects/$CI_PROJECT_ID/packages/generic/chestpreviews/$VERSION/ChestPreview-$VERSION.jar"
118 link_type: package
119
120rotate:push-token:
121 image: alpine:3.20
122 stage: rotate
123 needs:
124 - job: release:gitlab
125 before_script:
126 - apk add --no-cache bash curl jq coreutils
127 - chmod +x scripts/release.sh
128 script:
129 - ./scripts/release.sh rotate-token