From a53fc6206d019f5af51e5a7f00d372bc3fdb8abe Mon Sep 17 00:00:00 2001 From: Morton Jonuschat Date: Sat, 14 Dec 2024 12:45:53 -0800 Subject: [PATCH] [FEATURE] Reworked buildflows --- .github/workflows/build.yml | 52 ++++++ .github/workflows/build_all.yml | 100 ----------- .github/workflows/build_check_cache.yml | 58 ------- .github/workflows/build_deps.yml | 131 --------------- .github/workflows/build_prusa.yml | 211 ------------------------ CMakeLists.txt | 2 +- 6 files changed, 53 insertions(+), 501 deletions(-) create mode 100644 .github/workflows/build.yml delete mode 100644 .github/workflows/build_all.yml delete mode 100644 .github/workflows/build_check_cache.yml delete mode 100644 .github/workflows/build_deps.yml delete mode 100644 .github/workflows/build_prusa.yml diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 00000000000..401d6a59bd3 --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,52 @@ +name: Build PrusaSlicer (BOSS) + +on: + push: + # branches: + # - boss + # - release/* + paths: + - 'deps/**' + - 'src/**' + - '**/CMakeLists.txt' + - 'version.inc' + - 'resources/**' + - ".github/workflows/*.yml" + - "build_release_linux.sh" + - "build_release_macos.sh" + - "build_win.bat" + + pull_request: + branches: + - boss + - release/* + paths: + - 'deps/**' + - 'src/**' + - '**/CMakeLists.txt' + - 'version.inc' + - ".github/workflows/*.yml" + + workflow_dispatch: + +concurrency: + group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} + cancel-in-progress: true + +jobs: + build: + name: Build PrusaSlicer (BOSS) + strategy: + fail-fast: false + matrix: + platform: [linux, osx, windows] + uses: ./.github/workflows/build_${{ matrix.platform }}.yml + secrets: inherit + + release: + name: Release + uses: ./.github/workflows/release.yml + needs: [build] + secrets: inherit + permissions: + contents: write diff --git a/.github/workflows/build_all.yml b/.github/workflows/build_all.yml deleted file mode 100644 index c8968b9096a..00000000000 --- a/.github/workflows/build_all.yml +++ /dev/null @@ -1,100 +0,0 @@ -name: Build all - -on: - push: - # branches: - # - boss - # - release/* - paths: - - 'deps/**' - - 'src/**' - - '**/CMakeLists.txt' - - 'version.inc' - - 'resources/**' - - ".github/workflows/*.yml" - - "build_release_linux.sh" - - "build_release_macos.sh" - - "build_win.bat" - - pull_request: - branches: - - boss - - release/* - paths: - - 'deps/**' - - 'src/**' - - '**/CMakeLists.txt' - - 'version.inc' - - ".github/workflows/*.yml" - - workflow_dispatch: # allows for manual dispatch - inputs: - build-deps-only: - description: 'Only build dependencies (bypasses caching)' - type: boolean - default: false - -concurrency: - group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} - cancel-in-progress: true - - -jobs: - build_flatpak: - name: Build PrusaSlicer+BOSS (Flatpak) - runs-on: ubuntu-latest - container: - image: bilelmoussaoui/flatpak-github-actions:gnome-47 - options: --privileged - env: - date: - ver: - ver_pure: - steps: - - name: Checkout - uses: actions/checkout@v4 - - - name: Get the version and date on Ubuntu and macOS - if: inputs.os != 'windows-latest' - run: | - ver_pure=$(grep 'set(SLIC3R_VERSION' version.inc | cut -d '"' -f2) - if [[ "${{ github.event_name }}" == "pull_request" ]]; then - ver="PR-${{ github.event.number }}" - else - ver="$ver_pure+BOSS" - fi - echo "ver=$ver" >> $GITHUB_ENV - echo "ver_pure=$ver_pure" >> $GITHUB_ENV - echo "date=$(date +'%Y%m%d')" >> $GITHUB_ENV - shell: bash - - - uses: flatpak/flatpak-github-actions/flatpak-builder@v6 - with: - bundle: PrusaSlicer.flatpak - manifest-path: .flatpak/io.github.mjonuschat.PrusaSlicer.yml - cache-key: flatpak-builder-${{ github.sha }} - # build_all: - # name: Build All - # strategy: - # fail-fast: false - # matrix: - # include: - # - os: ubuntu-22.04 - # - os: macos-14 - # arch: arm64 - # - os: macos-13 - # arch: x86_64 - # - os: windows-latest - # uses: ./.github/workflows/build_check_cache.yml - # with: - # os: ${{ matrix.os }} - # arch: ${{ matrix.arch }} - # build-deps-only: ${{ inputs.build-deps-only || false }} - # secrets: inherit - # release: - # name: Release - # uses: ./.github/workflows/release.yml - # needs: build_all - # secrets: inherit - # permissions: - # contents: write diff --git a/.github/workflows/build_check_cache.yml b/.github/workflows/build_check_cache.yml deleted file mode 100644 index b5129ed2c14..00000000000 --- a/.github/workflows/build_check_cache.yml +++ /dev/null @@ -1,58 +0,0 @@ -name: Check Cache - -on: - workflow_call: - inputs: - os: - required: true - type: string - arch: - required: false - type: string - build-deps-only: - required: false - type: boolean - -jobs: - check_cache: # determines if there is a cache and outputs variables used in caching process - name: Check Cache - runs-on: ${{ inputs.os }} - outputs: - cache-key: ${{ steps.set_outputs.outputs.cache-key }} - cache-path: ${{ steps.set_outputs.outputs.cache-path }} - valid-cache: ${{ steps.cache_deps.outputs.cache-hit }} - steps: - - name: Checkout - uses: actions/checkout@v4 - - - name: set outputs - id: set_outputs - env: - underscore-arch: ${{ (inputs.os == 'macos-13' || inputs.os == 'macos-14') && '_' || ''}}${{ (inputs.os == 'macos-13' || inputs.os == 'macos-14') && inputs.arch || '' }} # if is macos, make a string that does "_{arch}", else output nothing - dash-arch: ${{ (inputs.os == 'macos-13' || inputs.os == 'macos-14') && '-' || ''}}${{ (inputs.os == 'macos-13' || inputs.os == 'macos-14') && inputs.arch || '' }} # if is macos, make a string that does "-{arch}", else output nothing - dep-folder-name: ${{ (inputs.os == 'windows-latest' || inputs.os == 'macos-13' || inputs.os == 'macos-14') && 'PrusaSlicer_dep' || 'destdir' }} - output-cmd: ${{ inputs.os == 'windows-latest' && '$env:GITHUB_OUTPUT' || '"$GITHUB_OUTPUT"'}} - run: | - echo cache-key=${{ runner.os }}${{ env.dash-arch }}-cache-Prusaslicer_deps-build-${{ hashFiles('deps/**') }} >> ${{ env.output-cmd }} - echo cache-path=${{ github.workspace }}/deps/build${{ env.underscore-arch }}/${{ env.dep-folder-name }}${{ env.underscore-arch }} >> ${{ env.output-cmd }} - - - name: load cache - id: cache_deps - uses: actions/cache@v4 - with: - path: ${{ steps.set_outputs.outputs.cache-path }} - key: ${{ steps.set_outputs.outputs.cache-key }} - lookup-only: true - - build_deps: # call next step - name: Build Deps - needs: [check_cache] - uses: ./.github/workflows/build_deps.yml - with: - cache-key: ${{ needs.check_cache.outputs.cache-key }} - cache-path: ${{ needs.check_cache.outputs.cache-path }} - valid-cache: ${{ needs.check_cache.outputs.valid-cache == 'true' }} - os: ${{ inputs.os }} - arch: ${{ inputs.arch }} - build-deps-only: ${{ inputs.build-deps-only }} - secrets: inherit diff --git a/.github/workflows/build_deps.yml b/.github/workflows/build_deps.yml deleted file mode 100644 index 1ce49badee5..00000000000 --- a/.github/workflows/build_deps.yml +++ /dev/null @@ -1,131 +0,0 @@ -name: Build dependencies - -on: - workflow_call: - inputs: - cache-key: - required: true - type: string - cache-path: - required: true - type: string - valid-cache: - required: true - type: boolean - os: - required: true - type: string - arch: - required: false - type: string - build-deps-only: - required: false - type: boolean - -jobs: - build_deps: - name: Build Deps - if: inputs.build-deps-only || inputs.valid-cache != true - runs-on: ${{ inputs.os }} - env: - date: - steps: - - # Setup the environment - - name: Checkout - uses: actions/checkout@v4 - - - name: load cached deps - uses: actions/cache@v4 - with: - path: ${{ inputs.cache-path }} - key: ${{ inputs.cache-key }} - - - name: setup dev on Windows - if: inputs.os == 'windows-latest' - uses: microsoft/setup-msbuild@v2 - - - name: Get the date on Ubuntu and macOS - if: inputs.os != 'windows-latest' - run: echo "date=$(date +'%Y%m%d')" >> $GITHUB_ENV - shell: bash - - - name: Get the date on Windows - if: inputs.os == 'windows-latest' - run: echo "date=$(Get-Date -Format 'yyyyMMdd')" | Out-File -Append -FilePath $env:GITHUB_ENV -Encoding utf8 - shell: pwsh - - - # Build Dependencies - - name: Build on Windows - if: inputs.os == 'windows-latest' - working-directory: ${{ github.workspace }} - run: | - choco install strawberryperl - mkdir ${{ github.workspace }}/deps/build - mkdir ${{ github.workspace }}/deps/build/PrusaSlicer_dep - .\build_win.bat -d=.\deps\build\PrusaSlicer_dep -c=Release -r=none -s=deps - .\build_win.bat -d=.\deps\build\PrusaSlicer_dep -c=Release -r=none -s=pack - cd ${{ github.workspace }}/deps/build - - - name: Build on Mac ${{ inputs.arch }} - if: inputs.os == 'macos-13' || inputs.os == 'macos-14' - working-directory: ${{ github.workspace }} - run: | - brew remove -f automake - brew install git gettext texinfo - (cd $(brew --repository homebrew/core)/Formula/a; git checkout 0b91bfb32c1 automake.rb); - HOMEBREW_NO_AUTO_UPDATE=1 HOMEBREW_NO_INSTALL_FROM_API=1 brew install automake - mkdir -p ${{ github.workspace }}/deps/build_${{ inputs.arch }} - mkdir -p ${{ github.workspace }}/deps/build_${{ inputs.arch }}/PrusaSlicer_dep_${{ inputs.arch }} - brew uninstall --ignore-dependencies zstd - ./build_release_macos.sh -dp -a ${{ inputs.arch }} -t 11.3 - brew install zstd - - - name: Build on Ubuntu - if: inputs.os == 'ubuntu-22.04' - working-directory: ${{ github.workspace }} - run: | - sudo apt-get update - sudo apt-get install -y cmake git build-essential autoconf cmake libglu1-mesa-dev libgtk-3-dev libdbus-1-dev libcurl4-openssl-dev libsecret-1-dev libssl-dev - mkdir -p ${{ github.workspace }}/deps/build - mkdir -p ${{ github.workspace }}/deps/build/destdir - sudo ./build_release_linux.sh -ur - sudo chown $USER -R ./ - ./build_release_linux.sh -dr - cd deps/build - tar -czvf PrusaSlicer_dep_ubuntu_$(date +"%Y%m%d").tar.gz destdir - - # Upload Artifacts - - name: Upload Mac ${{ inputs.arch }} artifacts - if: inputs.os == 'macos-13' || inputs.os == 'macos-14' - uses: actions/upload-artifact@v4 - with: - name: PrusaSlicer_dep_mac_${{ inputs.arch }}_${{ env.date }} - path: ${{ github.workspace }}/deps/build_${{ inputs.arch }}/PrusaSlicer_dep*.tar.gz - - - name: Upload Windows artifacts - if: inputs.os == 'windows-latest' - uses: actions/upload-artifact@v4 - with: - name: PrusaSlicer_dep_win64_${{ env.date }} - path: ${{ github.workspace }}/deps/build/PrusaSlicer_dep*.zip - - - name: Upload Ubuntu artifacts - if: inputs.os == 'ubuntu-22.04' - uses: actions/upload-artifact@v4 - with: - name: PrusaSlicer_dep_ubuntu_${{ env.date }} - path: ${{ github.workspace }}/deps/build/PrusaSlicer_dep_ubuntu_*.tar.gz - - build_prusa: - name: Build PrusaSlicer - needs: [build_deps] - if: ${{ !cancelled() && !inputs.build-deps-only && (inputs.valid-cache == true && needs.build_deps.result == 'skipped') || (inputs.valid-cache != true && success()) }} - uses: ./.github/workflows/build_prusa.yml - with: - cache-key: ${{ inputs.cache-key }} - cache-path: ${{ inputs.cache-path }} - os: ${{ inputs.os }} - arch: ${{ inputs.arch }} - secrets: inherit diff --git a/.github/workflows/build_prusa.yml b/.github/workflows/build_prusa.yml deleted file mode 100644 index 2904854c7a9..00000000000 --- a/.github/workflows/build_prusa.yml +++ /dev/null @@ -1,211 +0,0 @@ -name: Build PrusaSlicer - -on: - workflow_call: - inputs: - cache-key: - required: true - type: string - cache-path: - required: true - type: string - os: - required: true - type: string - arch: - required: false - type: string - -jobs: - build_prusa: - name: Build PrusaSlicer - runs-on: ${{ inputs.os }} - env: - date: - ver: - ver_pure: - - steps: - - name: Checkout - uses: actions/checkout@v4 - - - name: load cached deps - uses: actions/cache@v4 - with: - path: ${{ inputs.cache-path }} - key: ${{ inputs.cache-key }} - fail-on-cache-miss: true - - - name: Get the version and date on Ubuntu and macOS - if: inputs.os != 'windows-latest' - run: | - ver_pure=$(grep 'set(SLIC3R_VERSION' version.inc | cut -d '"' -f2) - if [[ "${{ github.event_name }}" == "pull_request" ]]; then - ver="PR-${{ github.event.number }}" - else - ver="$ver_pure+BOSS" - fi - echo "ver=$ver" >> $GITHUB_ENV - echo "ver_pure=$ver_pure" >> $GITHUB_ENV - echo "date=$(date +'%Y%m%d')" >> $GITHUB_ENV - shell: bash - - - name: Get the version and date on Windows - if: inputs.os == 'windows-latest' - run: | - $date = Get-Date -Format 'yyyyMMdd' - $ref = "${{ github.ref }}" - $eventName = "${{ github.event_name }}" - $prNumber = "${{ github.event.number }}" - $versionContent = Get-Content version.inc -Raw - if ($versionContent -match 'set\(SLIC3R_VERSION "(.*?)"\)') { - $ver_pure = $matches[1] - } - if ($eventName -eq 'pull_request') { - $ver = "PR" + $prNumber - } else { - $ver=$ver_pure + "+BOSS" - } - - echo "ver=$ver" | Out-File -Append -FilePath $env:GITHUB_ENV -Encoding utf8 - echo "ver_pure=$ver_pure" | Out-File -Append -FilePath $env:GITHUB_ENV -Encoding utf8 - echo "date=$date" | Out-File -Append -FilePath $env:GITHUB_ENV -Encoding utf8 - echo "date: ${{ env.date }} version: ${{ env.ver }}" - shell: pwsh - -# Mac - - name: Install tools mac - if: inputs.os == 'macos-13' || inputs.os == 'macos-14' - run: | - brew install git gettext automake texinfo tree - mkdir -p ${{ github.workspace }}/deps/build_${{inputs.arch}} - mkdir -p ${{ github.workspace }}/deps/build_${{inputs.arch}}/PrusaSlicer_dep_${{inputs.arch}} - tree ${{ github.workspace }}/deps/build_${{inputs.arch}}/PrusaSlicer_dep_${{inputs.arch}} - - - name: Build slicer mac - if: inputs.os == 'macos-13' || inputs.os == 'macos-14' - working-directory: ${{ github.workspace }} - run: | - ./build_release_macos.sh -s -n -a ${{inputs.arch}} -t 11.3 - - - name: Sign app and notary - if: (github.ref == 'refs/heads/boss' || startsWith(github.ref, 'refs/heads/release/')) && (inputs.os == 'macos-13' || inputs.os == 'macos-14') - working-directory: ${{ github.workspace }} - env: - BUILD_CERTIFICATE_BASE64: ${{ secrets.BUILD_CERTIFICATE_BASE64 }} - P12_PASSWORD: ${{ secrets.P12_PASSWORD }} - KEYCHAIN_PASSWORD: ${{ secrets.KEYCHAIN_PASSWORD }} - CERTIFICATE_ID: ${{ secrets.MACOS_CERTIFICATE_ID }} - run: | - CERTIFICATE_PATH=$RUNNER_TEMP/build_certificate.p12 - KEYCHAIN_PATH=$RUNNER_TEMP/app-signing.keychain-db - echo -n "$BUILD_CERTIFICATE_BASE64" | base64 --decode > $CERTIFICATE_PATH - security create-keychain -p $KEYCHAIN_PASSWORD $KEYCHAIN_PATH - security set-keychain-settings -lut 21600 $KEYCHAIN_PATH - security unlock-keychain -p $KEYCHAIN_PASSWORD $KEYCHAIN_PATH - security import $CERTIFICATE_PATH -P $P12_PASSWORD -A -t cert -f pkcs12 -k $KEYCHAIN_PATH - security list-keychain -d user -s $KEYCHAIN_PATH - security set-key-partition-list -S apple-tool:,apple:,codesign: -s -k $P12_PASSWORD $KEYCHAIN_PATH - codesign --deep --force --verbose --options runtime --timestamp --entitlements ${{ github.workspace }}/.github/scripts/disable_validation.entitlements --sign "$CERTIFICATE_ID" ${{ github.workspace }}/build_${{inputs.arch}}/PrusaSlicer/PrusaSlicer.app - ln -s /Applications ${{ github.workspace }}/build_${{inputs.arch}}/PrusaSlicer/Applications - hdiutil create -volname "PrusaSlicer" -srcfolder ${{ github.workspace }}/build_${{inputs.arch}}/PrusaSlicer -ov -format UDZO PrusaSlicer-${{ env.ver }}+MacOS-${{inputs.arch}}-${{ env.date }}.dmg - codesign --deep --force --verbose --options runtime --timestamp --entitlements ${{ github.workspace }}/.github/scripts/disable_validation.entitlements --sign "$CERTIFICATE_ID" PrusaSlicer-${{ env.ver }}+MacOS-${{inputs.arch}}-${{ env.date }}.dmg - xcrun notarytool store-credentials "notarytool-profile" --apple-id "${{ secrets.APPLE_DEV_ACCOUNT }}" --team-id "${{ secrets.TEAM_ID }}" --password "${{ secrets.APP_PWD }}" - xcrun notarytool submit "PrusaSlicer-${{ env.ver }}+MacOS-${{inputs.arch}}-${{ env.date }}.dmg" --keychain-profile "notarytool-profile" --wait - xcrun stapler staple PrusaSlicer-${{ env.ver }}+MacOS-${{inputs.arch}}-${{ env.date }}.dmg - - - name: Create DMG without notary - if: (github.ref != 'refs/heads/boss' && !startsWith(github.ref, 'refs/heads/release/')) && (inputs.os == 'macos-13' || inputs.os == 'macos-14') - working-directory: ${{ github.workspace }} - run: | - ln -s /Applications ${{ github.workspace }}/build_${{inputs.arch}}/PrusaSlicer/Applications - hdiutil create -volname "PrusaSlicer" -srcfolder ${{ github.workspace }}/build_${{inputs.arch}}/PrusaSlicer -ov -format UDZO PrusaSlicer-${{ env.ver }}+MacOS-${{inputs.arch}}-${{ env.date }}.dmg - - - name: Upload artifacts mac - if: inputs.os == 'macos-13' || inputs.os == 'macos-14' - uses: actions/upload-artifact@v4 - with: - name: PrusaSlicer-${{ env.ver }}+MacOS-${{inputs.arch}}-${{ env.date }} - path: ${{ github.workspace }}/PrusaSlicer-${{ env.ver }}+MacOS-${{inputs.arch}}-${{ env.date }}.dmg - -# Windows - - name: setup MSVC - if: inputs.os == 'windows-latest' - uses: microsoft/setup-msbuild@v2 - - - name: Install nsis - if: inputs.os == 'windows-latest' - run: | - dir "C:/Program Files (x86)/Windows Kits/10/Include" - choco install nsis - - - name: Build slicer Win - if: inputs.os == 'windows-latest' - working-directory: ${{ github.workspace }} - run: .\build_win.bat -d=.\deps\build\PrusaSlicer_dep -c=Release -s=app -r=none - - - name: Create installer Win - if: inputs.os == 'windows-latest' - working-directory: ${{ github.workspace }}/build - run: | - cpack -G NSIS - - - name: Pack app - if: inputs.os == 'windows-latest' - working-directory: ${{ github.workspace }}/build/src/Release - run: | - 7z a -tzip ${{ github.workspace }}\build\PrusaSlicer-${{ env.ver }}+win64-${{ env.date }}.zip resources *.exe *.dll - - - name: Upload artifacts Win zip - if: inputs.os == 'windows-latest' - uses: actions/upload-artifact@v4 - with: - name: PrusaSlicer-${{ env.ver }}+win64-${{ env.date }} - path: ${{ github.workspace }}\build\PrusaSlicer-${{ env.ver }}+win64-${{ env.date }}.zip - - - name: Upload artifacts Win installer - if: inputs.os == 'windows-latest' - uses: actions/upload-artifact@v4 - with: - name: PrusaSlicer-Installer-${{ env.ver }}+win64-${{ env.date }} - path: ${{ github.workspace }}\build\PrusaSlicer-Installer*.exe - -# Ubuntu - - name: Install dependencies - if: inputs.os == 'ubuntu-22.04' - run: | - sudo apt-get update - sudo apt-get install -y cmake git build-essential autoconf cmake libglu1-mesa-dev libgtk-3-dev libdbus-1-dev libcurl4-openssl-dev libsecret-1-dev libssl-dev - - - name: Install dependencies from build_linux.sh - if: inputs.os == 'ubuntu-22.04' - shell: bash - run: sudo ./build_release_linux.sh -ur - - - name: Fix permissions - if: inputs.os == 'ubuntu-22.04' - shell: bash - run: sudo chown $USER -R ./ - - - name: Build slicer - if: inputs.os == 'ubuntu-22.04' - shell: bash - run: | - ./build_release_linux.sh -isr - mv -n ./build/PrusaSlicer-${{ env.ver_pure }}+Linux.tar ./build/PrusaSlicer-${{ env.ver }}+Linux-${{ env.date }}.tar - mv -n ./build/PrusaSlicer-${{ env.ver_pure }}+Linux.AppImage ./build/PrusaSlicer-${{ env.ver }}+Linux-${{ env.date }}.AppImage - chmod +x ./build/PrusaSlicer-${{ env.ver }}+Linux-${{ env.date }}.AppImage - - - name: Upload artifacts Ubuntu (Archive) - if: inputs.os == 'ubuntu-22.04' - uses: actions/upload-artifact@v4 - with: - name: "PrusaSlicer-${{ env.ver }}+Linux-${{ env.date }} (Archive)" - path: './build/PrusaSlicer-${{ env.ver }}+Linux-${{ env.date }}.tar' - - - name: Upload artifacts Ubuntu (AppImage) - if: inputs.os == 'ubuntu-22.04' - uses: actions/upload-artifact@v4 - with: - name: "PrusaSlicer-${{ env.ver }}+Linux-${{ env.date }} (AppImage)" - path: './build/PrusaSlicer-${{ env.ver }}+Linux-${{ env.date }}.AppImage' diff --git a/CMakeLists.txt b/CMakeLists.txt index 339cd5ded86..0e847e067f6 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -634,7 +634,7 @@ endif() # Resources install target, configure fhs.hpp on UNIX if (WIN32) install(DIRECTORY "${SLIC3R_RESOURCES_DIR}/" DESTINATION "./resources") - set(CMAKE_INSTALL_SYSTEM_RUNTIME_LIBS_SKIP TRUE) + set(CMAKE_INSTALL_SYSTEM_RUNTIME_LIBS_SKIP FALSE) include(InstallRequiredSystemLibraries) install (PROGRAMS ${CMAKE_INSTALL_SYSTEM_RUNTIME_LIBS} DESTINATION ".") elseif (SLIC3R_FHS)