Skip to content

Go

Go #23

Workflow file for this run

# This workflow will build a golang project
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-go
name: Go
on:
release:
types: [published]
pull_request:
jobs:
build:
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- uses: actions/checkout@v4
- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: '1.23.1'
- name: Advance Version
if: github.event_name == 'release' && github.event.action == 'published'
run: |
cat <<< $(jq '.version="${{github.event.release.tag_name}}"' internal/config/config.json) > internal/config/config.json
- name: Build Linux AMD64
if: github.event_name == 'release' && github.event.action == 'published'
env:
GOOS: "linux"
GOARCH: "amd64"
BINARY: "linux-amd64"
GH_TOKEN: ${{ github.token }}
run: |
export FILENAME=krknctl-${{github.event.release.tag_name}}-$BINARY.tar.gz
sudo apt-get update && sudo apt-get install libbtrfs-dev
go build -tags containers_image_openpgp -ldflags="-w -s" -o $BINARY/ ./...
tar cfvz $FILENAME -C $BINARY krknctl
gh release upload ${{github.event.release.tag_name}} $FILENAME
- name: Build Linux ARM64
if: github.event_name == 'release' && github.event.action == 'published'
env:
GOOS: "linux"
GOARCH: "arm64"
BINARY: "linux-amd64"
GH_TOKEN: ${{ github.token }}
run: |
export FILENAME=krknctl-${{github.event.release.tag_name}}-$BINARY.tar.gz
sudo apt-get update && sudo apt-get install libbtrfs-dev
go build -tags containers_image_openpgp -ldflags="-w -s" -o $BINARY/ ./...
tar cfvz $FILENAME -C $BINARY krknctl
gh release upload ${{github.event.release.tag_name}} $FILENAME
- name: Build Darwin ARM64
if: github.event_name == 'release' && github.event.action == 'published'
env:
GOOS: "darwin"
GOARCH: "arm64"
BINARY: "darwin-arm64"
GH_TOKEN: ${{ github.token }}
run: |
export FILENAME=krknctl-${{github.event.release.tag_name}}-$BINARY.tar.gz
sudo apt-get update && sudo apt-get install libbtrfs-dev
go build -tags containers_image_openpgp -ldflags="-w -s" -o $BINARY/ ./...
tar cfvz $FILENAME -C $BINARY krknctl
gh release upload ${{github.event.release.tag_name}} $FILENAME
- name: Build Darwin AMD64
if: github.event_name == 'release' && github.event.action == 'published'
env:
GOOS: "darwin"
GOARCH: "amd64"
BINARY: "darwin-arm64"
GH_TOKEN: ${{ github.token }}
run: |
export FILENAME=krknctl-${{github.event.release.tag_name}}-$BINARY.tar.gz
sudo apt-get update && sudo apt-get install libbtrfs-dev
go build -tags containers_image_openpgp -ldflags="-w -s" -o $BINARY/ ./...
tar cfvz $FILENAME -C $BINARY krknctl
gh release upload ${{github.event.release.tag_name}} $FILENAME
- name: Test
if: github.event_name == 'pull_request'
run: |
go test -v ./...