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@d632683dd7b4114ad314bca15554477dd762a938 # v4.2.0
- name: Set up Go
uses: actions/setup-go@0a12ed9d6a96ab950c8f026ed9f722fe0da7ef32 # v5.0.2
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@c062e08bd532815e2082a85e87e3ef29c3e6d191 # v2.0.8
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@c062e08bd532815e2082a85e87e3ef29c3e6d191 # v2.0.8
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@c062e08bd532815e2082a85e87e3ef29c3e6d191 # v2.0.8
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