diff --git a/.github/workflows/pypi-release.yml b/.github/workflows/pypi-release.yml index b978ef12..5dce3705 100644 --- a/.github/workflows/pypi-release.yml +++ b/.github/workflows/pypi-release.yml @@ -24,7 +24,6 @@ jobs: 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, @@ -33,38 +32,25 @@ jobs: 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 + - 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, @@ -74,35 +60,34 @@ jobs: console.log(`Found ${artifactsList.artifacts.length} artifacts`); for (const artifact of artifactsList.artifacts) { - console.log(`Downloading artifact: ${artifact.name}`); + 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 fs = require('fs'); - fs.writeFileSync('${{github.workspace}}/' + artifact.name + '.zip', Buffer.from(download.data)); - console.log(`Downloaded and saved: ${artifact.name}.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); } - - - 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 + + console.log('Artifacts processed. Contents of dist directory:'); + await exec.exec('ls', ['-R', '${{github.workspace}}/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/* \ No newline at end of file + args: --non-interactive --skip-existing ${{github.workspace}}/dist/**/*.whl \ No newline at end of file