-
-
Notifications
You must be signed in to change notification settings - Fork 44
142 lines (136 loc) · 5.39 KB
/
Copy pathrelease.yml
File metadata and controls
142 lines (136 loc) · 5.39 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
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-access-control
DOCKER_BUILDIMAGE=leosac/leosac-buildsystem
DOCKER_PLATFORMS=linux/amd64,linux/arm64,linux/arm/v7
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 "docker_image=${DOCKER_IMAGE}" >> $GITHUB_OUTPUT
echo "docker_buildimage=${DOCKER_BUILDIMAGE}" >> $GITHUB_OUTPUT
echo "platforms=${DOCKER_PLATFORMS}" >> $GITHUB_OUTPUT
echo "tag=${TAG}" >> $GITHUB_OUTPUT
build:
runs-on: ubuntu-latest
needs: prepare
strategy:
matrix:
buildsystem: [ 'debian-bullseye' ]
platform: [ 'amd64', 'arm64', 'arm/v7' ]
steps:
- uses: actions/checkout@v4
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 "artifact_name=${ARTIFACT_NAME}" >> $GITHUB_OUTPUT
echo "version=${VERSION}" >> $GITHUB_OUTPUT
- name: Setup QEMU
uses: docker/setup-qemu-action@v3
- 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@v4
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 "buildx_args=--platform ${{ needs.prepare.outputs.platforms }} ${TAGS}" >> $GITHUB_OUTPUT
- uses: actions/checkout@v4
with:
submodules: recursive
- name: Setup QEMU
uses: docker/setup-qemu-action@v3
- name: Setup Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Docker Login
if: success()
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- uses: actions/download-artifact@v4
if: success()
with:
name: debian-bullseye_amd64
path: build/packages/debian-bullseye/linux/amd64
- uses: actions/download-artifact@v4
if: success()
with:
name: debian-bullseye_arm64
path: build/packages/debian-bullseye/linux/arm64
- uses: actions/download-artifact@v4
if: success()
with:
name: debian-bullseye_arm-v7
path: build/packages/debian-bullseye/linux/arm/v7
- 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 }}