Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GitHub Actions - Optimsation for Artefacts #450

Open
wants to merge 14 commits into
base: bleeding
Choose a base branch
from
6 changes: 3 additions & 3 deletions .github/workflows/build-emscripten.yml
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ jobs:
repo: 'apothecary',
sort: 'created_at',
direction: 'desc',
per_page: 50
per_page: 150
});

const target = process.env.TARGET;
Expand All @@ -76,8 +76,8 @@ jobs:
const max = 1;

for (const artifact of artifacts.data.artifacts) {
if (artifact.name.startsWith(artifactName) && !artifact.expired) {
// Download the artifact
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,
Expand Down
102 changes: 57 additions & 45 deletions .github/workflows/build-ios.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ env:
USE_ARTIFACT: true

jobs:
build-macos-platforms:
build-for-ios-platform:
runs-on: macos-14
strategy:
matrix:
Expand All @@ -34,16 +34,12 @@ jobs:
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=latest" >> $GITHUB_ENV
echo "PRERELEASE=true" >> $GITHUB_ENV
else
echo "RELEASE=latest" >> $GITHUB_ENV
echo "PRERELEASE=true" >> $GITHUB_ENV
fi
- uses: actions/checkout@v4
- name: Scripts Calc Formula - ${{ env.TARGET }} Bundle ${{ matrix.bundle }}
Expand All @@ -57,52 +53,68 @@ jobs:
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)){

// Ensure output directory exists
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 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;
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 = 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: |
Expand Down Expand Up @@ -189,7 +201,7 @@ jobs:
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.0.8
uses: softprops/action-gh-release@v2.1.0
with:
token: ${{ secrets.GITHUB_TOKEN }}
tag_name: ${{ env.RELEASE }}
Expand Down
25 changes: 7 additions & 18 deletions .github/workflows/build-macos.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,16 +34,12 @@ jobs:
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=latest" >> $GITHUB_ENV
echo "PRERELEASE=true" >> $GITHUB_ENV
else
echo "RELEASE=latest" >> $GITHUB_ENV
echo "PRERELEASE=true" >> $GITHUB_ENV
fi
- uses: actions/checkout@v4
- name: Scripts Calc Formula - ${{ env.TARGET }} Bundle ${{ matrix.bundle }}
Expand All @@ -57,43 +53,36 @@ jobs:
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
// https://api.github.com/repos/openframeworks/apothecary/actions/artifacts?per_page=250
const artifacts = await github.rest.actions.listArtifactsForRepo({
owner: 'openframeworks',
repo: 'apothecary',
sort: 'created_at',
direction: 'desc',
per_page: 50
per_page: 150
});

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];
const artifactNamesToDownload = new Set([artifactName1, artifactName2, artifactName3]);
let count = 0;
const max=3;

const max = 3;
for (const artifact of artifacts.data.artifacts) {
if (artifactNamesToDownload.includes(artifact.name) && !artifact.expired) {
// Download the artifact
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}`);
Expand Down Expand Up @@ -184,7 +173,7 @@ jobs:
BUNDLE: ${{ matrix.bundle }}
- name: Update Release 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
uses: softprops/action-gh-release@v2.1.0
with:
token: ${{ secrets.GITHUB_TOKEN }}
tag_name: ${{ env.RELEASE }}
Expand Down
6 changes: 1 addition & 5 deletions .github/workflows/build-msys2.yml
Original file line number Diff line number Diff line change
Expand Up @@ -59,16 +59,12 @@ jobs:
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=latest" >> $GITHUB_ENV
echo "PRERELEASE=true" >> $GITHUB_ENV
else
echo "RELEASE=latest" >> $GITHUB_ENV
echo "PRERELEASE=true" >> $GITHUB_ENV
fi
- name: Clone repository
uses: actions/checkout@v4
Expand All @@ -85,7 +81,7 @@ jobs:
run: ls -lah out/
- name: Update Release
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
uses: softprops/action-gh-release@v2.1.0
with:
token: ${{ secrets.GITHUB_TOKEN }}
tag_name: ${{ env.RELEASE }}
Expand Down
24 changes: 6 additions & 18 deletions .github/workflows/build-tvos.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,16 +34,12 @@ jobs:
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=latest" >> $GITHUB_ENV
echo "PRERELEASE=true" >> $GITHUB_ENV
else
echo "RELEASE=latest" >> $GITHUB_ENV
echo "PRERELEASE=true" >> $GITHUB_ENV
fi
- uses: actions/checkout@v4
- name: Scripts Calc Formula - ${{ env.TARGET }} Bundle ${{ matrix.bundle }}
Expand All @@ -57,43 +53,35 @@ jobs:
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
per_page: 150
});

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];
const artifactNamesToDownload = new Set([artifactName1, artifactName2, artifactName3]);
let count = 0;
const max=3;

const max = 3;
for (const artifact of artifacts.data.artifacts) {
if (artifactNamesToDownload.includes(artifact.name) && !artifact.expired) {
// Download the artifact
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}`);
Expand Down Expand Up @@ -191,7 +179,7 @@ jobs:
GA_CI_SECRET: ${{ secrets.CI_SECRET }}
- name: Update Release 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
uses: softprops/action-gh-release@v2.1.0
with:
token: ${{ secrets.GITHUB_TOKEN }}
tag_name: ${{ env.RELEASE }}
Expand Down
16 changes: 4 additions & 12 deletions .github/workflows/build-vs2019-x64.yml
Original file line number Diff line number Diff line change
Expand Up @@ -58,16 +58,12 @@ jobs:
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=latest" >> $GITHUB_ENV
echo "PRERELEASE=true" >> $GITHUB_ENV
else
echo "RELEASE=latest" >> $GITHUB_ENV
echo "PRERELEASE=true" >> $GITHUB_ENV
fi
- name: 'Download artifacts'
uses: actions/github-script@v7
Expand All @@ -89,7 +85,7 @@ jobs:
repo: 'apothecary',
sort: 'created_at',
direction: 'desc',
per_page: 50
per_page: 150
});

const target = process.env.TARGET + "-2019";
Expand All @@ -102,18 +98,14 @@ jobs:
const max = 1;

for (const artifact of artifacts.data.artifacts) {
const isBranchMatch = artifact.workflow_run.head_branch === release;
const isTagMatch = artifact.workflow_run.event === 'release' && artifact.name.includes(`libs-${release}`);
if (artifact.name === artifactName && !artifact.expired && (isBranchMatch || isTagMatch)) {

// Download the artifact
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}`);
Expand Down Expand Up @@ -172,7 +164,7 @@ jobs:
retention-days: 31
- name: Update Release x64
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
uses: softprops/action-gh-release@v2.1.0
with:
token: ${{ secrets.GITHUB_TOKEN }}
tag_name: ${{ env.RELEASE }}
Expand Down
Loading
Loading