Skip to content

Building using a build matrix #11

Building using a build matrix

Building using a build matrix #11

Workflow file for this run

name: build
on:
workflow_dispatch:
push:
branches:
- main
tags:
- v*.**
merge_group:
pull_request:
types: [opened, synchronize, reopened]
env:
CARGO_TERM_COLOR: always
jobs:
build:
strategy:
matrix:
runs-on: [ubuntu-latest, macos-latest]
include:
- arch: "linux-amd64"
runs-on: "ubuntu-latest"
- arch: "macos-arm64"
runs-on: "macos-latest"
runs-on: ${{ matrix.runs-on }}
steps:
- uses: actions/checkout@v4
with:
submodules: 'true'
- name: Build
run: cargo build --release --verbose
- name: Run tests
run: cargo test --verbose
- name: Archive csaf-validator (linux amd64)
uses: actions/upload-artifact@v4
with:
name: csaf-validator-${{ matrix.arch }}
path: target/release/csaf-validator
publish:
runs-on: ubuntu-latest
needs:
- build
#if: startsWith(github.ref, 'refs/tags/v') && !contains(github.ref, 'beta') && !contains(github.ref, 'alpha')
steps:
- name: Determine Version
run: |
# determine version from tag
export VERSION=$(echo "${GITHUB_REF}" | cut -d "/" -f3)
if [[ $VERSION != v* ]]
then
export VERSION=""
echo "Building version-less (main or feature branch)"
else
echo "Building as ${VERSION}"
fi
# store version in GitHub environment file
echo "version=$VERSION" >> $GITHUB_ENV
- uses: actions/download-artifact@v4
with:
path: csaf-validator
pattern: csaf-validator-*
merge-multiple: true
- run: |
ls -R
# just some magic to make the released files work with multiple platforms
mv csaf-validator-linux-amd64/csaf-validator csaf-validator-linux-amd64/csaf-validator-linux-amd64
mv csaf-validator-macos-arm64/csaf-validator csaf-validator-macos-arm64/csaf-validator-macos-arm64
#- name: Create Release
# id: create_release
# uses: softprops/action-gh-release@v2
# with:
# token: ${{ secrets.GITHUB_TOKEN }}
# name: ${{ env.version }}
# draft: false
# prerelease: false
# fail_on_unmatched_files: true
# files: |
# csaf-validator-*/csaf-validator-*