Publish #33
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: Publish | |
| on: | |
| workflow_dispatch: | |
| inputs: | |
| tag_name: | |
| description: 'Tag name for release' | |
| required: false | |
| default: nightly | |
| push: | |
| tags: | |
| - v[0-9]+.[0-9]+.[0-9]+ | |
| jobs: | |
| # Setup step is left here for future use, does nothing useful in this state | |
| setup: | |
| runs-on: ubuntu-latest | |
| outputs: | |
| build_type: ${{ steps.build.outputs.build_type }} | |
| steps: | |
| - name: Export build information | |
| id: build | |
| run: | | |
| printf "build_type=Release\n" >> $GITHUB_OUTPUT | |
| # Based on https://github.com/msys2/setup-msys2/blob/main/examples/cmake.yml | |
| # Windows-MSVC | |
| Windows-MSVC: | |
| needs: setup | |
| name: ${{ matrix.icon }} windows (${{matrix.platform}}, ${{matrix.compiler}}-${{matrix.compiler-ver}}) | |
| runs-on: ${{matrix.runs-on}} | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| runs-on: ["windows-2025"] | |
| sys: [windows] | |
| icon: ['⬜'] | |
| buildenv: [VS2022] | |
| compiler: ["MSVC"] | |
| platform: ["x86_64"] | |
| mode: ["cxx23"] | |
| build-type: ["Release"] | |
| target : ["incplot"] | |
| cmake-override: [""] | |
| include: | |
| - compiler: "MSVC" | |
| compiler-ver: "19" | |
| steps: | |
| - name: '🧰 Checkout' | |
| uses: actions/checkout@v5 | |
| with: | |
| submodules: recursive | |
| - uses: TheMrMilchmann/setup-msvc-dev@v3 | |
| with: | |
| arch: ${{matrix.platform}} | |
| - name: 'Configure' | |
| shell: bash | |
| run: cmake --preset ${{matrix.compiler}}_${{matrix.build-type}} ${{matrix.cmake-override}} | |
| - name: '🚧 Build' | |
| run: cmake --build build --target ${{matrix.target}} | |
| - name: Package | |
| run: cpack --config build/CPackConfig.cmake | |
| - uses: actions/upload-artifact@v4 | |
| with: | |
| name: ${{matrix.target}}_${{matrix.sys}}_msvc_${{matrix.platform}} | |
| path: | | |
| build/${{matrix.target}}_${{matrix.sys}}_msvc_${{matrix.platform}}.zip | |
| retention-days: 1 | |
| # Based on https://github.com/msys2/setup-msys2/blob/main/examples/cmake.yml | |
| Windows-MSYS: | |
| needs: setup | |
| name: ${{ matrix.icon }} windows (${{matrix.platform}}, ${{matrix.buildenv}}, ${{matrix.compiler}}-${{matrix.compiler-ver}}) | |
| runs-on: ${{ matrix.runs-on }} | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| runs-on: ["windows-2025"] | |
| sys: [windows] | |
| icon: ['🟦'] | |
| buildenv: [MSYS2] | |
| msystem: [ucrt64] | |
| compiler: ["gcc"] | |
| build-type: ["Release"] | |
| platform: ["x86_64"] | |
| target : ["incplot"] | |
| cmake-override: [""] | |
| include: | |
| - compiler: "gcc" | |
| compiler-ver: "15" | |
| add-to-pacboy: "" | |
| defaults: | |
| run: | |
| shell: msys2 {0} | |
| steps: | |
| - name: '🧰 Checkout' | |
| uses: actions/checkout@v5 | |
| with: | |
| submodules: recursive | |
| - name: '${{ matrix.icon }} Setup MSYS2' | |
| uses: msys2/setup-msys2@v2.27.0 | |
| with: | |
| msystem: ${{matrix.msystem}} | |
| update: true | |
| install: >- | |
| git | |
| make | |
| pacboy: >- | |
| toolchain:p | |
| ${{matrix.add-to-pacboy}} | |
| cmake:p | |
| ninja:p | |
| - name: 'Configure' | |
| run: cmake --preset ${{matrix.compiler}}_${{matrix.build-type}} ${{matrix.cmake-override}} | |
| - name: '🚧 Build' | |
| run: cmake --build build --target ${{matrix.target}} | |
| - name: Package | |
| run: cpack --config build/CPackConfig.cmake | |
| - uses: actions/upload-artifact@v4 | |
| with: | |
| name: ${{matrix.target}}_${{matrix.sys}}_gnu_${{matrix.platform}} | |
| path: | | |
| build/${{matrix.target}}_${{matrix.sys}}_gnu_${{matrix.platform}}.zip | |
| retention-days: 1 | |
| # Based on https://github.com/tcbrindle/flux/blob/main/.github/workflows/linux.yml | |
| Linux-Ubuntu: | |
| needs: setup | |
| name: ${{ matrix.icon }} linux (${{matrix.platform}}, ${{matrix.compiler}}-${{matrix.compiler-ver}}) | |
| runs-on: ${{ matrix.runs-on }} | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| icon: ['🟧'] | |
| sys: [linux] | |
| runs-on: [ubuntu-latest, ubuntu-24.04-arm] | |
| compiler: ["gcc"] | |
| build-type: ["Release"] | |
| target : ["incplot"] | |
| cmake-override: [""] | |
| include: | |
| - runs-on: ubuntu-latest | |
| compiler: "gcc" | |
| platform: "x86_64" | |
| compiler-ver: "14" | |
| cxx: g++-14 | |
| install: | | |
| sudo apt install gcc-14 g++-14 | |
| sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-14 100 --slave /usr/bin/g++ g++ /usr/bin/g++-14 --slave /usr/bin/gcov gcov /usr/bin/gcov-14 | |
| sudo update-alternatives --set gcc /usr/bin/gcc-14 | |
| - runs-on: ubuntu-24.04-arm | |
| compiler: "gcc" | |
| platform: "arm64" | |
| compiler-ver: "14" | |
| cxx: g++-14 | |
| install: | | |
| sudo apt install gcc-14 g++-14 | |
| sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-14 100 --slave /usr/bin/g++ g++ /usr/bin/g++-14 --slave /usr/bin/gcov gcov /usr/bin/gcov-14 | |
| sudo update-alternatives --set gcc /usr/bin/gcc-14 | |
| outputs: | |
| version: ${{ steps.build.outputs.version }} | |
| steps: | |
| - name: '🧰 Checkout' | |
| uses: actions/checkout@v5 | |
| with: | |
| submodules: recursive | |
| - name: Create Build Environment | |
| run: | | |
| ${{matrix.install}} | |
| - name: Configure | |
| run: | | |
| cmake --preset ${{matrix.compiler}}_${{matrix.build-type}} ${{matrix.cmake-override}} | |
| - name: '🚧 Build' | |
| run: cmake --build build --target ${{matrix.target}} | |
| - name: Package | |
| run: cpack --config build/CPackConfig.cmake | |
| - uses: actions/upload-artifact@v4 | |
| with: | |
| name: ${{matrix.target}}_${{matrix.sys}}_${{matrix.platform}} | |
| path: | | |
| build/${{matrix.target}}_${{matrix.sys}}_${{matrix.platform}}.tar.gz | |
| retention-days: 1 | |
| - name: Export version | |
| id: build | |
| run: | | |
| printf 'version<<END\n' >> $GITHUB_OUTPUT | |
| ./build/incplot --version | head -n 1 >> $GITHUB_OUTPUT | |
| printf 'END\n' >> $GITHUB_OUTPUT | |
| macOS: | |
| needs: setup | |
| name: ${{ matrix.icon }} macos (${{matrix.platform}}, ${{matrix.compiler}}-${{matrix.compiler-ver}}) | |
| runs-on: ${{ matrix.runs-on }} | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| icon: ['⬛'] | |
| sys: [macos] | |
| runs-on: [macos-14, macos-13] | |
| compiler: ["gcc"] | |
| compiler-ver: ["14"] | |
| build-type: ["Release"] | |
| target : ["incplot"] | |
| include: | |
| - runs-on: macos-14 | |
| platform: "arm64" | |
| - runs-on: macos-13 | |
| platform: "x86_64" | |
| - compiler: "gcc" | |
| compiler-ver: "14" | |
| cmake-override: "-DCMAKE_C_COMPILER=gcc-14 -DCMAKE_CXX_COMPILER=g++-14" | |
| install: | |
| steps: | |
| - name: '🧰 Checkout' | |
| uses: actions/checkout@v5 | |
| with: | |
| submodules: recursive | |
| - name: Setup Cpp | |
| uses: aminya/setup-cpp@v1 | |
| with: | |
| setup-cpp: true | |
| compiler: ${{matrix.compiler}}-${{matrix.compiler-ver}} | |
| - name: Create Build Environment | |
| run: | | |
| ${{matrix.install}} | |
| - name: Configure | |
| run: | | |
| cmake --preset ${{matrix.compiler}}_${{matrix.build-type}} ${{matrix.cmake-override}} | |
| - name: '🚧 Build' | |
| run: cmake --build build --target ${{matrix.target}} | |
| - name: Package | |
| run: cpack --config build/CPackConfig.cmake | |
| - uses: actions/upload-artifact@v4 | |
| with: | |
| name: ${{matrix.target}}_${{matrix.sys}}_${{matrix.platform}} | |
| path: | | |
| build/${{matrix.target}}_${{matrix.sys}}_${{matrix.platform}}.tar.gz | |
| retention-days: 1 | |
| publish: | |
| needs: [Windows-MSVC, Windows-MSYS, Linux-Ubuntu, macOS] | |
| runs-on: ubuntu-latest | |
| env: | |
| GH_REPO: ${{ github.repository }} | |
| GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| permissions: | |
| contents: write | |
| steps: | |
| # Must perform checkout first, since it deletes the target directory | |
| # before running, and would therefore delete the downloaded artifacts | |
| - uses: actions/checkout@v4 | |
| - uses: actions/download-artifact@v4 | |
| - name: Install dependencies | |
| run: sudo apt-get update && sudo apt-get install -y gettext-base | |
| - if: github.event_name == 'workflow_dispatch' | |
| run: echo "TAG_NAME=${{ github.event.inputs.tag_name }}" >> $GITHUB_ENV | |
| - if: github.event_name == 'schedule' | |
| run: echo 'TAG_NAME=nightly' >> $GITHUB_ENV | |
| - if: github.event_name == 'push' | |
| run: | | |
| TAG_NAME=${{ github.ref }} | |
| echo "TAG_NAME=${TAG_NAME#refs/tags/}" >> $GITHUB_ENV | |
| - if: env.TAG_NAME == 'nightly' | |
| run: | | |
| (echo 'SUBJECT=incplot development build'; | |
| echo 'PRERELEASE=--prerelease') >> $GITHUB_ENV | |
| gh release delete nightly --yes || true | |
| git push origin :nightly || true | |
| - if: env.TAG_NAME != 'nightly' | |
| run: | | |
| (echo 'SUBJECT=incplot release build'; | |
| echo 'PRERELEASE=') >> $GITHUB_ENV | |
| gh release delete stable --yes || true | |
| git push origin :stable || true | |
| # `sha256sum` outputs <sha> <path>, so we cd into each dir to drop the | |
| # containing folder from the output. | |
| - run: | | |
| for i in incplot*; do | |
| ( | |
| cd $i || exit | |
| sha256sum * >> $GITHUB_WORKSPACE/shasum.txt | |
| ) | |
| done | |
| - name: Publish release | |
| env: | |
| INCPLOT_VERSION: ${{ needs.Linux-Ubuntu.outputs.version }} | |
| run: | | |
| envsubst < "$GITHUB_WORKSPACE/.github/workflows/notes.md" > "$RUNNER_TEMP/notes.md" | |
| echo '```' >> "$RUNNER_TEMP/notes.md" | |
| cat shasum.txt >> "$RUNNER_TEMP/notes.md" | |
| echo '```' >> "$RUNNER_TEMP/notes.md" | |
| gh release create $TAG_NAME $PRERELEASE --notes-file "$RUNNER_TEMP/notes.md" --title "$INCPLOT_VERSION" --target $GITHUB_SHA incplot_linux_x86_64/* incplot_linux_arm64/* incplot_windows_msvc_x86_64/* incplot_windows_gnu_x86_64/* incplot_macos_arm64/* incplot_macos_x86_64/* shasum.txt |