From 447b2461e46d5e61d66f38957b1d0d2dcc20efd7 Mon Sep 17 00:00:00 2001 From: Amir Zarrinkafsh Date: Thu, 20 Feb 2020 10:25:28 +1100 Subject: [PATCH] [Buildkite] Automate CD for AUR packages (#644) * [Buildkite] Automate continuous deployment for AUR packages * [Buildkite] Make AUR deploy step conditional --- .buildkite/deployment.yml | 7 ++++++- .buildkite/steps/aurhelper.sh | 23 +++++++++++++++++++++++ .buildkite/steps/aurpackages.sh | 20 ++++++++++++++++++++ .buildkite/steps/deployimages.sh | 2 +- bootstrap.sh | 2 +- 5 files changed, 51 insertions(+), 3 deletions(-) create mode 100755 .buildkite/steps/aurhelper.sh create mode 100755 .buildkite/steps/aurpackages.sh diff --git a/.buildkite/deployment.yml b/.buildkite/deployment.yml index bb125610a..3716d6b70 100644 --- a/.buildkite/deployment.yml +++ b/.buildkite/deployment.yml @@ -17,4 +17,9 @@ steps: command: ".buildkite/steps/ghartifacts.sh" agents: upload: "fast" - if: build.tag != null \ No newline at end of file + key: "artifacts" + if: build.tag != null + + - label: ":linux: Deploy AUR" + command: ".buildkite/steps/aurpackages.sh | buildkite-agent pipeline upload" + if: build.tag != null || build.branch == "master" \ No newline at end of file diff --git a/.buildkite/steps/aurhelper.sh b/.buildkite/steps/aurhelper.sh new file mode 100755 index 000000000..af961d04a --- /dev/null +++ b/.buildkite/steps/aurhelper.sh @@ -0,0 +1,23 @@ +#! /bin/bash + +GITTAG=$(git describe --long --tags | sed 's/^v//;s/\([^-]*-g\)/r\1/;s/-/./g') + +echo "--- :linux: Deploy AUR package: ${PACKAGE}" +git clone ssh://aur@aur.archlinux.org/"${PACKAGE}".git +cd "${PACKAGE}" || exit + +if [[ $PACKAGE != "authelia-git" ]]; then + sed -i "/pkgver=/c\pkgver=${BUILDKITE_TAG//v/}" PKGBUILD && \ + docker run --rm -v $PWD:/build authelia/aurpackager bash -c "cd /build && updpkgsums" +else + sed -i "/pkgver=/c\pkgver=${GITTAG}" PKGBUILD +fi + +docker run --rm -v $PWD:/build authelia/aurpackager bash -c "cd /build && makepkg --printsrcinfo >| .SRCINFO" && \ +git add . && \ +if [[ $PACKAGE != "authelia-git" ]]; then + git commit -m "Update to ${BUILDKITE_TAG}" +else + git commit -m "Update to GIT version: ${GITTAG}" +fi +git push \ No newline at end of file diff --git a/.buildkite/steps/aurpackages.sh b/.buildkite/steps/aurpackages.sh new file mode 100755 index 000000000..d9c8663eb --- /dev/null +++ b/.buildkite/steps/aurpackages.sh @@ -0,0 +1,20 @@ +#!/bin/bash +set -eu + +for AUR_PACKAGE in authelia authelia-bin authelia-git; +do + echo " - label: \":linux: Deploy AUR Package [${AUR_PACKAGE}]\"" + echo " commands:" + echo " - \"aurhelper.sh\"" + echo " agents:" + echo " upload: \"fast\"" + echo " env:" + echo " "PACKAGE: ${AUR_PACKAGE}"" + if [[ "${AUR_PACKAGE}" != "authelia-git" ]]; then + echo " depends_on:" + echo " - \"artifacts\"" + echo " if: build.tag != null" + else + echo " if: build.branch == \"master\"" + fi +done \ No newline at end of file diff --git a/.buildkite/steps/deployimages.sh b/.buildkite/steps/deployimages.sh index 3ef4b2b56..857c2c3e6 100755 --- a/.buildkite/steps/deployimages.sh +++ b/.buildkite/steps/deployimages.sh @@ -7,7 +7,7 @@ do echo " - \"authelia-scripts docker push-image --arch=${BUILD_ARCH}\"" echo " label: \":docker: Deploy Image [${BUILD_ARCH}]\"" echo " agents:" - echo " "upload: fast"" + echo " upload: \"fast\"" echo " env:" echo " "ARCH: ${BUILD_ARCH}"" done \ No newline at end of file diff --git a/bootstrap.sh b/bootstrap.sh index f39d7f1f9..98d5949cf 100644 --- a/bootstrap.sh +++ b/bootstrap.sh @@ -1,6 +1,6 @@ #!/bin/bash -export PATH=$PATH:./cmd/authelia-scripts/:./node_modules/.bin:/tmp +export PATH=$PATH:./cmd/authelia-scripts/:./.buildkite/steps/:./node_modules/.bin:/tmp if [[ -z "$OLD_PS1" ]]; then OLD_PS1="$PS1"