macOS All Platforms #95
Workflow file for this run
This file contains 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: build-xros | |
on: | |
push: | |
paths-ignore: | |
- '**/README.md' | |
pull_request: | |
paths-ignore: | |
- '**/README.md' | |
concurrency: | |
group: ${{ github.workflow }}-${{ github.ref }} | |
cancel-in-progress: true | |
env: | |
TARGET: "xros" | |
NO_FORCE: 1 | |
GA_CI_SECRET: ${{ secrets.CI_SECRET }} | |
USE_ARTIFACT: true | |
jobs: | |
build-macos-platforms: | |
runs-on: macos-14 | |
strategy: | |
matrix: | |
bundle: [1, 2, 3] | |
env: | |
BUNDLE: ${{ matrix.bundle }} | |
DEVELOPER_DIR: "/Applications/Xcode_16.app/Contents/Developer" | |
steps: | |
- name: Determine Release | |
id: vars | |
shell: bash | |
run: | | |
if [[ "${{ github.ref }}" == refs/tags/* ]]; then | |
echo "RELEASE=${{ github.ref_name }}" >> $GITHUB_ENV | |
echo "PRERELEASE=false" >> $GITHUB_ENV | |
elif [[ "${{ github.ref }}" == "refs/heads/master" ]]; then | |
echo "RELEASE=nightly" >> $GITHUB_ENV | |
echo "PRERELEASE=false" >> $GITHUB_ENV | |
elif [[ "${{ github.ref }}" == "refs/heads/bleeding" ]]; then | |
echo "RELEASE=bleeding" >> $GITHUB_ENV | |
echo "PRERELEASE=true" >> $GITHUB_ENV | |
else | |
echo "RELEASE=bleeding" >> $GITHUB_ENV | |
echo "PRERELEASE=true" >> $GITHUB_ENV | |
fi | |
- uses: actions/checkout@v4 | |
- name: Scripts Calc Formula - ${{ env.TARGET }} Bundle ${{ matrix.bundle }} | |
run: ./scripts/calculate_formulas.sh | |
- name: Scripts Install | |
run: ./scripts/xros/install.sh | |
- name: 'Download artifacts' | |
uses: actions/github-script@v7 | |
if: env.USE_ARTIFACT == 'true' | |
with: | |
script: | | |
const fs = require('fs'); | |
const path = require('path'); | |
// https://api.github.com/repos/openframeworks/apothecary/actions/artifacts?per_page=250 | |
// Ensure the output directory exists | |
const outputDir = path.join(process.env.GITHUB_WORKSPACE, 'out'); | |
if (!fs.existsSync(outputDir)){ | |
fs.mkdirSync(outputDir); | |
} | |
// List all artifacts for the repository | |
const artifacts = await github.rest.actions.listArtifactsForRepo({ | |
owner: 'openframeworks', | |
repo: 'apothecary', | |
sort: 'created_at', | |
direction: 'desc', | |
per_page: 50 | |
}); | |
const target = process.env.TARGET; | |
const bundle = process.env.MATRIX_BUNDLE; | |
const release = process.env.RELEASE; | |
const artifactName1 = `libs-${release}-${target}-1`; | |
const artifactName2 = `libs-${release}-${target}-2`; | |
const artifactName3 = `libs-${release}-${target}-3`; | |
const artifactNamesToDownload = [artifactName1, artifactName2, artifactName3]; | |
let count = 0; | |
const max=3; | |
for (const artifact of artifacts.data.artifacts) { | |
if (artifactNamesToDownload.includes(artifact.name) && !artifact.expired) { | |
// Download the artifact | |
const download = await github.rest.actions.downloadArtifact({ | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
artifact_id: artifact.id, | |
archive_format: 'zip', | |
}); | |
const artifactPath = path.join(outputDir, `${artifact.name}.zip`); | |
fs.writeFileSync(artifactPath, Buffer.from(download.data)); | |
console.log(`Downloaded ${artifact.name} to ${artifactPath}`); | |
count++; | |
if (count >= max) { | |
break; | |
} | |
} | |
} | |
- name: Extract Artifacts to /out | |
if: env.USE_ARTIFACT == 'true' | |
run: | | |
mkdir -p out | |
if ls out/*.zip 1> /dev/null 2>&1; then | |
for zip in out/*.zip; do | |
echo "Extracting $zip..." | |
unzip -o "$zip" -d out/ | |
done | |
echo "Extraction complete." | |
rm out/*.zip | |
else | |
echo "No zip files to extract." | |
fi | |
if ls out/*.tar.bz2 1> /dev/null 2>&1; then | |
for tarball in out/*.tar.bz2; do | |
echo "Extracting $tarball..." | |
tar -xjf "$tarball" -C out/ | |
done | |
echo ".tar.bz2 extraction complete." | |
rm -f out/*.tar.bz2 | |
else | |
echo "No .tar.bz2 files to extract." | |
fi | |
rm -f xout/*.tar.bz2 | |
rm -f out/*.tar.bz2 | |
- name: Build VisionOS | |
working-directory: ${{ env.GITHUB_WORKSPACE }} | |
run: scripts/build.sh | |
env: | |
TARGET: "xros" | |
BUNDLE: ${{ matrix.bundle }} | |
ARCH: arm64 | |
GA_CI_SECRET: ${{ secrets.CI_SECRET }} | |
- name: Build VisionOS | |
working-directory: ${{ env.GITHUB_WORKSPACE }} | |
run: scripts/build.sh | |
env: | |
TARGET: "xros" | |
BUNDLE: ${{ matrix.bundle }} | |
ARCH: x86_64 | |
GA_CI_SECRET: ${{ secrets.CI_SECRET }} | |
- name: Build VisionOS SIMULATOR arm64 | |
working-directory: ${{ env.GITHUB_WORKSPACE }} | |
run: scripts/build.sh | |
env: | |
TARGET: "xros" | |
BUNDLE: ${{ matrix.bundle }} | |
ARCH: SIM_arm64 | |
GA_CI_SECRET: ${{ secrets.CI_SECRET }} | |
- name: Package Binaries for Artifact | |
if: github.repository == 'openframeworks/apothecary' && github.event_name == 'push' && (github.ref == 'refs/heads/master' || github.ref == 'refs/heads/bleeding' || contains(github.ref, 'refs/tags/')) | |
working-directory: ${{ env.GITHUB_WORKSPACE }} | |
run: scripts/artifact.sh | |
env: | |
BUNDLE: ${{ matrix.bundle }} | |
GA_CI_SECRET: ${{ secrets.CI_SECRET }} | |
- name: Upload binaries as Artifact | |
if: github.repository == 'openframeworks/apothecary' && github.event_name == 'push' && (github.ref == 'refs/heads/master' || github.ref == 'refs/heads/bleeding' || contains(github.ref, 'refs/tags/')) | |
uses: actions/upload-artifact@v4 | |
with: | |
name: libs-${{ env.RELEASE }}-${{ env.TARGET }}-${{ matrix.bundle }} | |
path: out/openFrameworksLibs_${{ env.RELEASE }}_${{ env.TARGET }}_${{ matrix.bundle }}.tar.bz2 | |
retention-days: 31 | |
- name: Remove .tar.bz2 files | |
if: github.repository == 'openframeworks/apothecary' && github.event_name == 'push' && (github.ref == 'refs/heads/master' || github.ref == 'refs/heads/bleeding' || contains(github.ref, 'refs/tags/')) | |
run: | | |
echo "Removing .tar.bz2 files from out/ directory..." | |
rm -f out/*.tar.bz2 | |
echo "Cleanup complete." | |
- name: List output directory | |
run: ls -lah out/ | |
- name: Merge our VisionOS libaries into XC Framework | |
working-directory: ${{ env.GITHUB_WORKSPACE }} | |
run: scripts/xros/xcframework_all.sh | |
env: | |
BUNDLE: ${{ matrix.bundle }} | |
GA_CI_SECRET: ${{ secrets.CI_SECRET }} | |
- name: Package | |
if: github.repository == 'openframeworks/apothecary' && github.event_name == 'push' && (github.ref == 'refs/heads/master' || github.ref == 'refs/heads/bleeding' || contains(github.ref, 'refs/tags/')) | |
working-directory: ${{ env.GITHUB_WORKSPACE }} | |
run: scripts/package.sh | |
env: | |
BUNDLE: ${{ matrix.bundle }} | |
GA_CI_SECRET: ${{ secrets.CI_SECRET }} | |
- name: Update XCFramework | |
if: github.repository == 'openframeworks/apothecary' && github.event_name == 'push' && (startsWith(github.ref, 'refs/tags/') || github.ref == 'refs/heads/master' || github.ref == 'refs/heads/bleeding') | |
uses: softprops/action-gh-release@v2.0.8 | |
with: | |
token: ${{ secrets.GITHUB_TOKEN }} | |
tag_name: ${{ env.RELEASE }} | |
files: xout/openFrameworksLibs_${{ env.RELEASE }}_${{ env.TARGET }}_${{ matrix.bundle }}.tar.bz2 |