Release #101
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Release | |
on: | |
schedule: | |
- cron: '0 1 * * 6' # Every saturday at 1am | |
push: | |
tags: | |
- v* | |
pull_request: | |
branches: [ master, develop ] | |
workflow_dispatch: | |
jobs: | |
prepare: | |
runs-on: ubuntu-latest | |
outputs: | |
docker_image: ${{ steps.prepare.outputs.docker_image }} | |
docker_buildimage: ${{ steps.prepare.outputs.docker_buildimage }} | |
tag: ${{ steps.prepare.outputs.tag }} | |
platforms: ${{ steps.prepare.outputs.platforms }} | |
docker_variables: ${{ steps.prepare.outputs.docker_variables }} | |
steps: | |
- name: Prepare | |
id: prepare | |
run: | | |
DOCKER_IMAGE=leosac/leosac | |
DOCKER_BUILDIMAGE=leosac/leosac-buildsystem | |
DOCKER_PLATFORMS=linux/amd64,linux/arm64,linux/arm/v7,linux/arm/v6 | |
TAG=edge | |
if [[ $GITHUB_REF == refs/tags/* ]]; then | |
TAG=${GITHUB_REF#refs/tags/v} | |
fi | |
if [ "${{ github.event_name }}" = "schedule" ]; then | |
TAG=weekly | |
fi | |
if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then | |
TAG=snapshot | |
fi | |
if [ "${{ github.event_name }}" = "pull_request" ]; then | |
DOCKER_PLATFORMS=linux/amd64 | |
fi | |
echo ::set-output name=docker_image::${DOCKER_IMAGE} | |
echo ::set-output name=docker_buildimage::${DOCKER_BUILDIMAGE} | |
echo ::set-output name=platforms::${DOCKER_PLATFORMS} | |
echo ::set-output name=tag::${TAG} | |
build: | |
runs-on: ubuntu-latest | |
needs: prepare | |
strategy: | |
matrix: | |
buildsystem: [ 'debian-bullseye', 'debian-buster' ] | |
platform: [ 'amd64', 'arm64', 'arm/v7', 'arm/v6' ] | |
steps: | |
- uses: actions/checkout@v2 | |
with: | |
submodules: recursive | |
- name: Prepare | |
id: prepare | |
run: | | |
ARTIFACT_NAME="${{ matrix.buildsystem }}_${{ matrix.platform }}" | |
ARTIFACT_NAME="${ARTIFACT_NAME////-}" | |
MAJOR=`grep "DLEOSAC_VERSION_MAJOR=" ${GITHUB_WORKSPACE}/CMakeLists.txt | egrep -o '([0-9]+)'` | |
MINOR=`grep "DLEOSAC_VERSION_MINOR=" ${GITHUB_WORKSPACE}/CMakeLists.txt | egrep -o '([0-9]+)'` | |
PATCH=`grep "DLEOSAC_VERSION_PATCH=" ${GITHUB_WORKSPACE}/CMakeLists.txt | egrep -o '([0-9]+)'` | |
VERSION=${MAJOR}.${MINOR}.${PATCH} | |
if [[ $GITHUB_REF != refs/tags/* ]]; then | |
VERSION=$(date +%s):${VERSION} | |
fi | |
echo ::set-output name=artifact_name::${ARTIFACT_NAME} | |
echo ::set-output name=version::${VERSION} | |
- name: Setup QEMU | |
uses: docker/setup-qemu-action@v1 | |
- name: Run ${{ matrix.platform }} on ${{ matrix.buildsystem }} | |
if: success() | |
run: docker run --entrypoint=/bin/bash | |
--platform linux/${{ matrix.platform }} | |
-v "${GITHUB_WORKSPACE}:/tmp/leosac" | |
${{needs.prepare.outputs.docker_buildimage}}:${{matrix.buildsystem}} | |
-c "DISTRIB=${{ matrix.buildsystem }} && | |
TARGETPLATFORM=linux/${{ matrix.platform }} && | |
VERSION=${{ steps.prepare.outputs.version }} && | |
TAG=${{ needs.prepare.outputs.tag }} && | |
BUILD_DATE=$(date -u +'%Y-%m-%dT%H:%M:%SZ') && | |
VCS_REF=${GITHUB_SHA::8} && | |
export DISTRIB TARGETPLATFORM VERSION TAG BUILD_DATE VCS_REF && /tmp/leosac/docker_scripts/build_leosac.sh" | |
- uses: actions/upload-artifact@v3 | |
if: success() | |
with: | |
name: ${{ steps.prepare.outputs.artifact_name }} | |
path: build/packages/${{ matrix.buildsystem }}/linux/${{ matrix.platform }}/*.deb | |
docker: | |
runs-on: ubuntu-latest | |
needs: [ prepare, build ] | |
steps: | |
- name: Prepare | |
id: prepare | |
run: | | |
TAGS="--tag ${{ needs.prepare.outputs.docker_image }}:${{ needs.prepare.outputs.tag }}" | |
if [[ ${{ needs.prepare.outputs.tag }} =~ ^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$ ]]; then | |
TAGS="$TAGS --tag ${{ needs.prepare.outputs.docker_image }}:latest" | |
fi | |
echo ::set-output name=buildx_args::--platform ${{ needs.prepare.outputs.platforms }} \ | |
${TAGS} | |
- uses: actions/checkout@v2 | |
with: | |
submodules: recursive | |
- name: Setup QEMU | |
uses: docker/setup-qemu-action@v1 | |
- name: Setup Docker Buildx | |
uses: docker/setup-buildx-action@v1.6.0 | |
- name: Docker Login | |
if: success() | |
uses: docker/login-action@v1.14.1 | |
with: | |
username: ${{ secrets.DOCKER_USERNAME }} | |
password: ${{ secrets.DOCKER_PASSWORD }} | |
- uses: actions/download-artifact@v3 | |
if: success() | |
with: | |
name: debian-bullseye_amd64 | |
path: build/packages/debian-bullseye/linux/amd64 | |
- uses: actions/download-artifact@v3 | |
if: success() | |
with: | |
name: debian-bullseye_arm64 | |
path: build/packages/debian-bullseye/linux/arm64 | |
- uses: actions/download-artifact@v3 | |
if: success() | |
with: | |
name: debian-bullseye_arm-v7 | |
path: build/packages/debian-bullseye/linux/arm/v7 | |
- uses: actions/download-artifact@v3 | |
if: success() | |
with: | |
name: debian-bullseye_arm-v6 | |
path: build/packages/debian-bullseye/linux/arm/v6 | |
- name: Build Docker Leosac Main | |
if: success() && github.event_name != 'pull_request' | |
run: | | |
docker buildx build --push ${{ steps.prepare.outputs.buildx_args }} --file ./docker/Dockerfile.main build/packages/debian-bullseye | |
- name: Inspect image | |
if: always() && github.event_name != 'pull_request' | |
run: | | |
docker buildx imagetools inspect ${{ needs.prepare.outputs.docker_image }}:${{ needs.prepare.outputs.tag }} | |
jfrog: | |
runs-on: ubuntu-latest | |
needs: [ prepare, build ] | |
steps: | |
- uses: actions/download-artifact@v3 | |
if: success() | |
with: | |
path: packages | |
- name: Upload artifacts to Debian repository | |
run: | | |
POOL=test | |
DEBPREFIX= | |
if [ "${{ github.event_name }}" = "push" ]; then | |
POOL=main | |
fi | |
if [ "${{ github.event_name }}" = "pull_request" ]; then | |
POOL=pull-request | |
DEBPREFIX=$(date +%s)- | |
fi | |
PACKAGES=packages | |
for pkg in ${PACKAGES}/debian-* ; do | |
distri=${pkg%_*} | |
distri=${distri#*-} | |
arch=${pkg#*linux-} | |
arch=${arch%/*} | |
for deb in ${pkg}/*.deb ; do | |
curl -H "X-JFrog-Art-Api:${{ secrets.JFROG_API_KEY }}" -XPUT "https://leosac.jfrog.io/artifactory/default-debian/pool/${POOL}/l/leosac/${distri}/${DEBPREFIX}$(basename -- $deb);deb.distribution=${distri};deb.component=main;deb.architecture=${arch}" -T ${deb} | |
done | |
done |