BlueGit

timfa birdcourier

Files

birdcourier / .gitlab-ci.yml

.gitlab-ci.yml

.gitlab-ci.yml 3.0 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 BirdCourier-<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/main/java/nl/timfalken/birdcourier/BirdCourierPlugin.java
66
67build:jar:
68 stage: build
69 image: gradle:jdk25
70 needs:
71 - job: bump:version
72 artifacts: true
73 before_script:
74 - apt-get update -qq && apt-get install -y -qq curl >/dev/null
75 - chmod +x scripts/release.sh
76 script:
77 - test -n "${VERSION}"
78 - gradle --no-daemon clean jar
79 - test -f "build/libs/BirdCourier-${VERSION}.jar"
80 - ls -la "build/libs/BirdCourier-${VERSION}.jar"
81 - ./scripts/release.sh upload
82 artifacts:
83 reports:
84 dotenv: version.env
85 paths:
86 - "build/libs/BirdCourier-*.jar"
87 - version.env
88 expire_in: 30 days
89
90release:gitlab:
91 stage: release
92 image: registry.gitlab.com/gitlab-org/release-cli:latest
93 needs:
94 - job: build:jar
95 artifacts: true
96 script:
97 - echo "Publishing GitLab Release for ${TAG} (version ${VERSION})"
98 release:
99 name: "BirdCourier $VERSION"
100 tag_name: "$TAG"
101 description: "Release $VERSION of BirdCourier."
102 assets:
103 links:
104 - name: "BirdCourier-$VERSION.jar"
105 url: "$CI_API_V4_URL/projects/$CI_PROJECT_ID/packages/generic/birdcourier/$VERSION/BirdCourier-$VERSION.jar"
106 link_type: package
107
108rotate:push-token:
109 image: alpine:3.20
110 stage: rotate
111 needs:
112 - job: release:gitlab
113 before_script:
114 - apk add --no-cache bash curl jq coreutils
115 - chmod +x scripts/release.sh
116 script:
117 - ./scripts/release.sh rotate-token