Skip to content

Apothecary fixes

Apothecary fixes #1250

name: build-emscripten
on:
push:
paths-ignore:
- '**/README.md'
pull_request:
paths-ignore:
- '**/README.md'
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
env:
TARGET: "emscripten"
EMSDK_VERSION: "3.1.64"
USE_ARTIFACT: true
jobs:
build-emscripten:
runs-on: ubuntu-latest
strategy:
matrix:
arch: [32, 64]
pthreads: [0, 1]
steps:
- uses: actions/checkout@v4
- name: Docker Step
run: docker run -di --name emscripten -v $PWD:/src emscripten/emsdk:${{ env.EMSDK_VERSION }} bash
- name: Scripts Calc Formula
run: ./scripts/calculate_formulas.sh
- name: Scripts Install
run: ./scripts/$TARGET/install.sh
- 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
fi
- name: Download previous artifacts
uses: actions/github-script@v7
if: env.USE_ARTIFACT == 'true'
with:
script: |
const fs = require('fs');
const path = require('path');
// 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 arch = process.env.ARCH;
const pthreads = process.env.PTHREADS_ENABLED;
const artifactName = `libs-${target}-${arch}-${pthreads}`;
let count = 0;
const max = 1;
for (const artifact of artifacts.data.artifacts) {
if (artifact.name.startsWith(artifactName) && !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
run: ./scripts/build.sh
env:
GA_CI_SECRET: ${{ secrets.CI_SECRET }}
ARCH: ${{ matrix.arch }}
PTHREADS_ENABLED: ${{ matrix.pthreads }}
- 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: |
ARCH_SUFFIX=""
if [[ "${{ matrix.arch }}" == "64" ]]; then
ARCH_SUFFIX="_memory64"
fi
PTHREADS_SUFFIX=""
if [[ "${{ matrix.pthreads }}" == "1" ]]; then
PTHREADS_SUFFIX="_pthreads"
fi
FILENAME="openFrameworksLibs_${{ env.release }}_emscripten${ARCH_SUFFIX}${PTHREADS_SUFFIX}.tar.bz2"
echo "FILENAME=$FILENAME" >> $GITHUB_ENV
scripts/package.sh
env:
GA_CI_SECRET: ${{ secrets.CI_SECRET }}
ARCH: ${{ matrix.arch }}
PTHREADS_ENABLED: ${{ matrix.pthreads }}
- name: Upload 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-emscripten-${{ matrix.arch }}-${{ matrix.pthreads }}
path: out/${{ env.FILENAME }}
retention-days: 31
- name: Update Release
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: out/${{ env.FILENAME }}