76 lines
1.9 KiB
YAML
76 lines
1.9 KiB
YAML
name: Build & Release
|
|
|
|
on:
|
|
push:
|
|
branches: [main]
|
|
pull_request:
|
|
branches: [main]
|
|
|
|
permissions:
|
|
contents: write
|
|
|
|
jobs:
|
|
build:
|
|
runs-on: ubuntu-latest
|
|
strategy:
|
|
matrix:
|
|
goos: [linux, windows]
|
|
goarch: [amd64]
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
|
|
- uses: actions/setup-go@v5
|
|
with:
|
|
go-version-file: go.mod
|
|
|
|
- name: Build
|
|
env:
|
|
GOOS: ${{ matrix.goos }}
|
|
GOARCH: ${{ matrix.goarch }}
|
|
run: go build -o verifactu-api-bin .
|
|
|
|
- name: Package Linux
|
|
if: matrix.goos == 'linux'
|
|
run: |
|
|
mkdir -p verifactu-api
|
|
mv verifactu-api-bin verifactu-api/verifactu-api
|
|
cp config.yml verifactu-api/
|
|
tar czf verifactu-api-linux-amd64.tar.gz verifactu-api/
|
|
|
|
- name: Package Windows
|
|
if: matrix.goos == 'windows'
|
|
run: |
|
|
mkdir -p verifactu-api
|
|
mv verifactu-api-bin verifactu-api/verifactu-api.exe
|
|
cp config.yml verifactu-api/
|
|
zip -r verifactu-api-windows-amd64.zip verifactu-api/
|
|
|
|
- name: Upload artifact
|
|
uses: actions/upload-artifact@v4
|
|
with:
|
|
name: verifactu-api-${{ matrix.goos }}-amd64
|
|
path: verifactu-api-${{ matrix.goos }}-amd64.*
|
|
|
|
release:
|
|
needs: build
|
|
runs-on: ubuntu-latest
|
|
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
|
|
- name: Download artifacts
|
|
uses: actions/download-artifact@v4
|
|
with:
|
|
path: artifacts
|
|
|
|
- name: Create release
|
|
env:
|
|
GH_TOKEN: ${{ github.token }}
|
|
run: |
|
|
TAG="v$(date +%Y%m%d)-${GITHUB_SHA::7}"
|
|
gh release create "$TAG" \
|
|
--title "Build $TAG" \
|
|
--generate-notes \
|
|
artifacts/verifactu-api-linux-amd64/verifactu-api-linux-amd64.tar.gz \
|
|
artifacts/verifactu-api-windows-amd64/verifactu-api-windows-amd64.zip
|