BlueGit

timfa copper-key

Files

copper-key / .gitlab-ci.yml

.gitlab-ci.yml

.gitlab-ci.yml 3.6 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 CopperKeys-<version>.jar + resource-pack zip; upload to Package Registry
12# 4. release — publish a GitLab Release with jar and resource-pack zip 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 PACKAGE_NAME: copperkeys
24 JAR_NAME: "CopperKeys-${VERSION}.jar"
25 PACK_NAME: "CopperKeys-resourcepack-${VERSION}.zip"
26
27stages:
28 - validate
29 - bump
30 - build
31 - release
32 - rotate
33
34.validate_image:
35 image: alpine:3.20
36 before_script:
37 - apk add --no-cache bash git grep coreutils
38 - git fetch --tags --force origin
39 - chmod +x scripts/release.sh
40
41validate:version:
42 extends: .validate_image
43 stage: validate
44 script:
45 - ./scripts/release.sh validate
46 artifacts:
47 reports:
48 dotenv: version.env
49 paths:
50 - version.env
51
52bump:version:
53 extends: .validate_image
54 stage: bump
55 needs:
56 - job: validate:version
57 artifacts: true
58 script:
59 - ./scripts/release.sh bump
60 artifacts:
61 reports:
62 dotenv: version.env
63 paths:
64 - version.env
65 - build.gradle.kts
66 - src/main/resources/plugin.yml
67 - README.md
68 - src/main/java/nl/timfalken/copperkeys/CopperKeysPlugin.java
69
70build:artifacts:
71 stage: build
72 image: gradle:jdk25
73 needs:
74 - job: bump:version
75 artifacts: true
76 before_script:
77 - apt-get update -qq && apt-get install -y -qq curl zip >/dev/null
78 - chmod +x scripts/release.sh
79 script:
80 - test -n "${VERSION}"
81 - gradle --no-daemon clean jar zipResourcePack
82 - test -f "build/libs/${JAR_NAME}"
83 - test -f "build/dist/${PACK_NAME}"
84 - ls -la "build/libs/${JAR_NAME}" "build/dist/${PACK_NAME}"
85 - ./scripts/release.sh upload
86 artifacts:
87 reports:
88 dotenv: version.env
89 paths:
90 - "build/libs/CopperKeys-*.jar"
91 - "build/dist/CopperKeys-resourcepack-*.zip"
92 - version.env
93 expire_in: 30 days
94
95release:gitlab:
96 stage: release
97 image: registry.gitlab.com/gitlab-org/release-cli:latest
98 needs:
99 - job: build:artifacts
100 artifacts: true
101 script:
102 - echo "Publishing GitLab Release for ${TAG} (version ${VERSION})"
103 release:
104 name: "CopperKeys $VERSION"
105 tag_name: "$TAG"
106 description: "Release $VERSION of CopperKeys."
107 assets:
108 links:
109 - name: "CopperKeys-$VERSION.jar"
110 url: "$CI_API_V4_URL/projects/$CI_PROJECT_ID/packages/generic/$PACKAGE_NAME/$VERSION/CopperKeys-$VERSION.jar"
111 link_type: package
112 - name: "CopperKeys-resourcepack-$VERSION.zip"
113 url: "$CI_API_V4_URL/projects/$CI_PROJECT_ID/packages/generic/$PACKAGE_NAME/$VERSION/CopperKeys-resourcepack-$VERSION.zip"
114 link_type: package
115
116rotate:push-token:
117 image: alpine:3.20
118 stage: rotate
119 needs:
120 - job: release:gitlab
121 before_script:
122 - apk add --no-cache bash curl jq coreutils
123 - chmod +x scripts/release.sh
124 script:
125 - ./scripts/release.sh rotate-token