Apothecary fixes (#433) #481
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-ios | |
on: | |
push: | |
paths-ignore: | |
- '**/README.md' | |
pull_request: | |
paths-ignore: | |
- '**/README.md' | |
concurrency: | |
group: ${{ github.workflow }}-${{ github.ref }} | |
cancel-in-progress: true | |
env: | |
TARGET: "ios" | |
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_15.4.app/Contents/Developer" | |
steps: | |
- name: Determine Release | |
id: vars | |
shell: bash | |
run: | | |
if [[ "${{ 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/osx/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=100 | |
// 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 artifactNamesToDownload = ['libs-ios-ios-1', 'libs-ios-ios-2', 'libs-ios-ios-3']; | |
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 iOS arm64 | |
working-directory: ${{ env.GITHUB_WORKSPACE }} | |
run: scripts/build.sh | |
env: | |
BUNDLE: ${{ matrix.bundle }} | |
ARCH: arm64 | |
- name: Build iOS SIMULATOR x86_64 | |
working-directory: ${{ env.GITHUB_WORKSPACE }} | |
run: scripts/build.sh | |
env: | |
BUNDLE: ${{ matrix.bundle }} | |
ARCH: x86_64 | |
- name: Build iOS SIMULATOR arm64 | |
working-directory: ${{ env.GITHUB_WORKSPACE }} | |
run: scripts/build.sh | |
env: | |
BUNDLE: ${{ matrix.bundle }} | |
ARCH: SIM_arm64 | |
- name: List output directory | |
run: ls -lah out/ | |
- name: Cleanup out of bundle | |
working-directory: ${{ env.GITHUB_WORKSPACE }} | |
run: scripts/artifact/artifact-clean.sh | |
env: | |
BUNDLE: ${{ matrix.bundle }} | |
- name: List output directory2 | |
run: ls -lah out/ | |
- name: Package Binaries for Artifact | |
if: github.repository == 'openframeworks/apothecary' && github.event_name == 'push' && (github.ref == 'refs/heads/master' || github.ref == 'refs/heads/bleeding') | |
working-directory: ${{ env.GITHUB_WORKSPACE }} | |
run: scripts/artifact/artifact.sh | |
env: | |
BUNDLE: ${{ matrix.bundle }} | |
- name: Upload binaries as Artifact | |
if: github.repository == 'openframeworks/apothecary' && github.event_name == 'push' && (github.ref == 'refs/heads/master' || github.ref == 'refs/heads/bleeding') | |
uses: actions/upload-artifact@v4 | |
with: | |
name: libs-ios-${{ 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') | |
run: | | |
echo "Removing .tar.bz2 files from out/ directory..." | |
rm -f out/*.tar.bz2 | |
rm -f xout/*.tar.bz2 | |
echo "Cleanup complete." | |
- name: Merge our iOS libaries into XC Framework | |
working-directory: ${{ env.GITHUB_WORKSPACE }} | |
run: scripts/ios/xcframework_all.sh | |
env: | |
BUNDLE: ${{ matrix.bundle }} | |
- name: Package | |
if: github.repository == 'openframeworks/apothecary' && github.event_name == 'push' && (github.ref == 'refs/heads/master' || github.ref == 'refs/heads/bleeding') | |
working-directory: ${{ env.GITHUB_WORKSPACE }} | |
run: scripts/package.sh | |
env: | |
BUNDLE: ${{ matrix.bundle }} | |
- name: Update Release arm64 | |
if: github.repository == 'openframeworks/apothecary' && github.event_name == 'push' && (github.ref == 'refs/heads/master' || github.ref == 'refs/heads/bleeding') | |
uses: johnwbyrd/update-release@v1.0.0 | |
with: | |
token: ${{ secrets.GITHUB_TOKEN }} | |
tag: ${{ env.RELEASE }} | |
release: ${{ env.RELEASE }} | |
prerelease: ${{ env.PRERELEASE }} | |
files: xout/openFrameworksLibs_${{ env.RELEASE }}_${{ env.TARGET }}_${{ matrix.bundle }}.tar.bz2 |