BlueGit

timfa containerpipes

Files

containerpipes / .gitlab-ci.yml

.gitlab-ci.yml

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