Skip to content

Update main.yml

Update main.yml #261

Workflow file for this run

name: CI
on:
push:
workflow_dispatch: # This allows you to manually trigger the workflow from the GitHub UI
jobs:
prepare: # separate job to generate tag name exactly once based on the date
runs-on: ubuntu-latest
outputs:
TAG_NAME: ${{ steps.generate_tag_name.outputs.TAG_NAME }} # map step output to job output
steps:
- name: Generate tag name
id: generate_tag_name
run: echo "TAG_NAME=$(date +'%Y-%m-%d-%H%M%S')" >> $GITHUB_OUTPUT
build:
needs: prepare
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
include:
- os: ubuntu-latest
CMAKE_ARGS: ""
- os: macos-latest
CMAKE_ARGS: -DCMAKE_CXX_COMPILER=clang++ -DCMAKE_C_COMPILER=clang -DCMAKE_OSX_DEPLOYMENT_TARGET=10.9
- os: windows-latest
CMAKE_ARGS: -G"Visual Studio 17 2022" -A"x64"
steps:
- name: Transfer variable TAG_NAME between jobs to be available as step output in this job
id: generate_tag_name
run: echo "TAG_NAME=${{needs.prepare.outputs.TAG_NAME}}" >> $GITHUB_OUTPUT
- uses: actions/checkout@v4
with:
path: contrib
- name: Setup cmake
uses: jwlawson/actions-setup-cmake@v2
with:
cmake-version: '3.29.x'
- name: Install prerequisites
shell: bash
run: |
if [ "$RUNNER_OS" == "Linux" ]; then
sudo apt-get -y install make autoconf automake tar patch libtool gcc
elif [ "$RUNNER_OS" == "Windows" ]; then
# choco install important_windows_software
echo "Nothing to install"
elif [ "$RUNNER_OS" == "macOS" ]; then
brew install autoconf automake libtool
else
echo "$RUNNER_OS not supported"
exit 1
fi
- name: Set up Visual Studio shell
uses: egor-tensin/vs-shell@v2
with:
arch: x64
- name: Build contrib
run: |
mkdir "${{ github.workspace }}/contrib-build"
cd "${{ github.workspace }}/contrib-build"
cmake ${{ matrix.CMAKE_ARGS }} -DBUILD_TYPE=ALL -DNUMBER_OF_JOBS=4 ${{ github.workspace }}/contrib
cmake ${{ matrix.CMAKE_ARGS }} -DBUILD_TYPE=OPENMP -DNUMBER_OF_JOBS=4 ${{ github.workspace }}/contrib
- name: Configure Git for Tagging
if: github.event_name == 'workflow_dispatch'
run: |
git config --global user.name 'GitHub Actions'
git config --global user.email '[email protected]'
- name: Create and Push Tag
if: github.event_name == 'workflow_dispatch'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
cd "${{ github.workspace }}/contrib"
git tag ${{ steps.generate_tag_name.outputs.TAG_NAME }}
git push origin ${{ steps.generate_tag_name.outputs.TAG_NAME }}
shell: bash
- name: Clean build and package
if: github.event_name == 'workflow_dispatch'
run: |
cd "${{ github.workspace }}/contrib-build"
rm -rf archives src CMakeFiles
tar czf "contrib_build-${{ runner.os }}.tar.gz" $(ls -d lib) $(ls -d bin) $(ls -d include) $(ls -d share)
shell: bash
- name: Create Release
if: github.event_name == 'workflow_dispatch'
id: create_release
uses: softprops/action-gh-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ steps.generate_tag_name.outputs.TAG_NAME }}
files: |
${{ github.workspace }}/contrib-build/contrib_build-${{runner.os}}.tar.gz