Merge branch 'auto-update' into 'main'
Create auto-updater See merge request greg/mingw-sword-build!3
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -105,6 +105,7 @@
|
||||
x86 = tar mingwW64;
|
||||
ucrt = tar ucrt64;
|
||||
ucrtAarch = tar arm.pkgsCross.ucrtAarch64;
|
||||
update = pkgs.callPackage ./update.nix { };
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
+37
@@ -0,0 +1,37 @@
|
||||
{
|
||||
writeShellApplication,
|
||||
gnugrep,
|
||||
nix-prefetch,
|
||||
subversion,
|
||||
}:
|
||||
writeShellApplication {
|
||||
name = "sword-updater";
|
||||
runtimeInputs = [
|
||||
gnugrep
|
||||
nix-prefetch
|
||||
subversion
|
||||
];
|
||||
|
||||
text = ''
|
||||
url="https://www.crosswire.org/svn/sword/trunk"
|
||||
old_rev="$(grep "${./flake.nix}" -e "rev = " | sed -E -e 's/.*"(.*)".*/\1/')"
|
||||
echo "OLD_REV=$old_rev"
|
||||
new_rev="$(svn info "$url" --show-item revision)"
|
||||
echo "NEW_REV=$new_rev"
|
||||
if [ "$new_rev" == "$old_rev" ]; then
|
||||
#exit 0
|
||||
else
|
||||
echo "DO_UPDATE=1"
|
||||
fi
|
||||
hash="$(nix-prefetch \
|
||||
--check-store \
|
||||
--option extra-experimental-features flakes \
|
||||
fetchsvn \
|
||||
--url "$url" \
|
||||
--rev "$new_rev" \
|
||||
)"
|
||||
echo "HASH=$hash"
|
||||
sed -i flake.nix \
|
||||
-e "s/rev = \"$old_rev\"/rev = \"$new_rev\"/"
|
||||
'';
|
||||
}
|
||||
Reference in New Issue
Block a user