Skip to content

fixed auto release

fixed auto release #1

Workflow file for this run

name: Go Build for Multiple Platforms
on:
push:
tags:
- 'v*.*.*' # Trigger only on tags like v1.0.0, v1.1.0, etc.
jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
os: [ ubuntu-latest, windows-latest] # Platforms to build on
arch: [ amd64 ] # Architecture
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: '1.22.1'
- name: Build the project
run: |
# Set GOOS based on the platform
if [ "${{ matrix.os }}" = "ubuntu-latest" ]; then
GOOS=linux
elif [ "${{ matrix.os }}" = "windows-latest" ]; then
GOOS=windows
else
echo "Unsupported OS"
exit 1
fi
GOARCH=${{ matrix.arch }}
echo "Building for $GOOS $GOARCH"
# Create the build directory
mkdir -p build/$GOOS/$GOARCH/untisDSB
# Build the project
env GOOS=$GOOS GOARCH=$GOARCH go build -o build/$GOOS/$GOARCH/untisDSB main.go
- name: Run tests
run: go test -v ./...
- name: Upload build artifacts
uses: actions/upload-artifact@v3
with:
name: untisDSB-${{ matrix.os }}-${{ matrix.arch }}
path: build/${{ matrix.os == 'ubuntu-latest' && 'linux' || matrix.os == 'windows-latest' && 'windows' }}/${{ matrix.arch }}/untisDSB
release:
needs: build # This ensures the 'release' job runs after 'build' is completed
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Download all build artifacts
uses: actions/download-artifact@v3
with:
name: untisDSB-${{ matrix.os }}-${{ matrix.arch }}
path: build/
- name: Create GitHub Release
uses: softprops/action-gh-release@v1
with:
tag_name: ${{ github.ref_name }} # Use the pushed tag as the release tag
files: |
build/linux/amd64/untisDSB
build/windows/amd64/untisDSB
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}