[ci] Fix nightly release generation #120
Workflow file for this run
This file contains hidden or 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: Nightly Release | |
on: | |
pull_request: | |
types: [opened, synchronize, reopened] | |
concurrency: | |
group: nightly-release-${{ github.ref_name }} | |
cancel-in-progress: true | |
jobs: | |
nightly-release: | |
name: Nightly Release | |
runs-on: ubuntu-latest | |
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" == *"StaticCodeAnalysis*" ]]; 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: List Files | |
run: | | |
echo "Contents of archives:" | |
find archives -type f | sort | |
echo "" | |
echo "Directory structure:" | |
tree -L 3 archives || true | |
- 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 view nightly || gh release create nightly \ | |
--title "Nightly Release" \ | |
--notes "${{ env.NOTES }}" \ | |
--prerelease \ | |
--target ${{ github.sha }} | |
FILES=$(find ./archives -type f -print0 | xargs -0) | |
echo "Uploading files: $FILES" | |
gh release upload --clobber nightly $FILES |