v0.10.1 #12
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Upload Release Assets | |
on: | |
release: | |
types: [published] | |
jobs: | |
release: | |
name: Upload Release Asset | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v3 | |
- name: Install Go | |
uses: actions/setup-go@v4 | |
with: | |
go-version: '>=1.19.0' | |
- name: Build binaries | |
run: | | |
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build \ | |
-ldflags="-X 'github.com/vorlif/xspreak/commands.Version=$(git describe --tags)'" \ | |
-o "xspreak-$(git describe --tags)-linux-amd64" | |
CGO_ENABLED=0 GOOS=darwin GOARCH=amd64 go build \ | |
-ldflags="-X 'github.com/vorlif/xspreak/commands.Version=$(git describe --tags)'" \ | |
-o "xspreak-$(git describe --tags)-darwin-amd64" | |
CGO_ENABLED=0 GOOS=windows GOARCH=amd64 go build \ | |
-ldflags="-X 'github.com/vorlif/xspreak/commands.Version=$(git describe --tags)'" \ | |
-o "xspreak-$(git describe --tags)-windows-amd64.exe" | |
- name: Upload release artifacts | |
uses: actions/github-script@v7 | |
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("xspreak-")) continue; | |
console.log("Uploading", file); | |
await github.repos.uploadReleaseAsset({ | |
owner, repo, | |
release_id: release.data.id, | |
name: file, | |
data: await fs.readFile(file), | |
}); | |
} |