Merge pull request #13 from TibaGroup/patch/workflow #4
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: Go Release | |
on: | |
push: | |
tags: | |
- 'v*.*.*' | |
branches: | |
- main | |
workflow_dispatch: | |
jobs: | |
release: | |
name: Release | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v3 | |
- name: Set up Go | |
uses: actions/setup-go@v5 | |
with: | |
go-version: '1.22' | |
- name: Install ARM64 Cross Compiler | |
run: sudo apt-get update && sudo apt-get install -y gcc-aarch64-linux-gnu | |
- name: Cache Go modules | |
uses: actions/cache@v3 | |
with: | |
path: ~/go/pkg/mod | |
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }} | |
restore-keys: | | |
${{ runner.os }}-go- | |
- name: Install dependencies | |
run: go mod tidy | |
- name: Get the Git tag version | |
id: get_version | |
run: | | |
# Get the current tag or default to 'latest' | |
VERSION=$(git describe --tags --abbrev=0 || echo "latest") | |
echo "VERSION=$VERSION" >> $GITHUB_ENV | |
- name: Build binaries for multiple platforms | |
env: | |
GOOS: darwin,windows,linux | |
GOARCH: amd64,arm64 | |
VERSION: ${{ env.VERSION }} | |
run: | | |
mkdir -p build | |
for OS in ${GOOS//,/ }; do | |
for ARCH in ${GOARCH//,/ }; do | |
echo "Building for $OS/$ARCH with version $VERSION" | |
# Set CC for linux/arm64 to aarch64-linux-gnu-gcc | |
if [ "$OS" = "linux" ] && [ "$ARCH" = "arm64" ]; then | |
export CC=aarch64-linux-gnu-gcc | |
export CGO_ENABLED=1 | |
fi | |
GOOS=$OS GOARCH=$ARCH go build -o build/nomad-dotnet-driver-$VERSION-$OS-$ARCH | |
done | |
done | |
- name: Create GitHub Release | |
uses: softprops/action-gh-release@v1 | |
with: | |
files: build/* | |
- name: Upload release assets | |
uses: actions/upload-artifact@v3 | |
with: | |
name: nomad-dotnet-driver | |
path: build/ |