Merge branch 'main' of github.com:someengineering/fixctl #28
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: Build and Release fixctl | |
on: | |
push: | |
tags: | |
- "*.*.*" | |
branches: | |
- main | |
jobs: | |
build: | |
name: Build fixctl on ${{ matrix.os }} | |
runs-on: ${{ matrix.os }} | |
strategy: | |
matrix: | |
os: [ubuntu-latest, windows-latest, macos-latest] | |
go-version: [1.22] | |
steps: | |
- name: Set up Go | |
uses: actions/setup-go@v5 | |
with: | |
go-version: ${{ matrix.go-version }} | |
- name: Check out code | |
uses: actions/checkout@v4 | |
- name: Set up environment | |
shell: bash | |
run: | | |
OS_NAME=$(echo ${{ matrix.os }} | sed 's/-latest//') | |
SUFFIX="" | |
if [ $OS_NAME = "windows" ]; then | |
SUFFIX=".exe" | |
fi | |
if [ $OS_NAME = "ubuntu" ]; then | |
OS_NAME="linux" | |
fi | |
echo "SUFFIX=$SUFFIX" >> $GITHUB_ENV | |
echo "OS_NAME=$OS_NAME" >> $GITHUB_ENV | |
- name: Build Binary (amd64) | |
run: | | |
GOARCH=amd64 go build -ldflags "-s -w" -o "${{ github.workspace }}/release/fixctl-$OS_NAME-amd64-${{ github.ref_name }}$SUFFIX" | |
shell: bash | |
- name: Build Binary (arm64) | |
run: | | |
GOARCH=arm64 go build -ldflags "-s -w" -o "${{ github.workspace }}/release/fixctl-$OS_NAME-arm64-${{ github.ref_name }}$SUFFIX" | |
shell: bash | |
- name: Generate Universal Binary (macOS) | |
if: matrix.os == 'macos-latest' | |
run: | | |
lipo -create -output "${{ github.workspace }}/release/fixctl-$OS_NAME-universal-${{ github.ref_name }}$SUFFIX" "${{ github.workspace }}/release/fixctl-$OS_NAME-amd64-${{ github.ref_name }}$SUFFIX" "${{ github.workspace }}/release/fixctl-$OS_NAME-arm64-${{ github.ref_name }}$SUFFIX" | |
rm -f "${{ github.workspace }}/release/fixctl-$OS_NAME-amd64-${{ github.ref_name }}$SUFFIX" "${{ github.workspace }}/release/fixctl-$OS_NAME-arm64-${{ github.ref_name }}$SUFFIX" | |
strip "${{ github.workspace }}/release/fixctl-$OS_NAME-universal-${{ github.ref_name }}$SUFFIX" | |
shell: bash | |
- name: Upload artifacts | |
uses: actions/upload-artifact@v4 | |
with: | |
name: fixctl-${{ matrix.os }}-${{ github.ref_name }} | |
path: ${{ github.workspace }}/release/ | |
create_release: | |
name: Create Release | |
needs: build | |
if: startsWith(github.ref, 'refs/tags/') | |
runs-on: ubuntu-latest | |
steps: | |
- name: Download all artifacts | |
uses: actions/download-artifact@v4 | |
with: | |
path: ${{ github.workspace }}/release | |
- name: Create Release | |
id: create_release | |
uses: softprops/action-gh-release@v2 | |
with: | |
tag_name: ${{ github.ref_name }} | |
name: ${{ github.ref_name }} | |
draft: false | |
prerelease: false | |
files: | | |
${{ github.workspace }}/release/*/* | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |