Skip to content

vs opencv build zlib test (#520) #1325

vs opencv build zlib test (#520)

vs opencv build zlib test (#520) #1325

Workflow file for this run

name: build-ios
on:
push:
paths-ignore:
- '**/README.md'
pull_request:
paths-ignore:
- '**/README.md'
concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
cancel-in-progress: true
env:
TARGET: "ios"
NO_FORCE: 1
GA_CI_SECRET: ${{ secrets.CI_SECRET }}
USE_ARTIFACT: true
DISABLE_WORKFLOW: "false"
jobs:
pre-check:
runs-on: ubuntu-latest
outputs:
workflow_disabled: ${{ steps.check-disabled.outputs.disabled }}
steps:
- name: Check if Workflow is disabled
id: check-disabled
shell: bash
run: |
if [ "${{ env.DISABLE_WORKFLOW }}" == "true" ]; then
echo "disabled=true" >> $GITHUB_ENV
echo "::set-output name=disabled::true"
else
echo "::set-output name=disabled::false"
fi
build-ios-platforms:
if: needs.pre-check.outputs.workflow_disabled != 'true'
runs-on: macos-14
needs: pre-check
strategy:
matrix:
bundle: [1, 2, 3]
env:
BUNDLE: ${{ matrix.bundle }}
DEVELOPER_DIR: "/Applications/Xcode_16.2.app/Contents/Developer"
steps:
- name: Check if Workflow is disabled
run: |
if [ "${{ env.DISABLE_WORKFLOW }}" == "true" ]; then
echo "Workflow is disabled. Exiting."
exit 78
fi
- name: Determine Release
id: vars
shell: bash
run: |
if [[ "${{ github.ref }}" == refs/tags/* ]]; then
echo "RELEASE=${{ github.ref_name }}" >> $GITHUB_ENV
elif [[ "${{ github.ref }}" == "refs/heads/master" ]]; then
echo "RELEASE=nightly" >> $GITHUB_ENV
elif [[ "${{ github.ref }}" == "refs/heads/bleeding" ]]; then
echo "RELEASE=latest" >> $GITHUB_ENV
else
echo "RELEASE=latest" >> $GITHUB_ENV
fi
- uses: actions/checkout@v4.2.2
- 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');
const outputDir = path.join(process.env.GITHUB_WORKSPACE, 'out');
// Ensure output directory exists
if (!fs.existsSync(outputDir)) {
fs.mkdirSync(outputDir);
}
try {
console.log("Fetching artifacts...");
const artifacts = await github.rest.actions.listArtifactsForRepo({
owner: 'openframeworks',
repo: 'apothecary',
sort: 'created_at',
direction: 'desc',
per_page: 150
});
const target = process.env.TARGET;
const bundle = process.env.MATRIX_BUNDLE;
const release = '${{ github.ref }}'.startsWith('refs/tags/') ? 'latest' : process.env.RELEASE;
console.log(`Target: ${target}, Bundle: ${bundle}, Release: ${release}`);
const artifactName1 = `libs-${release}-${target}-1`;
const artifactName2 = `libs-${release}-${target}-2`;
const artifactName3 = `libs-${release}-${target}-3`;
const artifactNamesToDownload = new Set([artifactName1, artifactName2, artifactName3]);
console.log(`Artifacts to download: ${Array.from(artifactNamesToDownload).join(', ')}`);
let count = 0;
const max = 3;
for (const artifact of artifacts.data.artifacts) {
console.log(`Checking artifact: ${artifact.name} (Expired: ${artifact.expired})`);
const isArtifactMatch = artifact.name.includes(`libs-${release}-${target}`) && !artifact.expired;
if (isArtifactMatch) {
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) {
console.log("Reached maximum artifact download count.");
break;
}
} else {
console.log(`Skipping artifact: ${artifact.name} - Conditions not met.`);
}
}
} catch (error) {
console.error("An error occurred:", error);
}
- 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: List output directory1
run: ls -lah out/
- 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-${{ 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')
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' || contains(github.ref, 'refs/tags/'))
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' && (startsWith(github.ref, 'refs/tags/') || github.ref == 'refs/heads/master' || github.ref == 'refs/heads/bleeding')
uses: softprops/action-gh-release@v2.1.0
with:
token: ${{ secrets.GITHUB_TOKEN }}
tag_name: ${{ env.RELEASE }}
files: xout/openFrameworksLibs_${{ env.RELEASE }}_${{ env.TARGET }}_${{ matrix.bundle }}.tar.bz2
wait-for-workflows:
runs-on: [ubuntu-latest]
needs: build-ios-platforms
# if: github.repository == 'openframeworks/apothecary' && github.event_name == 'push' && (github.ref == 'refs/heads/master' || github.ref == 'refs/heads/bleeding' || contains(github.ref, 'refs/tags/'))
steps:
# - name: Wait build-ios
# uses: NathanFirmo/wait-for-other-action@v1.0.4
# with:
# token: ${{ secrets.GITHUB_TOKEN }}
# workflow: 'build-ios.yml'
- name: Wait build-macos
uses: NathanFirmo/wait-for-other-action@v1.0.4
with:
token: ${{ secrets.GITHUB_TOKEN }}
workflow: 'build-macos.yml'
# - name: Wait build-xros
# uses: NathanFirmo/wait-for-other-action@v1.0.4
# with:
# token: ${{ secrets.GITHUB_TOKEN }}
# workflow: 'build-xros.yml'
# - name: Wait build-catos
# uses: NathanFirmo/wait-for-other-action@v1.0.4
# with:
# token: ${{ secrets.GITHUB_TOKEN }}
# workflow: 'build-catos.yml'
- name: Wait build-tvos
uses: NathanFirmo/wait-for-other-action@v1.0.4
with:
token: ${{ secrets.GITHUB_TOKEN }}
workflow: 'build-tvos.yml'
# - name: Wait build-watchos
# uses: NathanFirmo/wait-for-other-action@v1.0.4
# with:
# token: ${{ secrets.GITHUB_TOKEN }}
# workflow: 'build-watchos.yml'
build-xcframework:
runs-on: macos-14
needs: wait-for-workflows
env:
DEVELOPER_DIR: "/Applications/Xcode_16.2.app/Contents/Developer"
TARGET: "macos"
if: github.repository == 'openframeworks/apothecary' && github.event_name == 'push' && (github.ref == 'refs/heads/master' || github.ref == 'refs/heads/bleeding' || contains(github.ref, 'refs/tags/'))
steps:
- name: Determine Release
id: vars
shell: bash
run: |
if [[ "${{ github.ref }}" == refs/tags/* ]]; then
echo "RELEASE=${{ github.ref_name }}" >> $GITHUB_ENV
elif [[ "${{ github.ref }}" == "refs/heads/master" ]]; then
echo "RELEASE=nightly" >> $GITHUB_ENV
elif [[ "${{ github.ref }}" == "refs/heads/bleeding" ]]; then
echo "RELEASE=latest" >> $GITHUB_ENV
else
echo "RELEASE=latest" >> $GITHUB_ENV
fi
- uses: actions/checkout@v4.2.2
- name: Scripts Calc Formula
run: ./scripts/calculate_formulas.sh
- name: Scripts Install
run: ./scripts/macos/install.sh
- name: 'Download all artifacts'
uses: actions/github-script@v7
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: 150
});
const release = '${{ github.ref }}'.startsWith('refs/tags/') ? 'latest' : process.env.RELEASE;
const platforms = ["ios", "macos", "tvos"];
const platformTargets = { ios: "ios", macos: "osx", tvos: "tvos" };
const artifactNamesToDownload = new Set();
const max = 9; // The maximum suffix number for artifacts
// Generate artifact names dynamically based on platforms, target mappings, and max count
for (const platform of platforms) {
for (let i = 1; i <= max; i++) {
artifactNamesToDownload.add(`libs-${release}-${platformTargets[platform]}-${i}`);
}
}
let count = 0;
const downloadedArtifacts = new Set();
for (const artifact of artifacts.data.artifacts) {
if (artifactNamesToDownload.has(artifact.name) && !artifact.expired && !downloadedArtifacts.has(artifact.name)) {
// 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++;
downloadedArtifacts.add(artifact.name);
if (count >= max) {
break;
}
}
}
- name: Extract Artifacts to /out
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: List output directory
run: ls -lah ./
- name: List output directory out
run: ls -lah ./out
- name: Merge built libaries into Mega XC Framework
working-directory: ${{ env.GITHUB_WORKSPACE }}
run: scripts/macos/xcframework_all.sh
env:
GA_CI_SECRET: ${{ secrets.CI_SECRET }}
- name: List output directory xout
run: ls -lah ./xout
- name: Split into bundles 1
working-directory: ${{ env.GITHUB_WORKSPACE }}
run: scripts/macos/xcframework-split.sh macos 1
- name: Split into bundles 2
working-directory: ${{ env.GITHUB_WORKSPACE }}
run: scripts/macos/xcframework-split.sh macos 2
- name: Split into bundle 3
working-directory: ${{ env.GITHUB_WORKSPACE }}
run: scripts/macos/xcframework-split.sh macos 3
- name: Package Final
working-directory: ${{ env.GITHUB_WORKSPACE }}
run: scripts/package.sh macos 1
env:
GA_CI_SECRET: ${{ secrets.CI_SECRET }}
- name: Package Final
working-directory: ${{ env.GITHUB_WORKSPACE }}
run: scripts/package.sh macos 2
env:
GA_CI_SECRET: ${{ secrets.CI_SECRET }}
- name: Package Final
working-directory: ${{ env.GITHUB_WORKSPACE }}
run: scripts/package.sh macos 3
env:
GA_CI_SECRET: ${{ secrets.CI_SECRET }}
- name: Update Release macOS 1
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.1.0
with:
token: ${{ secrets.GITHUB_TOKEN }}
tag_name: ${{ env.RELEASE }}
files: xout_1/openFrameworksLibs_${{ env.RELEASE }}_${{ env.TARGET }}_1.tar.bz2
- name: Update Release macOS 2
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.1.0
with:
token: ${{ secrets.GITHUB_TOKEN }}
tag_name: ${{ env.RELEASE }}
files: xout_2/openFrameworksLibs_${{ env.RELEASE }}_${{ env.TARGET }}_2.tar.bz2
- name: Update Release macOS 3
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.1.0
with:
token: ${{ secrets.GITHUB_TOKEN }}
tag_name: ${{ env.RELEASE }}
files: xout_3/openFrameworksLibs_${{ env.RELEASE }}_${{ env.TARGET }}_3.tar.bz2