Update build.yml #14
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# see | ||
# https://github.com/sarnobat/github_workflow_action_tutorial.c/blob/main/.github/workflows/cmake-multi-platform.yml | ||
name: Build | ||
on: | ||
push: | ||
branches: [ master, actionBuild ] # Or your main branch name | ||
pull_request: | ||
branches: [ master, actionBuild ] | ||
jobs: | ||
build: | ||
needs: create_release | ||
runs-on: ${{ matrix.os }} | ||
strategy: | ||
# Set fail-fast to false to ensure that feedback is delivered for all matrix combinations. Consider changing this to true when your workflow is stable. | ||
fail-fast: false | ||
# Set up a matrix to run the following 3 configurations: | ||
# 1. <Windows, Release, latest MSVC compiler toolchain on the default runner image, default generator> | ||
# 2. <Linux, Release, latest GCC compiler toolchain on the default runner image, default generator> | ||
# 3. <Linux, Release, latest Clang compiler toolchain on the default runner image, default generator> | ||
# | ||
# To add more build types (Release, Debug, RelWithDebInfo, etc.) customize the build_type list. | ||
matrix: | ||
os: [ubuntu-latest, windows-latest, macos-latest] | ||
build_type: [Release] | ||
c_compiler: [gcc, clang, cl] | ||
include: | ||
- os: windows-latest | ||
c_compiler: cl | ||
cpp_compiler: cl | ||
suffix: win | ||
binary: ./build/Release/hello2.Windows.exe | ||
- os: ubuntu-latest | ||
c_compiler: gcc | ||
cpp_compiler: g++ | ||
suffix: linux | ||
binary: ./build/hello2.Linux | ||
- os: ubuntu-latest | ||
c_compiler: clang | ||
cpp_compiler: clang++ | ||
suffix: linux | ||
binary: ./build/hello2.Linux | ||
- os: macos-latest | ||
c_compiler: clang | ||
cpp_compiler: clang++ | ||
suffix: darwin | ||
binary: ./build/hello2.Darwin | ||
exclude: | ||
- os: windows-latest | ||
c_compiler: gcc | ||
- os: macos-latest | ||
c_compiler: gcc | ||
- os: macos-latest | ||
c_compiler: cl | ||
- os: windows-latest | ||
c_compiler: clang | ||
- os: ubuntu-latest | ||
c_compiler: cl | ||
# - os: ubuntu-latest | ||
# c_compiler: clang | ||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v3 | ||
- name: Set up dependencies (if any) | ||
# Example: Install required packages | ||
run: | | ||
sudo apt-get update | ||
sudo apt-get install -y make gcc libncurses-dev libpcre3 libpcre3-dev | ||
- name: Build with Make | ||
run: | | ||
./configure | ||
make -j$(nproc) # -j$(nproc) for parallel builds | ||
- name: Tag the repository | ||
shell: bash | ||
id: tag | ||
run: | | ||
# See https://docs.github.com/en/get-started/using-git/dealing-with-special-characters-in-branch-and-tag-names | ||
TAG=v$(date -Iseconds | sed 's/[T:\+]/-/g') | ||
echo "$TAG" | ||
echo "tag=$TAG" >> $GITHUB_OUTPUT | ||
git config --global user.name "GitHub Action" | ||
git config --global user.email "[email protected]" | ||
git tag -a $TAG -m "Published version $TAG" ${GITHUB_SHA} | ||
git push origin $TAG | ||
find . | ||
- name: Upload | ||
uses: actions/upload-release-asset@v1 | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
with: | ||
upload_url: ${{ needs.create_release.outputs.upload_url }} | ||
asset_path: ${{ matrix.binary }} | ||
asset_name: ccze.${{ matrix.os }}.${{ matrix.c_compiler }} | ||
asset_content_type: application/octet-stream |