feat: publish container image for cli (#11) #16
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: Release | |
on: | |
push: | |
tags: | |
- "v[0-9]+.[0-9]+.[0-9]+*" | |
permissions: | |
contents: write | |
jobs: | |
build_and_release: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Check out code | |
uses: actions/checkout@v3 | |
- name: Set up Go | |
uses: actions/setup-go@v4 | |
with: | |
go-version: "1.20.4" | |
- name: Build all targets | |
run: make build-all | |
- name: Compute checksums | |
run: | | |
cd bin | |
for file in deploykf-*; do | |
sha256sum "$file" > "$file.sha256" | |
done | |
- name: Create GitHub Release and Upload Release Assets | |
uses: actions/github-script@v6 | |
with: | |
script: | | |
const fs = require('fs'); | |
const path = require('path'); | |
const { repo: { owner, repo }, ref: tag_ref } = context; | |
const tag_name = tag_ref.replace('refs/tags/', ''); | |
const tag_version = tag_ref.replace('refs/tags/v', ''); | |
// Create a draft release | |
const response = await github.rest.repos.createRelease({ | |
owner: owner, | |
repo: repo, | |
tag_name: tag_name, | |
name: `deployKF CLI - ${tag_version}`, | |
draft: true, | |
prerelease: tag_name.includes('-'), | |
}); | |
const { id: release_id } = response.data; | |
// Upload each binary and checksum file | |
const globber = await glob.create('./bin/deploykf-*'); | |
for await (const file of globber.globGenerator()) { | |
const asset_name = path.basename(file); | |
const asset_path = `./bin/${asset_name}`; | |
core.info(`Uploading ${asset_name}`); | |
await github.rest.repos.uploadReleaseAsset({ | |
owner: owner, | |
repo: repo, | |
release_id: release_id, | |
name: asset_name, | |
data: fs.readFileSync(asset_path), | |
}); | |
} |