From 40cb532dc0b31715d5753b75c351fb1c356a0880 Mon Sep 17 00:00:00 2001 From: Kewbit Date: Wed, 27 Nov 2024 21:29:49 +0000 Subject: [PATCH] Update .gitlab-ci.yml file --- .gitlab-ci.yml | 89 +++++++++++++++----------------------------------- 1 file changed, 27 insertions(+), 62 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 1935d2d9..c44f9414 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1,68 +1,33 @@ stages: - - sync - - patch - - build - - release + - update_patched_master -# Sync the upstream repository -sync: - stage: sync - script: - - echo "Syncing upstream master branch..." - - git fetch origin master - - git reset --hard origin/master - rules: - - if: '$CI_PIPELINE_SOURCE == "schedule"' # Trigger on schedule or manual action +variables: + GIT_STRATEGY: fetch + GIT_SSL_NO_VERIFY: "1" -# Apply patches -patch: - stage: patch +update_patched_master: + stage: update_patched_master + only: + - patched_changes script: - - echo "Switching to patched_master branch..." - - git fetch origin patched_master || true - - git checkout -b patched_master || git checkout patched_master - - echo "Merging upstream changes into patched_master..." - - git merge origin/master --no-ff -m "Merge upstream changes into patched_master" - - echo "Applying custom patches..." - - git fetch origin patched_changes - - git checkout patched_changes - - git merge patched_master --no-ff -m "Applying custom patches" - - echo "Updating patched_master with patched_changes..." + - echo "Setting up Git..." + - git config user.name "$GITLAB_USER_NAME" + - git config user.email "$GITLAB_USER_EMAIL" + - git remote set-url origin https://oauth2:${GITLAB_ACCESS_TOKEN}@${CI_SERVER_HOST}/${CI_PROJECT_PATH}.git + - echo "Fetching all branches..." + - git fetch --all + - echo "Checking out patched_master..." - git checkout patched_master - - git merge patched_changes --no-ff -m "Merged patches into patched_master" + - echo "Merging master into patched_master..." + - git merge origin/master --no-edit + - echo "Cleaning working directory..." + - git rm -r --cached . + - git clean -fd + - echo "Overwriting all files from patched_changes (excluding .gitlab-ci.yml)..." + - git checkout origin/patched_changes -- . ':!.gitlab-ci.yml' + - echo "Adding changes..." + - git add . + - echo "Committing changes..." + - git commit -m "Auto-update patched_master with changes from patched_changes" + - echo "Pushing changes to patched_master..." - git push origin patched_master - rules: - - if: '$CI_COMMIT_BRANCH == "patched_changes"' # Trigger when patched_changes updates - - if: '$CI_COMMIT_BRANCH == "master"' # Trigger when master updates - -# Build process -build: - stage: build - image: registry:java-core-builder:latest # Use Gradle with Java 21 - script: - - echo "Building with Gradle on Java 21..." - - java -version - - ./gradlew clean :daemon:shadowJar - artifacts: - paths: - - daemon/build/libs/ # Artifacts path - expire_in: 7 days # Artifacts expiration time - rules: - - if: '$CI_COMMIT_TAG' # Trigger on new tag - - if: '$CI_COMMIT_BRANCH == "patched_master"' # Trigger when patched_master updates - -# Prepare release artifacts -release: - stage: release - image: alpine:latest # Minimal Docker image for release - script: - - echo "Preparing release artifacts..." - - mkdir -p release - - cp daemon/build/libs/*.jar release/ - - echo "Release artifact generated." - artifacts: - paths: - - release/ # Path for release artifacts - expire_in: 7 days - rules: - - if: '$CI_COMMIT_TAG' # Trigger only on new tags