Skip to content

Commit

Permalink
Rework Github Build Actions (#2566)
Browse files Browse the repository at this point in the history
update workflows from dev branch

Co-authored-by: SoftFever <[email protected]>
  • Loading branch information
Ocraftyone and SoftFever authored Nov 18, 2023
1 parent b3db0a5 commit cbb7c33
Show file tree
Hide file tree
Showing 4 changed files with 244 additions and 240 deletions.
55 changes: 55 additions & 0 deletions .github/workflows/build_all.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
name: Build all

on:
push:
branches:
- main
paths:
- 'deps/**'
- 'src/**'
- '**/CMakeLists.txt'
- 'version.inc'
- 'localization/**'
- 'resources/**'
- ".github/workflows/build_*.yml"

pull_request:
branches:
- main
paths:
- 'deps/**'
- 'src/**'
- '**/CMakeLists.txt'
- 'version.inc'
- ".github/workflows/build_*.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_all:
name: Build All
strategy:
fail-fast: false
matrix:
include:
- os: ubuntu-20.04
- os: windows-latest
- os: macos-12
arch: x86_64
- os: macos-12
arch: arm64
uses: ./.github/workflows/build_check_cache.yml
with:
os: ${{ matrix.os }}
arch: ${{ matrix.arch }}
build-deps-only: ${{ inputs.build-deps-only || false }}
57 changes: 57 additions & 0 deletions .github/workflows/build_check_cache.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
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@v3

- name: set outputs
id: set_outputs
env:
underscore-arch: ${{ inputs.os == 'macos-12' && '_' || ''}}${{ inputs.os == 'macos-12' && inputs.arch || '' }} # if is macos, make a string that does "_{arch}", else output nothing
dash-arch: ${{ inputs.os == 'macos-12' && '-' || ''}}${{ inputs.os == 'macos-12' && inputs.arch || '' }} # if is macos, make a string that does "-{arch}", else output nothing
dep-folder-name: ${{ (inputs.os == 'windows-latest' || inputs.os == 'macos-12') && 'OrcaSlicer_dep' || 'destdir' }}
output-cmd: ${{ inputs.os == 'windows-latest' && '$env:GITHUB_OUTPUT' || '"$GITHUB_OUTPUT"'}}
run: |
echo cache-key=${{ runner.os }}${{ env.dash-arch }}-cache-orcaslicer_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@v3
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 }}
132 changes: 66 additions & 66 deletions .github/workflows/build_deps.yml
Original file line number Diff line number Diff line change
@@ -1,60 +1,62 @@
# name: Build Deps
name: Build deps

on:
pull_request:
branches:
- main
paths:
- 'deps/**'
- .github/workflows/build_deps.yml
push:
branches:
- main
paths:
- 'deps/**'
- .github/workflows/build_deps.yml

concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true
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:
strategy:
fail-fast: false
matrix:
include:
- os: ubuntu-20.04
- os: windows-latest
- os: macos-12
arch: x86_64
- os: macos-12
arch: arm64
runs-on: ${{ matrix.os }}

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@v3

- name: load cached deps
uses: actions/cache@v3
with:
path: ${{ inputs.cache-path }}
key: ${{ inputs.cache-key }}

- name: setup dev on Windows
if: matrix.os == 'Windows'
if: inputs.os == 'windows-latest'
uses: microsoft/[email protected]

- name: Get the date on Ubuntu and macOS
if: matrix.os != 'windows-latest'
id: get-date-unix
if: inputs.os != 'windows-latest'
run: echo "date=$(date +'%Y%m%d')" >> $GITHUB_ENV
shell: bash

- name: Get the date on Windows
if: matrix.os == 'windows-latest'
id: get-date-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: matrix.os == 'windows-latest'
if: inputs.os == 'windows-latest'
working-directory: ${{ github.workspace }}
run: |
choco install strawberryperl
Expand All @@ -64,26 +66,18 @@ jobs:
.\build_release_vs2022.bat pack
cd ${{ github.workspace }}/deps/build
- name: Build on Mac x86_64
if: matrix.os == 'macos-12' && matrix.arch == 'x86_64'
- name: Build on Mac ${{ inputs.arch }}
if: inputs.os == 'macos-12'
working-directory: ${{ github.workspace }}
run: |
brew install cmake git gettext automake
mkdir -p ${{ github.workspace }}/deps/build_x86_64
mkdir -p ${{ github.workspace }}/deps/build_x86_64/OrcaSlicer_dep_x86_64
./build_release_macos.sh -dp -a x86_64
- name: Build on Mac arm64
if: matrix.os == 'macos-12' && matrix.arch == 'arm64'
working-directory: ${{ github.workspace }}
run: |
brew install cmake git gettext automake
mkdir -p ${{ github.workspace }}/deps/build_arm64
mkdir -p ${{ github.workspace }}/deps/build_arm64/OrcaSlicer_dep_arm64
./build_release_macos.sh -dp -a arm64
brew list
mkdir -p ${{ github.workspace }}/deps/build_${{ inputs.arch }}
mkdir -p ${{ github.workspace }}/deps/build_${{ inputs.arch }}/OrcaSlicer_dep_${{ inputs.arch }}
./build_release_macos.sh -dp -a ${{ inputs.arch }}
- name: Build on Ubuntu
if: matrix.os == 'ubuntu-20.04'
if: inputs.os == 'ubuntu-20.04'
working-directory: ${{ github.workspace }}
run: |
sudo apt-get update
Expand All @@ -99,32 +93,38 @@ jobs:
./BuildLinux.sh -dr
cd deps/build
tar -czvf OrcaSlicer_dep_ubuntu_$(date +"%Y%m%d").tar.gz destdir
- name: Upload Mac arm64 artifacts
if: matrix.os == 'macos-12' && matrix.arch == 'arm64'
uses: actions/upload-artifact@v3
with:
name: OrcaSlicer_dep_mac_arm64_${{ env.date }}
path: ${{ github.workspace }}/deps/build_arm64/OrcaSlicer_dep*.tar.gz
- name: Upload Mac x86_64 artifacts
if: matrix.os == 'macos-12' && matrix.arch == 'x86_64'

# Upload Artifacts
- name: Upload Mac ${{ inputs.arch }} artifacts
if: inputs.os == 'macos-12'
uses: actions/upload-artifact@v3
with:
name: OrcaSlicer_dep_mac_x86_64_${{ env.date }}
path: ${{ github.workspace }}/deps/build_x86_64/OrcaSlicer_dep*.tar.gz
name: OrcaSlicer_dep_mac_${{ inputs.arch }}_${{ env.date }}
path: ${{ github.workspace }}/deps/build_${{ inputs.arch }}/OrcaSlicer_dep*.tar.gz

- name: Upload Windows artifacts
if: matrix.os == 'windows-latest'
if: inputs.os == 'windows-latest'
uses: actions/upload-artifact@v3
with:
name: OrcaSlicer_dep_win64_${{ env.date }}
path: ${{ github.workspace }}/deps/build/OrcaSlicer_dep*.zip

- name: Upload Ubuntu artifacts
if: matrix.os == 'ubuntu-20.04'
if: inputs.os == 'ubuntu-20.04'
uses: actions/upload-artifact@v3
with:
name: OrcaSlicer_dep_ubuntu_${{ env.date }}
path: ${{ github.workspace }}/deps/build/OrcaSlicer_dep_ubuntu_*.tar.gz


build_orca:
name: Build OrcaSlicer
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_orca.yml
with:
cache-key: ${{ inputs.cache-key }}
cache-path: ${{ inputs.cache-path }}
os: ${{ inputs.os }}
arch: ${{ inputs.arch }}

Loading

0 comments on commit cbb7c33

Please sign in to comment.