Skip to content

Commit da515dc

Browse files
committed
Add artifact collection step
1 parent 1b5ea58 commit da515dc

1 file changed

Lines changed: 35 additions & 0 deletions

File tree

.github/workflows/build.yml

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,10 @@ on:
3737
git_ref:
3838
type: string
3939
default: master
40+
outputs:
41+
artifact-map:
42+
description: The artifact-id for built x64 wintray
43+
value: ${{ jobs.collect-artifacts.outputs.artifact-map }}
4044

4145
jobs:
4246
build:
@@ -72,7 +76,38 @@ jobs:
7276
run: dotnet publish -c Release -r win-${{ env.RUNTIME_IDENTIFIER }}
7377

7478
- name: Upload build artifacts
79+
id: upload-artifact
7580
uses: actions/upload-artifact@v4
7681
with:
7782
name: artifact-${{ env.RUNTIME_IDENTIFIER }}
7883
path: ${{ github.workspace }}\bin\Release\net9.0-windows\win-${{ env.RUNTIME_IDENTIFIER }}\publish
84+
85+
collect-artifacts:
86+
needs: build
87+
runs-on: ubuntu-latest
88+
outputs:
89+
# Expose the map as a job-level output
90+
artifact-map: ${{ steps.make-map.outputs.artifact-map }}
91+
steps:
92+
- name: List and map artifacts
93+
id: make-map
94+
uses: actions/github-script@v7
95+
with:
96+
script: |
97+
const core = require('@actions/core');
98+
// 1. Fetch all artifacts for this run
99+
const res = await github.rest.actions.listWorkflowRunArtifacts({
100+
owner: context.repo.owner,
101+
repo: 'wintray',
102+
run_id: context.runId
103+
});
104+
// 2. Reduce into { artifactName: id, … }
105+
const map = res.data.artifacts.reduce((acc, a) => {
106+
acc[a.name] = a.id;
107+
return acc;
108+
}, {});
109+
// 3. Output the JSON string
110+
const mapString = JSON.stringify(map);
111+
core.setOutput('artifact-map', mapString);
112+
core.debug(`Artifact map: ${mapString}`);
113+

0 commit comments

Comments
 (0)