Skip to content

Commit baa777d

Browse files
Added version information (build number, hash id)
1 parent 50910f1 commit baa777d

File tree

10 files changed

+294
-174
lines changed

10 files changed

+294
-174
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
name: Build and push docker container
2+
3+
inputs:
4+
arch:
5+
required: true
6+
description: "Architecture amd64/arm64"
7+
run_number:
8+
required: true
9+
description: "Workflow run number"
10+
commit_hash:
11+
required: true
12+
description: "Git commit hash"
13+
username:
14+
required: true
15+
description: "User name"
16+
token:
17+
required: true
18+
description: "Auth token"
19+
20+
runs:
21+
using: "composite"
22+
steps:
23+
- id: repo_name
24+
uses: ASzc/change-string-case-action@v1
25+
with:
26+
string: ${{ github.repository }}
27+
28+
- name: Checkout repository
29+
uses: actions/checkout@v3
30+
with:
31+
submodules: recursive
32+
33+
# Workaround: https://github.com/docker/build-push-action/issues/461
34+
- name: Setup Docker buildx
35+
uses: docker/setup-buildx-action@79abd3f86f79a9d68a23c75a09a9a85889262adf
36+
37+
# Login against a Docker registry except on PR
38+
- name: Log into registry ghcr.io
39+
uses: docker/login-action@28218f9b04b4f3f62068d7b6ce6ca5b26e35336c
40+
with:
41+
registry: ghcr.io
42+
username: ${{ inputs.username }}
43+
password: ${{ inputs.token }}
44+
45+
- name: Print run number
46+
run: |
47+
echo "Run number for docker file = ${{ github.run_number }}"
48+
shell: bash
49+
50+
# https://github.com/docker/build-push-action
51+
- name: Build and push docker container to ghcr.io
52+
id: build-and-push
53+
uses: docker/build-push-action@ac9327eae2b366085ac7f6a2d02df8aa8ead720a
54+
with:
55+
push: true
56+
context: .
57+
platforms: linux/${{ inputs.arch }}
58+
file: Dockerfile.${{ inputs.arch }}
59+
labels: ${{ steps.meta.outputs.labels }}
60+
build-args: |
61+
GITHUB_RUN_NUMBER=${{ inputs.run_number }}
62+
GITHUB_COMMIT_HASH=${{ inputs.commit_hash }}
63+
tags: |
64+
ghcr.io/${{ steps.repo_name.outputs.lowercase }}/sua:latest_${{ inputs.arch }}
65+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
name: Build native binaries
2+
3+
inputs:
4+
arch:
5+
required: true
6+
description: "Architecture amd64/arm64"
7+
run_number:
8+
required: true
9+
description: "Workflow run number"
10+
11+
runs:
12+
using: "composite"
13+
steps:
14+
- uses: actions/checkout@v3
15+
with:
16+
submodules: recursive
17+
18+
# Remove apt repos that are known to break from time to time
19+
- name: Remove broken apt repos
20+
run: |
21+
for apt_file in `grep -lr microsoft /etc/apt/sources.list.d/`; do sudo rm $apt_file; done
22+
shell: bash
23+
24+
- name: Install tools
25+
run: |
26+
sudo apt-get install apt-transport-https --yes
27+
sudo apt-get -y update
28+
sudo apt-get -y upgrade
29+
sudo apt-get -y install autoconf binutils cmake file \
30+
gcc g++ git libtool make \
31+
build-essential libcurl4-openssl-dev \
32+
binutils-aarch64-linux-gnu gcc-9-aarch64-linux-gnu g++-9-aarch64-linux-gnu \
33+
python3 python3-pip python3-setuptools python3-wheel ninja-build python3-pip \
34+
libselinux1-dev libmount-dev libmount1 libblkid-dev
35+
pip3 install meson
36+
shell: bash
37+
38+
- name: Print run number
39+
run: |
40+
echo "Run number for native = ${{ inputs.run_number }}"
41+
shell: bash
42+
43+
- name: Build for ${{ inputs.arch }}
44+
run: |
45+
mkdir build_${{ inputs.arch }}
46+
./scripts/build_openssl_${{ inputs.arch }}.sh
47+
./scripts/build_glib_${{ inputs.arch }}.sh
48+
cd build_${{ inputs.arch }}
49+
cmake -DCMAKE_INSTALL_PREFIX=../dist_${{ inputs.arch }} -DCMAKE_TOOLCHAIN_FILE=../cmake/linux/${{ matrix.arch }}/toolchain.cmake -DOPENSSL_ROOT_DIR=../build_${{ matrix.arch }} -DOPENSSL_CRYPTO_LIBRARY=../build_${{ matrix.arch }}/lib/libcrypto.so -DSUA_BUILD_NUMBER=${{ inputs.run_number }} ..
50+
make
51+
make install
52+
shell: bash
53+
54+
#- name: Run unit tests
55+
# if: ${{ inputs.arch=='amd64' }}
56+
# run: |
57+
# cd dist_${{ inputs.arch }}/utest
58+
# ./TestSDVSelfUpdateAgent
59+
60+
- name: Compress artifacts
61+
run: tar -czvf sua_${{ inputs.arch }}.tar.gz --exclude=lib/cmake --exclude=lib/pkgconfig -C dist_${{ matrix.arch }} bin/sdv-self-update-agent lib
62+
shell: bash
63+

.github/workflows/docker-publish.yml

-86
This file was deleted.

.github/workflows/main.yaml

+102
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,102 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches: [ main ]
6+
pull_request:
7+
branches: [ main ]
8+
9+
jobs:
10+
build-docker-image:
11+
runs-on: ubuntu-latest
12+
permissions:
13+
contents: read
14+
packages: write
15+
id-token: write
16+
strategy:
17+
matrix:
18+
arch: [ amd64, arm64 ]
19+
steps:
20+
- uses: actions/checkout@v3
21+
with:
22+
submodules: recursive
23+
24+
- name: Build Docker image
25+
uses: ./.github/actions/build-docker-image
26+
with:
27+
arch: ${{ matrix.arch }}
28+
run_number: ${{ github.run_number }}
29+
commit_hash: ${{ github.sha }}
30+
username: ${{ github.actor }}
31+
token: ${{ secrets.GITHUB_TOKEN }}
32+
33+
push-docker-image:
34+
runs-on: ubuntu-latest
35+
needs: build-docker-image
36+
steps:
37+
- uses: actions/checkout@v3
38+
with:
39+
submodules: recursive
40+
41+
- id: repo_name
42+
uses: ASzc/change-string-case-action@v1
43+
with:
44+
string: ${{ github.repository }}
45+
46+
- name: Log into registry ghcr.io
47+
uses: docker/login-action@28218f9b04b4f3f62068d7b6ce6ca5b26e35336c
48+
with:
49+
registry: ghcr.io
50+
username: ${{ github.actor }}
51+
password: ${{ secrets.GITHUB_TOKEN }}
52+
53+
- name: Create merged manifest and push
54+
env:
55+
REPO: ghcr.io/softwaredefinedvehicle/sdv-self-update-agent
56+
run: |
57+
docker buildx imagetools create -t ghcr.io/${{ steps.repo_name.outputs.lowercase }}/sua:latest ghcr.io/${{ steps.repo_name.outputs.lowercase }}/sua:latest_arm64 ghcr.io/${{ steps.repo_name.outputs.lowercase }}/sua:latest_amd64
58+
59+
build-native-binary:
60+
runs-on: ubuntu-latest
61+
strategy:
62+
matrix:
63+
arch: [ arm64, amd64 ]
64+
steps:
65+
- uses: actions/checkout@v3
66+
with:
67+
submodules: recursive
68+
69+
- name: Build native binary
70+
id: build-native-binary
71+
uses: ./.github/actions/build-native-binary
72+
with:
73+
arch: ${{ matrix.arch }}
74+
run_number: ${{ github.run_number }}
75+
76+
- name: Upload ${{ matrix.arch }} artifact to workspace
77+
uses: actions/upload-artifact@v3
78+
with:
79+
name: sua_${{ matrix.arch }}.tar.gz
80+
path: sua_${{ matrix.arch }}.tar.gz
81+
82+
upload-native-binary:
83+
runs-on: ubuntu-latest
84+
needs: build-native-binary
85+
steps:
86+
- uses: actions/checkout@v3
87+
with:
88+
submodules: recursive
89+
90+
- name: Download artifacts
91+
uses: actions/download-artifact@v2
92+
93+
- name: Upload artifacts to build results
94+
uses: marvinpinto/action-automatic-releases@latest
95+
with:
96+
repo_token: ${{ secrets.GITHUB_TOKEN }}
97+
draft: false
98+
prerelease: true
99+
automatic_release_tag: build_${{ github.run_number }}
100+
title: "Build ${{ github.run_number }}"
101+
files: "**/sua_*.tar.gz"
102+

0 commit comments

Comments
 (0)