Skip to content

Commit

Permalink
Feat: Create release and upload artefacts on tagging (#567)
Browse files Browse the repository at this point in the history
feat(CI): Create automatic releases

fix(deps): Adjust dependabot updates
  • Loading branch information
GoetzGoerisch authored Jul 20, 2023
1 parent c888ec4 commit 96071ba
Show file tree
Hide file tree
Showing 2 changed files with 186 additions and 158 deletions.
2 changes: 1 addition & 1 deletion .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ updates:
directory: "/"
target-branch: "development"
schedule:
interval: "daily"
interval: "weekly"

- package-ecosystem: "docker"
directory: "/"
Expand Down
342 changes: 185 additions & 157 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,162 +5,190 @@ on:
push:
pull_request:
branches: [main, development]
merge_group:
merge_group:

jobs:
build-linux:
strategy:
matrix:
os: [ubuntu-20.04, ubuntu-22.04]
build_type: [Debug, Release]
arch: ["386", "amd64"]
runs-on: ${{matrix.os}}
env:
CMAKE_INSTALL_PREFIX: ${{ github.workspace }}/install
steps:
- name: Checkout Code
uses: actions/checkout@v3.5.3
with:
path: UmatiDashboardOpcUaClient
submodules: recursive
fetch-depth: 0
- name: Build UmatiDashboardOpcUaClient with dependencies
# yamllint disable rule:line-length
run: |
#! /bin/bash
LIBCPP_VERSION="$(dpkg -s libstdc++6 | grep Version | awk '{match($0,"[0-9]+.[0-9].[0-9]",a)}END{print a[0]}')" # yamllint disable-line rule:line-length
mkdir -p build
cd build || exit
#shellcheck disable=SC2296
cmake ../UmatiDashboardOpcUaClient/.github/ -DCMAKE_INSTALL_PREFIX:PATH="${{ env.CMAKE_INSTALL_PREFIX }}" \
-DCMAKE_BUILD_TYPE="${{matrix.build_type}}" -DPAHO_WITH_SSL=1 -DBUILD_DEB_PACKAGE:BOOL=1 -DDEB_PACKAGE_LIBCPP_VERSION="$LIBCPP_VERSION"
cmake --build . -j
cd Dashboard-Client-build
make package
# yamllint enable rule:line-length
- name: Run Tests
run: |
#! /bin/bash
cd build/Dashboard-Client-build || exit
ctest -V -C "${{matrix.build_type}}"
- name: Run integration test cacert_test
run: |
#! /bin/bash
cd UmatiDashboardOpcUaClient/Tests/integration/cacert_test || exit
./genCerts.sh
cp "${{ github.workspace }}/build/Dashboard-Client-build/Tests/unit/TestCaCertificate" .
docker-compose up -d
./evaluateTest.sh
- name: Upload Artefacts
uses: actions/upload-artifact@v3
with:
name: UmatiDashboardOpcUaClient-${{matrix.build_type}}-${{matrix.os}}-${{matrix.arch}}
path: |
${{ env.CMAKE_INSTALL_PREFIX }}/bin
${{ env.CMAKE_INSTALL_PREFIX }}/share/DashboardOpcUaClient
- name: Upload Debian package
uses: actions/upload-artifact@v3
with:
name: dashboardopcuaclient-${{matrix.build_type}}-${{matrix.os}}-${{matrix.arch}}.deb
path: |
${{ env.CMAKE_INSTALL_PREFIX }}/*.deb
build-windows:
strategy:
matrix:
os: [windows-2019, windows-2022]
build_type: [Debug, Release]
arch: ["386", "amd64"]
runs-on: ${{matrix.os}}
env:
CMAKE_INSTALL_PREFIX: ${{ github.workspace }}/install
steps:
- name: Checkout Code
uses: actions/checkout@v3.5.3
with:
path: UmatiDashboardOpcUaClient
submodules: recursive
fetch-depth: 0
- name: Build UmatiDashboardOpcUaClient with dependencies
shell: pwsh
# yamllint disable rule:line-length
run: |
#shellcheck disable=SC1073,SC1050,SC1141,SC1083,SC1072,SC2296
$matrixarch = "${{matrix.arch}}"
if($matrixarch -eq "386"){$arch="Win32"}
if($matrixarch -eq "amd64"){$arch="x64"}
mkdir -p build
cd build || exit
cmake ../UmatiDashboardOpcUaClient/.github/ -DCMAKE_INSTALL_PREFIX:PATH=${{ env.CMAKE_INSTALL_PREFIX }} -A "$arch" -DPAHO_WITH_SSL=1
cmake --build . -j --config ${{matrix.build_type}}
# yamllint enable rule:line-length
- name: Run Tests
shell: pwsh
run: |
cd build/Dashboard-Client-build || exit
ctest -V -C ${{matrix.build_type}}
- name: Download CA Certs
shell: pwsh
run: |
cd ${{ env.CMAKE_INSTALL_PREFIX }}
mkdir -p bin/certs
curl https://curl.se/ca/cacert.pem -o bin/certs/cacert.pem -s
- name: Upload Artefacts
uses: actions/upload-artifact@v3
with:
name: UmatiDashboardOpcUaClient-${{matrix.build_type}}-${{matrix.os}}-${{matrix.arch}}
path: |
${{ env.CMAKE_INSTALL_PREFIX }}/bin
${{ env.CMAKE_INSTALL_PREFIX }}/share/DashboardOpcUaClient
docker:
runs-on: ubuntu-22.04
env:
# Check if this is not a pull request and GITHUB_TOKEN is set
# As all env variables are strings, you need to compaire against "== 'true'" (not "== true")
IS_NOT_PR: ${{ !github.head_ref && true }}
steps:
- name: Checkout Code
uses: actions/checkout@v3.5.3
with:
path: UmatiDashboardOpcUaClient
submodules: recursive
fetch-depth: 0
- name: Set up QEMU
uses: docker/setup-qemu-action@v2.2.0
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2.9.1
- name: PrepareReg Names
# yamllint disable rule:line-length
run: |
#! /bin/bash
#shellcheck disable=SC2296
echo IMAGE_REPOSITORY="$(echo "${{ github.repository }}" | tr '[:upper:]' '[:lower:]')" >> "$GITHUB_ENV"
echo IMAGE_TAG="$(echo "${{ github.ref }}" | tr '[:upper:]' '[:lower:]' | awk '{sub(/([^\/]*\/){2}/,""); gsub(/\/|_/, "-")}1')" >> "$GITHUB_ENV"
# yamllint enable rule:line-length
- name: Login to GitHub Container Registry
uses: docker/login-action@v2.2.0
if: env.IS_NOT_PR == 'true' && ${{ github.actor }} != 'dependabot'
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build Docker Release
uses: docker/build-push-action@v4.1.1
with:
file: "./UmatiDashboardOpcUaClient/Dockerfile"
context: ./UmatiDashboardOpcUaClient
platforms: linux/amd64
push: ${{env.IS_NOT_PR == 'true'}}
tags: |
ghcr.io/${{ env.IMAGE_REPOSITORY }}:${{ env.IMAGE_TAG }}
provenance: false
- name: Run integration test mqtt
if: ${{env.IS_NOT_PR == 'true'}}
run : |
#! /bin/bash
python -m pip install --upgrade pip
cd ./UmatiDashboardOpcUaClient/Tests/integration/mqtt_test || exit
pip install -r requirements.txt
docker compose up -d
./waitForContainer.sh
python -m unittest discover test_mqtt_sampleserver
build-linux:
strategy:
matrix:
os: [ubuntu-20.04, ubuntu-22.04]
build_type: [Debug, Release]
arch: ["386", "amd64"]
runs-on: ${{matrix.os}}
env:
CMAKE_INSTALL_PREFIX: ${{ github.workspace }}/install
steps:
- name: Checkout Code
uses: actions/checkout@v3.5.3
with:
path: UmatiDashboardOpcUaClient
submodules: recursive
fetch-depth: 0
- name: Build UmatiDashboardOpcUaClient with dependencies
# yamllint disable rule:line-length
run: |
#! /bin/bash
LIBCPP_VERSION="$(dpkg -s libstdc++6 | grep Version | awk '{match($0,"[0-9]+.[0-9].[0-9]",a)}END{print a[0]}')" # yamllint disable-line rule:line-length
mkdir -p build
cd build || exit
#shellcheck disable=SC2296
cmake ../UmatiDashboardOpcUaClient/.github/ -DCMAKE_INSTALL_PREFIX:PATH="${{ env.CMAKE_INSTALL_PREFIX }}" \
-DCMAKE_BUILD_TYPE="${{matrix.build_type}}" -DPAHO_WITH_SSL=1 -DBUILD_DEB_PACKAGE:BOOL=1 -DDEB_PACKAGE_LIBCPP_VERSION="$LIBCPP_VERSION"
cmake --build . -j
cd Dashboard-Client-build
make package
# yamllint enable rule:line-length
- name: Run Tests
run: |
#! /bin/bash
cd build/Dashboard-Client-build || exit
ctest -V -C "${{matrix.build_type}}"
- name: Run integration test cacert_test
run: |
#! /bin/bash
cd UmatiDashboardOpcUaClient/Tests/integration/cacert_test || exit
./genCerts.sh
cp "${{ github.workspace }}/build/Dashboard-Client-build/Tests/unit/TestCaCertificate" .
docker-compose up -d
./evaluateTest.sh
- name: Upload Artefacts
uses: actions/upload-artifact@v3
with:
name: UmatiDashboardOpcUaClient-${{matrix.build_type}}-${{matrix.os}}-${{matrix.arch}}
path: |
${{ env.CMAKE_INSTALL_PREFIX }}/bin
${{ env.CMAKE_INSTALL_PREFIX }}/share/DashboardOpcUaClient
- name: Upload Debian package
uses: actions/upload-artifact@v3
with:
name: dashboardopcuaclient-${{matrix.build_type}}-${{matrix.os}}-${{matrix.arch}}.deb
path: |
${{ env.CMAKE_INSTALL_PREFIX }}/*.deb
build-windows:
strategy:
matrix:
os: [windows-2019, windows-2022]
build_type: [Debug, Release]
arch: ["386", "amd64"]
runs-on: ${{matrix.os}}
env:
CMAKE_INSTALL_PREFIX: ${{ github.workspace }}/install
steps:
- name: Checkout Code
uses: actions/checkout@v3.5.3
with:
path: UmatiDashboardOpcUaClient
submodules: recursive
fetch-depth: 0
- name: Build UmatiDashboardOpcUaClient with dependencies
shell: pwsh
# yamllint disable rule:line-length
run: |
#shellcheck disable=SC1073,SC1050,SC1141,SC1083,SC1072,SC2296
$matrixarch = "${{matrix.arch}}"
if($matrixarch -eq "386"){$arch="Win32"}
if($matrixarch -eq "amd64"){$arch="x64"}
mkdir -p build
cd build || exit
cmake ../UmatiDashboardOpcUaClient/.github/ -DCMAKE_INSTALL_PREFIX:PATH=${{ env.CMAKE_INSTALL_PREFIX }} -A "$arch" -DPAHO_WITH_SSL=1
cmake --build . -j --config ${{matrix.build_type}}
# yamllint enable rule:line-length
- name: Run Tests
shell: pwsh
run: |
cd build/Dashboard-Client-build || exit
ctest -V -C ${{matrix.build_type}}
- name: Download CA Certs
shell: pwsh
run: |
cd ${{ env.CMAKE_INSTALL_PREFIX }}
mkdir -p bin/certs
curl https://curl.se/ca/cacert.pem -o bin/certs/cacert.pem -s
- name: Upload Artefacts
uses: actions/upload-artifact@v3
with:
name: UmatiDashboardOpcUaClient-${{matrix.build_type}}-${{matrix.os}}-${{matrix.arch}}
path: |
${{ env.CMAKE_INSTALL_PREFIX }}/bin
${{ env.CMAKE_INSTALL_PREFIX }}/share/DashboardOpcUaClient
docker:
runs-on: ubuntu-22.04
env:
# Check if this is not a pull request and GITHUB_TOKEN is set
# As all env variables are strings, you need to compaire against "== 'true'" (not "== true")
IS_NOT_PR: ${{ !github.head_ref && true }}
steps:
- name: Checkout Code
uses: actions/checkout@v3.5.3
with:
path: UmatiDashboardOpcUaClient
submodules: recursive
fetch-depth: 0
- name: Set up QEMU
uses: docker/setup-qemu-action@v2.2.0
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2.9.1
- name: PrepareReg Names
# yamllint disable rule:line-length
run: |
#! /bin/bash
#shellcheck disable=SC2296
echo IMAGE_REPOSITORY="$(echo "${{ github.repository }}" | tr '[:upper:]' '[:lower:]')" >> "$GITHUB_ENV"
echo IMAGE_TAG="$(echo "${{ github.ref }}" | tr '[:upper:]' '[:lower:]' | awk '{sub(/([^\/]*\/){2}/,""); gsub(/\/|_/, "-")}1')" >> "$GITHUB_ENV"
# yamllint enable rule:line-length
- name: Login to GitHub Container Registry
uses: docker/login-action@v2.2.0
if: env.IS_NOT_PR == 'true' && ${{ github.actor }} != 'dependabot'
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build Docker Release
uses: docker/build-push-action@v4.1.1
with:
file: "./UmatiDashboardOpcUaClient/Dockerfile"
context: ./UmatiDashboardOpcUaClient
platforms: linux/amd64
push: ${{env.IS_NOT_PR == 'true'}}
tags: |
ghcr.io/${{ env.IMAGE_REPOSITORY }}:${{ env.IMAGE_TAG }}
provenance: false
- name: Run integration test mqtt
if: ${{env.IS_NOT_PR == 'true'}}
run: |
#! /bin/bash
python -m pip install --upgrade pip
cd ./UmatiDashboardOpcUaClient/Tests/integration/mqtt_test || exit
pip install -r requirements.txt
docker compose up -d
./waitForContainer.sh
python -m unittest discover test_mqtt_sampleserver
release:
runs-on: ubuntu-22.04
needs: [build-linux, build-windows]
if: startsWith(github.ref, 'refs/tags/')
steps:
- name: Download artifact
uses: dawidd6/action-download-artifact@v2.27.0
with:
github_token: ${{secrets.GITHUB_TOKEN}}
workflow: build.yml
workflow_conclusion: success
repo: ${{ github.repository }}
if_no_artifact_found: fail
skip_unpack: true
- name: Checksum
run: |
#! /bin/bash
sha256sum ./*.zip > SHA256-checksums
- name: Display structure of downloaded files
run: ls -R
- name: Release
uses: softprops/action-gh-release@v0.1.15
with:
generate_release_notes: true
fail_on_unmatched_files: true
files: |
./*.zip
SHA256-checksums

0 comments on commit 96071ba

Please sign in to comment.