Update release #5
Workflow file for this run
This file contains 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: Ceylon-Build-Python | |
on: | |
push: | |
branches: | |
- main | |
- master | |
- devops | |
- release | |
tags: | |
- '*' | |
jobs: | |
release: | |
name: Ceylon-Release-Python | |
runs-on: ubuntu-20.04 | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Get latest successful workflow run | |
id: get_latest_run | |
uses: actions/github-script@v6 | |
with: | |
script: | | |
const workflow_id = 'python-build.yml'; | |
console.log(`Searching for workflow runs of: ${workflow_id}`); | |
console.log(`Current ref: ${context.ref}`); | |
const { data: runs } = await github.rest.actions.listWorkflowRuns({ | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
workflow_id: workflow_id, | |
status: 'success', | |
}); | |
console.log(`Total workflow runs found: ${runs.total_count}`); | |
if (runs.total_count === 0) { | |
console.log('No workflow runs found. Checking if the workflow file exists...'); | |
try { | |
await github.rest.actions.getWorkflow({ | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
workflow_id: workflow_id, | |
}); | |
console.log('Workflow file exists, but no runs were found.'); | |
} catch (error) { | |
console.log(`Error checking workflow file: ${error.message}`); | |
core.setFailed(`Workflow file '${workflow_id}' not found. Please check the workflow name.`); | |
return; | |
} | |
core.setFailed('No successful workflow runs found. Ensure the python-build.yml workflow has run successfully at least once.'); | |
return; | |
} | |
const latestRun = runs.workflow_runs[0]; | |
console.log(`Latest successful run ID: ${latestRun.id}`); | |
console.log(`Run details: Branch - ${latestRun.head_branch}, Commit - ${latestRun.head_sha}`); | |
core.setOutput('run_id', latestRun.id); | |
- name: Download artifacts | |
if: steps.get_latest_run.outcome == 'success' | |
uses: actions/github-script@v6 | |
with: | |
script: | | |
const run_id = ${{ steps.get_latest_run.outputs.run_id }}; | |
console.log(`Attempting to download artifacts from run ID: ${run_id}`); | |
const { data: artifactsList } = await github.rest.actions.listWorkflowRunArtifacts({ | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
run_id: run_id, | |
}); | |
console.log(`Found ${artifactsList.artifacts.length} artifacts`); | |
for (const artifact of artifactsList.artifacts) { | |
console.log(`Downloading artifact: ${artifact.name}`); | |
const download = await github.rest.actions.downloadArtifact({ | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
artifact_id: artifact.id, | |
archive_format: 'zip', | |
}); | |
const fs = require('fs'); | |
fs.writeFileSync('${{github.workspace}}/' + artifact.name + '.zip', Buffer.from(download.data)); | |
console.log(`Downloaded and saved: ${artifact.name}.zip`); | |
} | |
- name: Unzip artifacts | |
if: steps.get_latest_run.outcome == 'success' | |
run: | | |
mkdir -p dist | |
for file in *.zip | |
do | |
echo "Unzipping $file" | |
unzip -j "$file" -d dist | |
done | |
echo "Contents of dist directory:" | |
ls -la dist | |
- name: Publish to PyPI | |
if: steps.get_latest_run.outcome == 'success' | |
uses: PyO3/maturin-action@v1 | |
env: | |
MATURIN_PYPI_TOKEN: ${{ secrets.PYPI_API_TOKEN }} | |
with: | |
command: upload | |
args: --non-interactive --skip-existing dist/* |