Skip to content

Nightly Release

Nightly Release #115

Workflow file for this run

name: Release
on:
workflow_run:
workflows:
- Static Code Analysis
branches:
- main
types:
- completed
concurrency:
group: nightly-release-${{ github.ref_name }}
cancel-in-progress: true
jobs:
nightly-release:
name: Nightly Release
runs-on: ubuntu-latest
if: ${{ github.event.workflow_run.conclusion == 'success' }}
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Get latest workflow run artifacts
id: download-artifacts
uses: actions/github-script@v6
with:
script: |
const fs = require('fs');
const path = require('path');
const workflows = ['build.yml', 'build_documentation.yml', 'static_analysis.yml'];
let allArtifacts = [];
for (const workflow of workflows) {
const runs = await github.rest.actions.listWorkflowRuns({
owner: context.repo.owner,
repo: context.repo.repo,
workflow_id: workflow,
branch: 'main',
per_page: 1
});
if (!runs.data.workflow_runs.length) {
console.log(`No runs found for workflow ${workflow}`);
continue;
}
const runId = runs.data.workflow_runs[0].id;
const artifacts = await github.rest.actions.listWorkflowRunArtifacts({
owner: context.repo.owner,
repo: context.repo.repo,
run_id: runId
});
const nightlyArtifacts = artifacts.data.artifacts.filter(a =>
a.name.startsWith("Nightly_")
);
if (nightlyArtifacts.length === 0) {
console.log(`No Nightly artifacts found in workflow ${workflow}`);
continue;
}
allArtifacts.push(...nightlyArtifacts);
}
if (allArtifacts.length === 0) {
throw new Error("No Nightly artifacts found in any workflow.");
}
for (const artifact of allArtifacts) {
const download = await github.rest.actions.downloadArtifact({
owner: context.repo.owner,
repo: context.repo.repo,
artifact_id: artifact.id,
archive_format: 'zip'
});
const filePath = path.join(process.env.GITHUB_WORKSPACE, `${artifact.name}.zip`);
fs.writeFileSync(filePath, Buffer.from(download.data));
console.log(`Downloaded artifact: ${filePath}`);
}
- name: Unzip build artifacts only
run: |
mkdir -p archives
for f in *.zip; do
if [[ "$f" == *"_SCA.zip" ]]; then
# Keep static analysis artifacts as .zip
cp "$f" "archives/"
else
# Extract build artifacts
artifact_name="${f%.zip}"
mkdir -p "archives/$artifact_name"
unzip -o "$f" -d "archives/$artifact_name"
fi
done
- name: Configure Git
run: |
git config user.name "github-actions"
git config user.email "github-actions@github.com"
- name: Create or update Nightly release
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NOTES: |
Latest development release, continuously updated.
run: |
gh release delete nightly -y || true
FILES=$(find ./archives -type f -print0 | xargs -0)
echo "Uploading files:"
gh release create nightly $FILES \
--title "Nightly Release" \
--notes "${{ env.NOTES }}" \
--prerelease \
--target ${{ github.sha }}