Create auto-updater

This commit is contained in:
Greg Hellings
2025-08-08 16:14:06 -05:00
parent 9066dcfeea
commit 4df117b535
3 changed files with 96 additions and 0 deletions
+58
View File
@@ -1,10 +1,63 @@
stages:
- check
- update
- build
- release
version_update:
stage: update
tags:
- nix
rules:
- if: '$CI_PIPELINE_SOURCE == "manual"'
artifacts:
reports:
dotenv: update.env
script:
- nix run ".#update" > update.env
- |-
if git diff --quiet; then
echo "Found changes to make"
git checkout -b "sword-rev/$CI_PIPELINE_IID"
echo "BRANCH=sword-rev/$CI_PIPELINE_IID" >> update.env
git stage .
git commit -m "Automatic update #$CI_PIPELINE_IID"
git push "https://${GITLAB_USER_LOGIN}:${CI_GIT_TOKEN}@${CI_REPOSITORY_URL#*@}" HEAD
fi
create_pr:
stage: update
needs:
- version_update
dependencies:
- version_update
variables:
GIT_STRATEGY: none
GITLAB_PRIVATE_TOKEN: $CI_GIT_TOKEN
rules:
- if: '$CI_PIPELINE_SOURCE == "manual"'
script:
- test -z ${DO_UPDATE} && { echo "No updates required. Not crating PR"; exit 0; }
- >-
CREATE_MR=$(gitlab project-merge-request create
--remove-source-branch true
--project-id ${CI_PROJECT_ID}
--source-branch "${BRANCfh}"
--target-branch "main"
--title "Update sword to r$NEW_REV")
- IID=${CREATE_MR#* }
- >-
gitlab project-merge-request merge \
--project-id ${CI_PROJECT_ID} \
--iid ${IID} \
--merge-when-pipeline-succeeds true
- echo "PR set to auto-merge if build succeeds"
check:
stage: check
rules:
- if: '$CI_PIPELINE_SOURCE == "manual"'
when: never
tags:
- nix
script:
@@ -25,6 +78,9 @@ build:
- ARCH: [x86, ucrt]
tags:
- nix
rules:
- if: '$CI_PIPELINE_SOURCE == "manual"'
when: never
script:
- nix run -L ".#${ARCH}"
- ls -l
@@ -46,6 +102,8 @@ build:
rules:
- if: $CI_COMMIT_BRANCH == "main"
when: always
- if: '$CI_PIPELINE_SOURCE == "manual"'
when: never
needs:
- job: check
artifacts: true