mirror of
https://github.com/FiloSottile/age.git
synced 2026-01-08 21:03:05 +00:00
.github/workflows: use gh to upload release artifacts (#455)
* .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
This commit is contained in:
29
.github/workflows/build.yml
vendored
29
.github/workflows/build.yml
vendored
@@ -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
|
||||
@@ -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 }}
|
||||
|
||||
Reference in New Issue
Block a user