From 5c522ed2e1c0e74f323b4e79ff74ee89bb8119e2 Mon Sep 17 00:00:00 2001 From: Aurel Canciu Date: Thu, 3 Dec 2020 02:08:25 +0200 Subject: [PATCH] Add publisher scripts and gorelease config Signed-off-by: Aurel Canciu --- .goreleaser.yml | 18 +++++++++++++++ ci/aur/flux-bin/.gitignore | 1 + ci/aur/flux-bin/publish.sh | 46 ++++++++++++++++++++++++++++++++++++++ ci/aur/flux-git/.gitignore | 1 + ci/aur/flux-git/publish.sh | 42 ++++++++++++++++++++++++++++++++++ ci/aur/flux-go/.gitignore | 1 + ci/aur/flux-go/publish.sh | 44 ++++++++++++++++++++++++++++++++++++ 7 files changed, 153 insertions(+) create mode 100644 ci/aur/flux-bin/.gitignore create mode 100755 ci/aur/flux-bin/publish.sh create mode 100644 ci/aur/flux-git/.gitignore create mode 100755 ci/aur/flux-git/publish.sh create mode 100644 ci/aur/flux-go/.gitignore create mode 100755 ci/aur/flux-go/publish.sh diff --git a/.goreleaser.yml b/.goreleaser.yml index c72e9af0..9650bf0d 100644 --- a/.goreleaser.yml +++ b/.goreleaser.yml @@ -50,3 +50,21 @@ brews: type: optional test: | system "#{bin}/flux --version" +publishers: + - name: aur-pkg-bin + ids: + - nix + cmd: | + eval $(ssh-agent -s) + ssh-add <(echo "{{ .Env.AUR_BOT_SSH_PRIVATE_KEY }}") + ci/aur/flux-bin/publish.sh {{ .Version }} + - name: aur-pkg-git + cmd: | + eval $(ssh-agent -s) + ssh-add <(echo "{{ .Env.AUR_BOT_SSH_PRIVATE_KEY }}") + ci/aur/flux-git/publish.sh {{ .Version }} + - name: aur-pkg-go + cmd: | + eval $(ssh-agent -s) + ssh-add <(echo "{{ .Env.AUR_BOT_SSH_PRIVATE_KEY }}") + ci/aur/flux-go/publish.sh {{ .Version }} diff --git a/ci/aur/flux-bin/.gitignore b/ci/aur/flux-bin/.gitignore new file mode 100644 index 00000000..5a6ed48b --- /dev/null +++ b/ci/aur/flux-bin/.gitignore @@ -0,0 +1 @@ +.pkg diff --git a/ci/aur/flux-bin/publish.sh b/ci/aur/flux-bin/publish.sh new file mode 100755 index 00000000..54513023 --- /dev/null +++ b/ci/aur/flux-bin/publish.sh @@ -0,0 +1,46 @@ +#!/usr/bin/env bash + +set -e + +WD=$(cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd) +PKGNAME=$(basename $WD) +ROOT=${WD%/ci/aur/$PKGNAME} + +export VERSION=$1 +echo "Publishing to AUR as version ${VERSION}" + +cd $WD + +export GIT_SSH_COMMAND="ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no" + +rm -rf .pkg +git clone aur@aur.archlinux.org:$PKGNAME .pkg 2>&1 + +CURRENT_PKGVER=$(cat .pkg/.SRCINFO | grep pkgver | awk '{ print $3 }') +CURRENT_PKGREL=$(cat .pkg/.SRCINFO | grep pkgrel | awk '{ print $3 }') + +export PKGVER=${VERSION/-/} + +if [[ "${CURRENT_PKGVER}" == "${PKGVER}" ]]; then + export PKGREL=$((CURRENT_PKGREL+1)) +else + export PKGREL=1 +fi + +export SHA256SUM_ARM=$(sha256sum ${ROOT}/dist/flux_${PKGVER}_linux_arm.tar.gz | awk '{ print $1 }') +export SHA256SUM_ARM64=$(sha256sum ${ROOT}/dist/flux_${PKGVER}_linux_arm64.tar.gz | awk '{ print $1 }') +export SHA256SUM_AMD64=$(sha256sum ${ROOT}/dist/flux_0.4.2_linux_amd64.tar.gz | awk '{ print $1 }') + +envsubst '$PKGVER $PKGREL $SHA256SUM_AMD64 $SHA256SUM_ARM $SHA256SUM_ARM64' < .SRCINFO.template > .pkg/.SRCINFO +envsubst '$PKGVER $PKGREL $SHA256SUM_AMD64 $SHA256SUM_ARM $SHA256SUM_ARM64' < PKGBUILD.template > .pkg/PKGBUILD + +cd .pkg +git config user.name "fluxcdbot" +git config user.email "fluxcdbot@users.noreply.github.com" +git add -A +if [ -z "$(git status --porcelain)" ]; then + echo "No changes." +else + git commit -m "Updated to version v${PKGVER} release ${PKGREL}" + git push origin master +fi diff --git a/ci/aur/flux-git/.gitignore b/ci/aur/flux-git/.gitignore new file mode 100644 index 00000000..5a6ed48b --- /dev/null +++ b/ci/aur/flux-git/.gitignore @@ -0,0 +1 @@ +.pkg diff --git a/ci/aur/flux-git/publish.sh b/ci/aur/flux-git/publish.sh new file mode 100755 index 00000000..bc2f21a9 --- /dev/null +++ b/ci/aur/flux-git/publish.sh @@ -0,0 +1,42 @@ +#!/usr/bin/env bash + +set -e + +WD=$(cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd) +PKGNAME=$(basename $WD) +ROOT=${WD%/ci/aur/$PKGNAME} + +export VERSION=$1 +echo "Publishing to AUR as version ${VERSION}" + +cd $WD + +export GIT_SSH_COMMAND="ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no" + +rm -rf .pkg +git clone aur@aur.archlinux.org:$PKGNAME .pkg 2>&1 + +CURRENT_PKGVER=$(cat .pkg/.SRCINFO | grep pkgver | awk '{ print $3 }') +CURRENT_PKGREL=$(cat .pkg/.SRCINFO | grep pkgrel | awk '{ print $3 }') + +export PKGVER=${VERSION/-/} + +if [[ "${CURRENT_PKGVER}" == "${PKGVER}" ]]; then + export PKGREL=$((CURRENT_PKGREL+1)) +else + export PKGREL=1 +fi + +envsubst '$PKGVER $PKGREL' < .SRCINFO.template > .pkg/.SRCINFO +envsubst '$PKGVER $PKGREL' < PKGBUILD.template > .pkg/PKGBUILD + +cd .pkg +git config user.name "fluxcdbot" +git config user.email "fluxcdbot@users.noreply.github.com" +git add -A +if [ -z "$(git status --porcelain)" ]; then + echo "No changes." +else + git commit -m "Updated to version v${PKGVER} release ${PKGREL}" + git push origin master +fi diff --git a/ci/aur/flux-go/.gitignore b/ci/aur/flux-go/.gitignore new file mode 100644 index 00000000..5a6ed48b --- /dev/null +++ b/ci/aur/flux-go/.gitignore @@ -0,0 +1 @@ +.pkg diff --git a/ci/aur/flux-go/publish.sh b/ci/aur/flux-go/publish.sh new file mode 100755 index 00000000..4c96417d --- /dev/null +++ b/ci/aur/flux-go/publish.sh @@ -0,0 +1,44 @@ +#!/usr/bin/env bash + +set -e + +WD=$(cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd) +PKGNAME=$(basename $WD) +ROOT=${WD%/ci/aur/$PKGNAME} + +export VERSION=$1 +echo "Publishing to AUR as version ${VERSION}" + +cd $WD + +export GIT_SSH_COMMAND="ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no" + +rm -rf .pkg +git clone aur@aur.archlinux.org:$PKGNAME .pkg 2>&1 + +CURRENT_PKGVER=$(cat .pkg/.SRCINFO | grep pkgver | awk '{ print $3 }') +CURRENT_PKGREL=$(cat .pkg/.SRCINFO | grep pkgrel | awk '{ print $3 }') + +export PKGVER=${VERSION/-/} + +if [[ "${CURRENT_PKGVER}" == "${PKGVER}" ]]; then + export PKGREL=$((CURRENT_PKGREL+1)) +else + export PKGREL=1 +fi + +export SHA256SUM=$(curl -sL https://github.com/fluxcd/flux2/archive/v$PKGVER.tar.gz | sha256sum | awk '{ print $1 }') + +envsubst '$PKGVER $PKGREL $SHA256SUM' < .SRCINFO.template > .pkg/.SRCINFO +envsubst '$PKGVER $PKGREL $SHA256SUM' < PKGBUILD.template > .pkg/PKGBUILD + +cd .pkg +git config user.name "fluxcdbot" +git config user.email "fluxcdbot@users.noreply.github.com" +git add -A +if [ -z "$(git status --porcelain)" ]; then + echo "No changes." +else + git commit -m "Updated to version v${PKGVER} release ${PKGREL}" + git push origin master +fi