[ci] Fix nightly release generation #123
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: 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: List existing releases | |
env: | |
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
run: | | |
gh release list | |
- name: Create or update Nightly release | |
env: | |
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
NOTES: | | |
Latest development release, continuously updated. | |
run: | | |
# Create nightly release if it doesn't exist | |
gh release view nightly || gh release create nightly \ | |
--title "Nightly Release" \ | |
--notes "${{ env.NOTES }}" \ | |
--prerelease \ | |
--target ${{ github.sha }} | |
# Find all .zip files in the root directory | |
echo "Uploading all .zip files in repository root:" | |
find . -maxdepth 1 -name "*.zip" -print0 | while IFS= read -r -d '' file; do | |
echo "→ $file" | |
gh release upload --clobber nightly "$file" | |
done |