@@ -55,49 +55,47 @@ jobs:
5555 script : |
5656 const artifactName = `PyFlowGraph-Windows-${{ inputs.tag_name }}`;
5757
58- // Get the commit SHA for the tag
59- const tagRef = await github.rest.git.getRef({
60- owner: context.repo.owner,
61- repo: context.repo.repo,
62- ref: 'tags/${{ inputs.tag_name }}'
63- });
64- const tagSha = tagRef.data.object.sha;
65- console.log(`Tag ${{ inputs.tag_name }} points to commit: ${tagSha}`);
66-
67- // Search for workflow runs that built this specific commit
58+ // Search for recent successful builds (last 50 runs)
6859 const workflowRuns = await github.rest.actions.listWorkflowRunsForRepo({
6960 owner: context.repo.owner,
7061 repo: context.repo.repo,
7162 workflow_id: 'windows-build.yml',
72- head_sha: tagSha,
7363 status: 'completed',
74- conclusion: 'success'
64+ conclusion: 'success',
65+ per_page: 50
7566 });
7667
77- if (workflowRuns.data.workflow_runs.length === 0) {
78- throw new Error(`No successful build found for tag ${{ inputs.tag_name }} (commit: ${tagSha})`);
79- }
68+ console.log(`Searching for artifact '${artifactName}' in ${workflowRuns.data.workflow_runs.length} recent successful builds...`);
8069
81- const runId = workflowRuns.data.workflow_runs[0].id;
82- console.log(`Found build run: ${runId}`);
70+ // Search through recent successful builds to find the artifact
71+ let foundArtifact = null;
72+ let foundRunId = null;
8373
84- // Find the artifact in that run
85- const artifacts = await github.rest.actions.listWorkflowRunArtifacts({
86- owner: context.repo.owner,
87- repo: context.repo.repo,
88- run_id: runId
89- });
74+ for (const run of workflowRuns.data.workflow_runs) {
75+ const artifacts = await github.rest.actions.listWorkflowRunArtifacts({
76+ owner: context.repo.owner,
77+ repo: context.repo.repo,
78+ run_id: run.id
79+ });
80+
81+ const artifact = artifacts.data.artifacts.find(a => a.name === artifactName);
82+ if (artifact) {
83+ foundArtifact = artifact;
84+ foundRunId = run.id;
85+ console.log(`Found artifact '${artifactName}' in build run ${run.id} (commit: ${run.head_sha.substring(0,7)})`);
86+ break;
87+ }
88+ }
9089
91- const artifact = artifacts.data.artifacts.find(a => a.name === artifactName);
92- if (!artifact) {
93- throw new Error(`Artifact '${artifactName}' not found in build run ${runId}`);
90+ if (!foundArtifact) {
91+ throw new Error(`Artifact '${artifactName}' not found in any recent successful builds`);
9492 }
9593
96- console.log(`Found artifact: ${artifact .name} (ID: ${artifact .id})`);
94+ console.log(`Using artifact: ${foundArtifact .name} (ID: ${foundArtifact .id})`);
9795
98- core.setOutput('artifact_id', artifact .id);
99- core.setOutput('run_id', runId );
100- core.setOutput('artifact_name', artifact .name);
96+ core.setOutput('artifact_id', foundArtifact .id);
97+ core.setOutput('run_id', foundRunId );
98+ core.setOutput('artifact_name', foundArtifact .name);
10199
102100 - name : Download build artifact
103101 uses : actions/download-artifact@v4
0 commit comments