Files
Alma/.github/workflows/github-actions.yml

68 lines
1.8 KiB
YAML

name: Build and Release Go App
on:
push:
# tags:
# - 'v*' # Runs only when a new version tag is pushed
jobs:
build:
name: Build Go App
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
goarch: [amd64]
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: '1.21'
- name: Set environment variables
if: runner.os != 'Windows'
run: |
echo "GOOS=${{ runner.os == 'Windows' && 'windows' || runner.os == 'macos' && 'darwin' || 'linux' }}" >> $GITHUB_ENV
echo "GOARCH=${{ matrix.goarch }}" >> $GITHUB_ENV
- name: Set environment variables
if: runner.os == 'Windows'
run: |
Add-Content -Path $env:GITHUB_ENV "GOOS=${{ runner.os == 'Windows' && 'windows' || runner.os == 'macos' && 'darwin' || 'linux' }}"
Add-Content -Path $env:GITHUB_ENV "GOARCH=${{ matrix.goarch }}"
- name: Build application
run: |
mkdir -p dist
go build -o dist/alma-${{ env.GOOS }}-${{ env.GOARCH }}${{ env.GOOS == 'windows' && '.exe' || '' }}
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: app-${{ env.GOOS }}-${{ env.GOARCH }}
path: dist/*
release:
name: Create GitHub Release
runs-on: ubuntu-latest
needs: build
steps:
- name: Download all artifacts
uses: actions/download-artifact@v4
with:
path: dist
- name: Create release
uses: softprops/action-gh-release@v2
with:
files: dist/**/*
draft: true
prerelease: false
generate_release_notes: true
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}