Fix condition for package step in workflow #15
This file contains hidden or 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
| name: CMake on multiple platforms | |
| on: | |
| push: | |
| branches: [ "master" ] | |
| tags: | |
| - 'v*' | |
| pull_request: | |
| branches: [ "master" ] | |
| permissions: | |
| contents: write | |
| jobs: | |
| build: | |
| runs-on: ${{ matrix.os }} | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| os: [ubuntu-latest] | |
| build_type: [Release] | |
| c_compiler: [gcc, clang, cl] | |
| include: | |
| - os: ubuntu-latest | |
| c_compiler: gcc | |
| cpp_compiler: g++ | |
| - os: ubuntu-latest | |
| c_compiler: clang | |
| cpp_compiler: clang++ | |
| exclude: | |
| - os: ubuntu-latest | |
| c_compiler: cl | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Install Dependencies (Ubuntu) | |
| if: matrix.os == 'ubuntu-latest' | |
| run: | | |
| sudo apt-get update | |
| sudo apt-get install -y \ | |
| build-essential \ | |
| cmake \ | |
| ninja-build \ | |
| pkg-config \ | |
| gcc g++ \ | |
| clang \ | |
| libgtk-4-dev \ | |
| libwebkitgtk-6.0-dev \ | |
| libjson-glib-dev | |
| - name: Set reusable strings | |
| id: strings | |
| shell: bash | |
| run: | | |
| echo "build-output-dir=${{ github.workspace }}/build" >> "$GITHUB_OUTPUT" | |
| - name: Configure CMake | |
| run: > | |
| cmake -B ${{ steps.strings.outputs.build-output-dir }} | |
| -DCMAKE_CXX_COMPILER=${{ matrix.cpp_compiler }} | |
| -DCMAKE_C_COMPILER=${{ matrix.c_compiler }} | |
| -DCMAKE_BUILD_TYPE=${{ matrix.build_type }} | |
| -S ${{ github.workspace }} | |
| - name: Build | |
| run: cmake --build ${{ steps.strings.outputs.build-output-dir }} --config ${{ matrix.build_type }} | |
| - name: Run unit tests (hb_tests) | |
| working-directory: ${{ steps.strings.outputs.build-output-dir }} | |
| run: ctest -C ${{ matrix.build_type }} -R hb_tests --output-on-failure | |
| tag: | |
| needs: build | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 # Required for tags | |
| - name: Get latest tag | |
| id: latest | |
| run: | | |
| git fetch --tags | |
| tag=$(git tag --sort=-v:refname | head -n 1) | |
| if [ -z "$tag" ]; then tag="v0.0.0"; fi | |
| echo "latest=$tag" >> $GITHUB_OUTPUT | |
| - name: Calculate next tag | |
| id: next | |
| run: | | |
| tag="${{ steps.latest.outputs.latest }}" | |
| echo "Current tag: $tag" | |
| IFS='.' read -r major minor patch <<< "${tag#v}" | |
| patch=$((patch + 1)) | |
| new_tag="v$major.$minor.$patch" | |
| echo "new_tag=$new_tag" >> $GITHUB_OUTPUT | |
| - name: Create and push tag | |
| run: | | |
| git tag ${{ steps.next.outputs.new_tag }} | |
| git push origin ${{ steps.next.outputs.new_tag }} | |
| package: | |
| needs: tag | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| - name: Install Dependencies (Ubuntu) | |
| run: | | |
| sudo apt-get update | |
| sudo apt-get install -y \ | |
| build-essential \ | |
| cmake \ | |
| ninja-build \ | |
| pkg-config \ | |
| gcc g++ \ | |
| clang \ | |
| libgtk-4-dev \ | |
| libwebkitgtk-6.0-dev \ | |
| libjson-glib-dev \ | |
| dpkg-dev fakeroot | |
| - name: Set reusable strings | |
| id: strings | |
| shell: bash | |
| run: | | |
| echo "build-output-dir=${{ github.workspace }}/build" >> "$GITHUB_OUTPUT" | |
| - name: Configure CMake (Release) | |
| run: > | |
| cmake -B ${{ steps.strings.outputs.build-output-dir }} | |
| -DCMAKE_C_COMPILER=gcc | |
| -DCMAKE_CXX_COMPILER=g++ | |
| -DCMAKE_BUILD_TYPE=Release | |
| -S ${{ github.workspace }} | |
| - name: Build | |
| run: cmake --build ${{ steps.strings.outputs.build-output-dir }} --config Release --parallel | |
| - name: Make DEB with CPack | |
| working-directory: ${{ steps.strings.outputs.build-output-dir }} | |
| run: cpack -G DEB | |
| - name: Upload DEB artifact | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: hudbox-deb | |
| path: ${{ steps.strings.outputs.build-output-dir }}/*.deb | |
| - name: Create GitHub Release and upload .deb | |
| uses: softprops/action-gh-release@v2 | |
| with: | |
| files: ${{ steps.strings.outputs.build-output-dir }}/*.deb | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |