Skip to content

Workflow file for this run

name: Build CLIs and Upload Them as Release Assets
on:
release:
types:
- published
permissions: {}
jobs:
build:
runs-on: ubuntu-latest
permissions:
contents: write
strategy:
matrix:
cli: [fitactivity, fitconv]
os: [linux, macOS, windows]
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- name: Set up Go
uses: actions/setup-go@41dfa10bad2bb2ae585af6ee5bb4d7d973ad74ed # v5.1.0
with:
go-version: "stable"
- name: Build [macOS]
if: matrix.os == 'macOS'
run: |
CGO_ENABLED=0 GOOS=darwin GOARCH=amd64 go build -ldflags="-s -w -X 'main.version=$(git describe --tags)'" -trimpath -o $cli cmd/$cli/main.go
zip -9q $cli-$os-amd64.zip $cli
CGO_ENABLED=0 GOOS=darwin GOARCH=arm64 go build -ldflags="-s -w -X 'main.version=$(git describe --tags)'" -trimpath -o $cli cmd/$cli/main.go
zip -9q $cli-$os-arm64.zip $cli
rm $cli
printf "sha256: %s\n" "$(shasum -a 256 $cli-$os-amd64.zip)"
printf "sha256: %s\n" "$(shasum -a 256 $cli-$os-arm64.zip)"
env:
cli: ${{ matrix.cli }}
os: ${{ matrix.os }}
- name: Build [windows]
if: matrix.os == 'windows'
run: |
CGO_ENABLED=0 GOOS=$os GOARCH=amd64 go build -ldflags="-s -w -X 'main.version=$(git describe --tags)'" -trimpath -o $cli.exe cmd/$cli/main.go
zip -9q $cli-$os-amd64.zip $cli.exe
rm $cli.exe
printf "sha256: %s\n" "$(shasum -a 256 $cli-$os-amd64.zip)"
env:
cli: ${{ matrix.cli }}
os: ${{ matrix.os }}
- name: Build [linux]
if: matrix.os == 'linux'
run: |
CGO_ENABLED=0 GOOS=$os GOARCH=amd64 go build -ldflags="-s -w -X 'main.version=$(git describe --tags)'" -trimpath -o $cli cmd/$cli/main.go
tar -I 'gzip -9' -cf $cli-$os-amd64.tar.gz $cli
rm $cli
printf "sha256: %s\n" "$(shasum -a 256 $cli-$os-amd64.tar.gz)"
env:
cli: ${{ matrix.cli }}
os: ${{ matrix.os }}
- name: Upload Release Assets [macOS]
uses: softprops/action-gh-release@01570a1f39cb168c169c802c3bceb9e93fb10974 # v2.1.0
if: startsWith(github.ref, 'refs/tags/v') && matrix.os == 'macOS'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
files: |
${{ matrix.cli }}-${{ matrix.os }}-amd64.zip
${{ matrix.cli }}-${{ matrix.os }}-arm64.zip
- name: Upload Release Assets [windows]
uses: softprops/action-gh-release@01570a1f39cb168c169c802c3bceb9e93fb10974 # v2.1.0
if: startsWith(github.ref, 'refs/tags/v') && matrix.os == 'windows'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
files: ${{ matrix.cli }}-${{ matrix.os }}-amd64.zip
- name: Upload Release Assets [linux]
uses: softprops/action-gh-release@01570a1f39cb168c169c802c3bceb9e93fb10974 # v2.1.0
if: startsWith(github.ref, 'refs/tags/v') && matrix.os == 'linux'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
files: ${{ matrix.cli }}-${{ matrix.os }}-amd64.tar.gz