Skip to content

Build

Build #384

Workflow file for this run

name: Build
on:
workflow_dispatch:
push:
# Cronjob
schedule:
- cron: 5 5 * * *
jobs:
get-version:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
with:
repository: openSYDE/openSYDE.git
path: './opensyde'
ref: master
- name: apt install
run: |
sudo apt update && sudo apt install -y pcregrep
- name: Read version from file
run: |
MAJOR=`pcregrep -io1 '#\s*define\s+PROJECT_VERSION_MAJOR\s+(\d+)' opensyde/opensyde_syde_sup/src/version_config.hpp`
MINOR=`pcregrep -io1 '#\s*define\s+PROJECT_VERSION_MINOR\s+(\d+)' opensyde/opensyde_syde_sup/src/version_config.hpp`
RELEASE=`pcregrep -io1 '#\s*define\s+PROJECT_VERSION_RELEASE\s+(\d+)' opensyde/opensyde_syde_sup/src/version_config.hpp`
BUILD=`pcregrep -io1 '#\s*define\s+PROJECT_VERSION_BUILD\s+(\d+)' opensyde/opensyde_syde_sup/src/version_config.hpp`
echo "${MAJOR}.${MINOR}r${RELEASE}" > version.txt
cat version.txt
- uses: actions/cache/save@v3
id: cache
if: always()
with:
path: .
key: ${{ github.run_id }}
enableCrossOsArchive: true
build-ubuntu:
runs-on: ubuntu-20.04
needs: get-version
steps:
- uses: actions/cache/restore@v3
id: cache
with:
path: .
key: ${{ github.run_id }}
fail-on-cache-miss: true
enableCrossOsArchive: true
- name: Set up GCC
uses: egor-tensin/setup-gcc@v1
with:
version: 9
platform: x64
- name: Get CMake
uses: symbitic/install-cmake@master
- name: Build
run: |
mkdir ./opensyde/opensyde_syde_sup/build
cd ./opensyde/opensyde_syde_sup/build
cmake ../pjt -DCMAKE_TOOLCHAIN_FILE=../pjt/toolchain_ubuntu_64bit.cmake
cmake --build . --target all -- -j13
tar -czvf SYDEsup-Ubuntu.tar.gz SYDEsup
shell: bash
- uses: actions/upload-artifact@v3
with:
name: SYDEsup-Ubuntu
path: ./opensyde/opensyde_syde_sup/build/SYDEsup-Ubuntu.tar.gz
build-alpine:
runs-on: ubuntu-latest
needs: get-version
steps:
- uses: actions/cache/restore@v3
id: cache
with:
path: .
key: ${{ github.run_id }}
fail-on-cache-miss: true
enableCrossOsArchive: true
- name: Setup latest Alpine Linux
uses: jirutka/setup-alpine@v1
with:
branch: v3.16
packages: >
linux-headers
build-base
cmake
ninja
automake
autoconf
git
libtool
perl
tar
gzip
wget
- name: Build libressl
run: |
wget https://ftp.openbsd.org/pub/OpenBSD/LibreSSL/libressl-3.7.0.tar.gz
tar xzf libressl-3.7.0.tar.gz
cd libressl-3.7.0
mkdir build-ninja
cd build-ninja
cmake -G"Ninja" ..
ninja
ninja test
ninja install
shell: alpine.sh --root {0}
- name: Build
run: |
mkdir ./opensyde/opensyde_syde_sup/build
cd ./opensyde/opensyde_syde_sup/build
cmake ../pjt -DCMAKE_TOOLCHAIN_FILE=../pjt/toolchain_ubuntu_64bit.cmake
cmake --build . --target all -- -j13
tar -czvf SYDEsup-Alpine.tar.gz SYDEsup
shell: alpine.sh --root {0}
- uses: actions/upload-artifact@v3
with:
name: SYDEsup-Alpine
path: ./opensyde/opensyde_syde_sup/build/SYDEsup-Alpine.tar.gz
build-windows:
runs-on: windows-latest
needs: get-version
steps:
- uses: actions/cache/restore@v3
id: cache
with:
path: .
key: ${{ github.run_id }}
fail-on-cache-miss: true
enableCrossOsArchive: true
- name: 'Setup MSYS2'
uses: msys2/setup-msys2@v2
with:
msystem: mingw32
update: true
install: >-
git
make
p7zip
pacboy: >-
toolchain:p
cmake:p
ninja:p
- name: Build
run: |
mkdir opensyde/opensyde_syde_sup/build
cd opensyde/opensyde_syde_sup/build
cmake.exe ../pjt -G Ninja -DCMAKE_BUILD_TYPE=Release "-DCMAKE_TOOLCHAIN_FILE=../pjt/toolchain_windows.cmake"
cmake.exe --build . --target all -- -j13
7z a SYDEsup-Windows.zip SYDEsup.exe
shell: msys2 {0}
- uses: actions/upload-artifact@v3
with:
name: SYDEsup-Windows
path: ./opensyde/opensyde_syde_sup/build/SYDEsup-Windows.zip
deploy:
runs-on: ubuntu-latest
permissions:
contents: write
needs: [get-version, build-ubuntu, build-alpine, build-windows]
if: github.ref == 'refs/heads/master'
steps:
- uses: actions/cache/restore@v3
id: cache
with:
path: .
key: ${{ github.run_id }}
fail-on-cache-miss: true
enableCrossOsArchive: true
- name: Set version variable
run: |
VERSION=`cat $GITHUB_WORKSPACE/version.txt`
echo "version=$VERSION" >> $GITHUB_ENV
- uses: actions/download-artifact@v3
with:
name: SYDEsup-Ubuntu
path: release
- uses: actions/download-artifact@v3
with:
name: SYDEsup-Alpine
path: release
- uses: actions/download-artifact@v3
with:
name: SYDEsup-Windows
path: release
- uses: ncipollo/release-action@v1
with:
name: "SYDEsup V${{ env.version }}"
artifacts: "release/*"
artifactErrorsFailBuild: true
allowUpdates: true
commit: master
tag: release-v${{ env.version }}
docker:
runs-on: ubuntu-latest
needs: [get-version, build-ubuntu, build-alpine]
if: github.ref == 'refs/heads/master'
strategy:
matrix:
image: [
{ dist: Alpine },
{ dist: Ubuntu }
]
steps:
- uses: actions/cache/restore@v3
id: cache
with:
path: .
key: ${{ github.run_id }}
fail-on-cache-miss: true
enableCrossOsArchive: true
- uses: actions/download-artifact@v3
with:
name: SYDEsup-${{ matrix.image.dist }}
path: release
- name: Version
run: |
VERSION=$(cat version.txt)
echo "version=$VERSION" >> $GITHUB_ENV
DIST=$(echo ${{ matrix.image.dist }} | tr [:upper:] [:lower:])
echo "dist=$DIST" >> $GITHUB_ENV
echo "date=$(date --utc)" >> $GITHUB_ENV
TAGS="developsessions/sydesup:$DIST,developsessions/sydesup:v$VERSION-$DIST"
if [ "${{ matrix.image.dist }}" == "Alpine" ]; then TAGS="${TAGS},developsessions/sydesup:latest"; fi
echo "tags=$TAGS" >> $GITHUB_ENV
cd release
tar -xzf SYDEsup-${{ matrix.image.dist }}.tar.gz
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Login to Docker Hub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Build and push
uses: docker/build-push-action@v4
with:
build-contexts: |
project=${{ github.workspace }}/release
push: true
file: Dockerfile.${{ env.dist }}
tags: ${{ env.tags }}
build-args: |
BUILD_DATE=${{ env.date }}
VCS_REF=${{ github.sha }}
BUILD_VERSION=${{ env.version }}