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: | ||
workflow_run: | ||
workflows: ["Ceylon-Build-Python"] | ||
types: | ||
- completed | ||
branches: | ||
- main | ||
- master | ||
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}`); | ||
const { data: runs } = await github.rest.actions.listWorkflowRuns({ | ||
owner: context.repo.owner, | ||
repo: context.repo.repo, | ||
workflow_id: workflow_id, | ||
status: 'success', | ||
}); | ||
if (runs.total_count === 0) { | ||
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}`); | ||
core.setOutput('run_id', latestRun.id); | ||
- name: Download and unzip artifacts | ||
if: steps.get_latest_run.outcome == 'success' | ||
uses: actions/github-script@v6 | ||
with: | ||
script: | | ||
const fs = require('fs'); | ||
const path = require('path'); | ||
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(`Processing 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 artifactDir = path.join('${{github.workspace}}', 'dist', artifact.name); | ||
fs.mkdirSync(artifactDir, { recursive: true }); | ||
const zipPath = path.join(artifactDir, 'artifact.zip'); | ||
fs.writeFileSync(zipPath, Buffer.from(download.data)); | ||
console.log(`Unzipping ${zipPath} to ${artifactDir}`); | ||
await exec.exec('unzip', ['-j', zipPath, '-d', artifactDir]); | ||
console.log(`Removing zip file ${zipPath}`); | ||
fs.unlinkSync(zipPath); | ||
} | ||
console.log('Artifacts processed. Contents of dist directory:'); | ||
await exec.exec('ls', ['-R', '${{github.workspace}}/dist']); | ||
- name: Publish to PyPI | ||
uses: PyO3/maturin-action@v1 | ||
env: | ||
MATURIN_PYPI_TOKEN: ${{ secrets.PYPI_API_TOKEN }} | ||
with: | ||
command: upload | ||
args: --non-interactive --skip-existing ${{github.workspace}}/dist/**/*.whl |