authelia/.buildkite/hooks/pre-artifact
Amir Zarrinkafsh 93e20a44e9
feat: build and distribute .deb packages (#2114)
* feat: build and distribute .deb packages

Creates .deb packages for distribution via GitHub releases and Buildkite builds for the following architectures:

* amd64
* armhf
* arm64

* fix: pkgver reference in debpackages.sh

* refactor: split deb packaging jobs and quote variables

* fix: pipeline upload for debpackages

* fix: depends_on key for debpackages

* fix: add depends_on: ~ for debpackages step

* fix: pre-artifact hook for debpackages

* fix: add .deb suffix in pre-artifact hook

* fix: variable reference in debhelper.sh

* refactor: silence wget output in debhelper.sh

* refactor: make build concurrency gate only depend_on docker builds

* refactor: make build concurrency gate also depend_on coverage build

* refactor: remove dependencies for build concurrency gate
2021-06-26 11:45:21 +10:00

36 lines
1.5 KiB
Bash
Executable File

#!/usr/bin/env bash
set +u
DOCKER_IMAGE=authelia/authelia
if [[ "${BUILDKITE_LABEL}" == ":hammer_and_wrench: Unit Test" ]]; then
tar -czf authelia-public_html.tar.gz -C dist public_html
sha256sum authelia-public_html.tar.gz > authelia-public_html.tar.gz.sha256
fi
if [[ "${BUILDKITE_LABEL}" =~ ":docker: Build Image" ]]; then
echo "--- :docker: Saving artifacts for :buildkite: :docker: :github: releases"
# Save binary for buildkite and github artifacts
if [[ "${ARCH}" != "coverage" ]]; then
docker create --name authelia-binary "${DOCKER_IMAGE}:latest"
docker cp authelia-binary:/app/authelia "./authelia-${OS}-${ARCH}"
docker rm -f authelia-binary
tar -czf "authelia-${OS}-${ARCH}.tar.gz" "authelia-${OS}-${ARCH}" authelia.service config.template.yml
sha256sum "authelia-${OS}-${ARCH}.tar.gz" > "authelia-${OS}-${ARCH}.tar.gz.sha256"
fi
# Saving image for push to docker hub
docker save "${DOCKER_IMAGE}" | zstdmt -T0 -12 > "authelia-image-${ARCH}.tar.zst"
fi
if [[ "${BUILDKITE_LABEL}" =~ ":debian: Build Package" ]]; then
if [[ "${BUILDKITE_TAG}" != "" ]]; then
echo "--- :debian: Saving artifacts for :github: release"
for f in *.deb; do mv "$f" "$(echo "$f" | sed s/${BUILDKITE_TAG//v}-1_//)"; done
else
echo "--- :debian: Saving artifacts for :buildkite: release"
VERSION=$(git describe --long --tags | sed 's/^v//;s/\([^-]*-g\)/r\1/;s/-/./g')
for f in *.deb; do mv "$f" "$(echo "$f" | sed s/${VERSION}-1_//)"; done
fi
sha256sum "authelia_${PACKAGE}.deb" > "authelia_${PACKAGE}.deb.sha256"
fi