-
Notifications
You must be signed in to change notification settings - Fork 1
94 lines (78 loc) · 3.35 KB
/
pypi-release.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
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