v0.0.6 #7
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
on: | |
release: | |
types: [published] | |
name: Upload Release Asset | |
jobs: | |
release: | |
name: Upload Release Asset | |
runs-on: ubuntu-latest | |
steps: | |
- name: Install Go | |
uses: actions/setup-go@v2 | |
with: | |
go-version: 1.16.x | |
- name: Checkout repository | |
uses: actions/checkout@v2 | |
- name: Build binaries | |
run: | | |
version=$(git describe --tags --always --abbrev=5) | |
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -trimpath -ldflags="-extldflags=-static -w -s -X github.com/pallavJha/chaakoo/cmd.version=$version" -o "chaakoo-$version-linux-amd64" cmd/chaakoo/main.go | |
CGO_ENABLED=0 GOOS=linux GOARCH=arm64 go build -trimpath -ldflags="-extldflags=-static -w -s -X github.com/pallavJha/chaakoo/cmd.version=$version" -o "chaakoo-$version-linux-arm64" cmd/chaakoo/main.go | |
CGO_ENABLED=0 GOOS=darwin GOARCH=amd64 go build -trimpath -ldflags="-extldflags=-static -w -s -X github.com/pallavJha/chaakoo/cmd.version=$version" -o "chaakoo-$version-darwin-amd64" cmd/chaakoo/main.go | |
CGO_ENABLED=0 GOOS=darwin GOARCH=arm64 go build -trimpath -ldflags="-extldflags=-static -w -s -X github.com/pallavJha/chaakoo/cmd.version=$version" -o "chaakoo-$version-darwin-arm64" cmd/chaakoo/main.go | |
CGO_ENABLED=0 GOOS=windows GOARCH=amd64 go build -trimpath -ldflags="-extldflags=-static -w -s -X github.com/pallavJha/chaakoo/cmd.version=$version" -o "chaakoo-$version-windows-amd64" cmd/chaakoo/main.go | |
- name: Upload release artifacts | |
uses: actions/github-script@v3 | |
with: | |
github-token: ${{ secrets.PUBLISH_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("chaakoo-")) continue; | |
console.log("Uploading", file); | |
await github.repos.uploadReleaseAsset({ | |
owner, repo, | |
release_id: release.data.id, | |
name: file, | |
data: await fs.readFile(file), | |
}); | |
} |