Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ci: use ncipollo/release-action for uploading release artifacts #1292

Merged
merged 1 commit into from
Dec 19, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
52 changes: 9 additions & 43 deletions .github/workflows/release-please.yml
Original file line number Diff line number Diff line change
Expand Up @@ -55,54 +55,20 @@ jobs:
fetch-depth: 0
ref: "${{ needs.release-please.outputs.release_tag }}"

- name: Look up release
id: lookup-release
uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7.0.1
with:
script: |
const currentTag = "${{ needs.release-please.outputs.release_tag }}";
core.info(`Looking for release associated with '${currentTag}'`);
const release = await github.rest.repos.getReleaseByTag({
owner: context.repo.owner,
repo: context.repo.repo,
tag: currentTag
});
core.info(`Release found: ${release.data.id}'`);
core.setOutput('release_id', release.data.id);


- uses: ./.github/actions/setup-goversion

- name: Build binaries
run: make cross

- name: Attach binaries
uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7.0.1
uses: ncipollo/release-action@2c591bcc8ecdcd2db72b97d6147f871fcd833ba5 # v1.14.0
with:
github-token: ${{ github.token }}
script: |
const path = require('node:path');
const fs = require('node:fs/promises');

const releaseId = '${{ steps.lookup-release.outputs.release_id }}';
const globber = await glob.create('dist/*');

for await (const file of globber.globGenerator()) {
const filename = path.basename(file);
try {
await github.rest.repos.uploadReleaseAsset({
owner: context.repo.owner,
repo: context.repo.repo,
release_id: releaseId,
name: filename,
data: await fs.readFile(file),
});
} catch (e) {
if (e.status === 422) {
core.setFailed(`${filename} already attached to release`);
return;
}
throw e;
}
}
token: ${{ github.token }}
allowUpdates: true
tag: ${{ needs.release-please.outputs.release_tag }}
omitNameDuringUpdate: true
omitPrereleaseDuringUpdate: true
omitBodyDuringUpdate: true
omitDraftDuringUpdate: true
artifacts: "dist/**/*"

Loading