Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 34 additions & 0 deletions .github/actions/setup-cmake/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
name: Set up CMake
description: Install the pinned CMake release used by the macOS and Windows builds

runs:
using: composite
steps:
- name: Install CMake on macOS
if: runner.os == 'macOS'
shell: bash
run: |
version=3.31.0
archive="cmake-$version-macos-universal.tar.gz"
cd "$RUNNER_TEMP"
curl --fail --show-error --silent --location --retry 3 \
"https://github.com/Kitware/CMake/releases/download/v$version/$archive" -o "$archive"
echo "50d5b9f370e71c8eee87c123b7fb9272caf2bf2b372ea7c9423f10f1cd52813b $archive" | shasum -a 256 -c -
tar -xzf "$archive"
echo "$RUNNER_TEMP/cmake-$version-macos-universal/CMake.app/Contents/bin" >> "$GITHUB_PATH"

- name: Install CMake on Windows
if: runner.os == 'Windows'
shell: pwsh
run: |
$version = '3.31.0'
$archive = "cmake-$version-windows-x86_64.zip"
$archivePath = Join-Path $env:RUNNER_TEMP $archive
Invoke-WebRequest "https://github.com/Kitware/CMake/releases/download/v$version/$archive" `
-OutFile $archivePath -MaximumRetryCount 3
$checksum = (Get-FileHash -Algorithm SHA256 $archivePath).Hash
if ($checksum -ne 'f4b499f71cf44115a1d711d4867da3c6bd2f3f4d7121c213ace979757640385c') {
throw 'CMake archive checksum did not match'
}
Expand-Archive -LiteralPath $archivePath -DestinationPath $env:RUNNER_TEMP
Join-Path $env:RUNNER_TEMP "cmake-$version-windows-x86_64\bin" | Add-Content -Path $env:GITHUB_PATH -Encoding utf8
147 changes: 123 additions & 24 deletions .github/workflows/build_all.yml
Original file line number Diff line number Diff line change
@@ -1,51 +1,87 @@
name: Build all

on:
push:
branches:
- main
pull_request:
branches: [master, main]
paths:
- 'deps/**'
- 'src/**'
- '**/CMakeLists.txt'
- 'version.inc'
- 'bbl/**'
- 'resources/**'
- ".github/workflows/build_*.yml"

pull_request:
branches:
- master
paths:
- 'deps/**'
- 'src/**'
- '**/CMakeLists.txt'
- 'version.inc'
- '.github/actions/**'
- ".github/workflows/build_*.yml"
- 'BuildLinux.sh'
- 'BuildMac.sh'
- 'build_win.bat'

workflow_dispatch: # manual dispatch
inputs:
build-deps-only:
description: 'Only build dependencies (bypasses caching)'
type: boolean
default: false

pull_request_target:
branches: [master, main]
types: [closed]

workflow_dispatch:
inputs:
build-deps-only:
description: 'Only build dependencies (bypasses caching)'
type: boolean
default: false

permissions:
contents: read

concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true
group: ${{ github.workflow }}-${{ github.event_name }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: ${{ github.event_name != 'pull_request_target' }}

jobs:
release_metadata:
name: Read merged release version
if: >-
github.event_name == 'pull_request_target' &&
github.event.pull_request.merged &&
github.event.pull_request.base.ref == github.event.repository.default_branch
runs-on: ubuntu-latest
outputs:
commit: ${{ steps.version.outputs.commit }}
version: ${{ steps.version.outputs.version }}
tag: ${{ steps.version.outputs.tag }}
steps:
# Use the commit accepted by the base branch, including squash and rebase merges.
- uses: actions/checkout@v6
with:
ref: ${{ github.event.pull_request.merge_commit_sha }}
sparse-checkout: version.inc
sparse-checkout-cone-mode: false
persist-credentials: false
- name: Read version.inc
id: version
shell: bash
env:
MERGE_COMMIT: ${{ github.event.pull_request.merge_commit_sha }}
PR_NUMBER: ${{ github.event.pull_request.number }}
run: |
test "$(git rev-parse HEAD)" = "$MERGE_COMMIT"
version=$(sed -nE 's/^set\(SLIC3R_VERSION "([0-9]+\.[0-9]+\.[0-9]+\.[0-9]+)"\)$/\1/p' version.inc)
if [[ ! "$version" =~ ^[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
echo 'Expected a four-component SLIC3R_VERSION in version.inc' >&2
exit 1
fi
echo "commit=$MERGE_COMMIT" >> "$GITHUB_OUTPUT"
echo "version=$version-c" >> "$GITHUB_OUTPUT"
echo "tag=v$version-pr$PR_NUMBER-c" >> "$GITHUB_OUTPUT"

build_all:
name: Build All
needs: release_metadata
if: ${{ !cancelled() && (github.event_name != 'pull_request_target' || needs.release_metadata.result == 'success') }}
strategy:
fail-fast: false
matrix:
include:
- os: ubuntu-22.04
- os: ubuntu-24.04
- os: windows-latest
- os: windows-2022
- os: macos-15-intel
arch: x86_64
- os: macos-15
Expand All @@ -55,4 +91,67 @@ jobs:
os: ${{ matrix.os }}
arch: ${{ matrix.arch }}
build-deps-only: ${{ inputs.build-deps-only || false }}
secrets: inherit
source-ref: ${{ needs.release_metadata.outputs.commit }}
release-version: ${{ needs.release_metadata.outputs.version }}

publish_release:
name: Publish release binaries
needs: [release_metadata, build_all]
if: ${{ needs.release_metadata.result == 'success' && needs.build_all.result == 'success' }}
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- uses: actions/download-artifact@v7
with:
pattern: release-*
path: release-assets
merge-multiple: true
- name: Publish the complete release
shell: bash
env:
GH_TOKEN: ${{ github.token }}
GH_REPO: ${{ github.repository }}
RELEASE_TAG: ${{ needs.release_metadata.outputs.tag }}
RELEASE_VERSION: ${{ needs.release_metadata.outputs.version }}
MERGE_COMMIT: ${{ needs.release_metadata.outputs.commit }}
PR_URL: ${{ github.event.pull_request.html_url }}
run: |
assets=(
"BambuStudio_Windows_V${RELEASE_VERSION}_portable.zip"
"BambuStudio_Mac_x86_64_V${RELEASE_VERSION}.zip"
"BambuStudio_Mac_arm64_V${RELEASE_VERSION}.zip"
"Bambu_Studio_ubuntu-22.04_V${RELEASE_VERSION}.AppImage"
"Bambu_Studio_ubuntu-24.04_V${RELEASE_VERSION}.AppImage"
)
for asset in "${assets[@]}"; do
if [[ ! -s "release-assets/$asset" ]]; then
echo "Missing release binary $asset" >&2
exit 1
fi
done

if ! target=$(gh api "repos/$GH_REPO/git/ref/tags/$RELEASE_TAG" --jq '.object.sha' 2>/dev/null); then
target=$(gh api --method POST "repos/$GH_REPO/git/refs" \
-f "ref=refs/tags/$RELEASE_TAG" -f "sha=$MERGE_COMMIT" --jq '.object.sha')
fi
test "$target" = "$MERGE_COMMIT"

if ! release=$(gh release view "$RELEASE_TAG" --json isDraft,assets); then
gh release create "$RELEASE_TAG" --verify-tag --draft \
--title "Bambu Studio $RELEASE_VERSION" --notes "Built from $PR_URL at $MERGE_COMMIT."
release=$(gh release view "$RELEASE_TAG" --json isDraft,assets)
fi

# A rerun may resume a draft, or verify a release that already finished.
if [[ $(jq -r '.isDraft' <<< "$release") == true ]]; then
paths=("${assets[@]/#/release-assets/}")
gh release upload "$RELEASE_TAG" "${paths[@]}" --clobber
release=$(gh release view "$RELEASE_TAG" --json isDraft,assets)
fi
for asset in "${assets[@]}"; do
jq -e --arg asset "$asset" 'any(.assets[]; .name == $asset and .size > 0)' <<< "$release" > /dev/null
done
if [[ $(jq -r '.isDraft' <<< "$release") == true ]]; then
gh release edit "$RELEASE_TAG" --draft=false
fi
Loading
Loading