Auto Release #3
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: Auto Relese | |
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: | |
path: build/ | |
- name: List downloaded files | |
run: ls -R 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/untisDSB-ubuntu-latest-amd64 | |
build/untisDSB-windows-latest-amd64 | |
build/ubuntu-latest/amd64/untisDSB | |
build/windows-latest/amd64/untisDSB |