Skip to content

Commit

Permalink
.github/workflows: use gh to upload release artifacts (FiloSottile#455)
Browse files Browse the repository at this point in the history
* .github/workflows: use gh to upload release artifacts

https://cli.github.com/manual/gh_release_upload

* .github/workflows: remove unnecessary braces

When you use expressions in an if conditional, you may omit the expression syntax ${{ }} because GitHub automatically evaluates the if conditional as an expression.

https://docs.github.com/en/actions/learn-github-actions/expressions
  • Loading branch information
0x2b3bfa0 authored Oct 10, 2022
1 parent 000e931 commit e05ce26
Showing 1 changed file with 5 additions and 24 deletions.
29 changes: 5 additions & 24 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ jobs:
path: age-*
upload:
name: Upload release binaries
if: ${{ github.event_name == 'release' }}
if: github.event_name == 'release'
needs: build
permissions:
contents: write
Expand All @@ -75,26 +75,7 @@ jobs:
with:
name: age-binaries
- name: Upload release artifacts
uses: actions/github-script@v3
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
const fs = require("fs").promises;
const { repo: { owner, repo }, sha } = context;
const release = await github.repos.getReleaseByTag({
owner, repo,
tag: process.env.GITHUB_REF.replace("refs/tags/", ""),
});
console.log("Release:", { release });
for (let file of await fs.readdir(".")) {
if (!file.startsWith("age-")) continue;
console.log("Uploading", file);
await github.repos.uploadReleaseAsset({
owner, repo,
release_id: release.data.id,
name: file,
data: await fs.readFile(file),
});
}
run: gh release upload "$GITHUB_REF_NAME" age-*
env:
GH_REPO: ${{ github.repository }}
GH_TOKEN: ${{ github.token }}

0 comments on commit e05ce26

Please sign in to comment.