Skip to content

Add versioning support and detailed CLI version command #2

Add versioning support and detailed CLI version command

Add versioning support and detailed CLI version command #2

Workflow file for this run

name: Release
on:
push:
tags:
- 'v*'
permissions:
contents: write
jobs:
build-and-release:
name: Build ${{ matrix.goos }}-${{ matrix.goarch }}
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
goos: [linux, darwin]
goarch: [amd64, arm64]
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Go
uses: actions/setup-go@v5
with:
go-version: '1.21'
check-latest: true
- name: Cache Go modules
uses: actions/cache@v4
with:
path: |
~/.cache/go-build
~/go/pkg/mod
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-
- name: Build binary
env:
CGO_ENABLED: 0
GOOS: ${{ matrix.goos }}
GOARCH: ${{ matrix.goarch }}
run: |
mkdir -p dist
BIN_NAME=pumadevctl
OUT=dist/${BIN_NAME}_${GOOS}_${GOARCH}
go build -trimpath -ldflags "-s -w" -o "$OUT" .
tar -C dist -czf "${OUT}.tar.gz" "${BIN_NAME}_${GOOS}_${GOARCH}"
- name: Create GitHub Release (if not exists)
id: create_release
uses: softprops/action-gh-release@v2
with:
draft: false
prerelease: false
name: ${{ github.ref_name }}
tag_name: ${{ github.ref_name }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Upload assets
uses: softprops/action-gh-release@v2
with:
files: |
dist/pumadevctl_${{ matrix.goos }}_${{ matrix.goarch }}.tar.gz
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}