ci: add release job and package binaries

- Package Linux as tar.gz and Windows as zip
- Include config.yml in releases
- Create GitHub release on push to main with auto-generated tag
- Add contents write permission
This commit is contained in:
lite 2026-05-17 17:25:34 -04:00
parent 1c29f9926a
commit 4e5d7bd8b1
1 changed files with 46 additions and 4 deletions

View File

@ -1,4 +1,4 @@
name: Build
name: Build & Release
on:
push:
@ -6,6 +6,9 @@ on:
pull_request:
branches: [main]
permissions:
contents: write
jobs:
build:
runs-on: ubuntu-latest
@ -24,10 +27,49 @@ jobs:
env:
GOOS: ${{ matrix.goos }}
GOARCH: ${{ matrix.goarch }}
run: go build -o verifactu-api-${{ matrix.goos }}-${{ matrix.goarch }} .
run: go build -o verifactu-api .
- name: Package Linux
if: matrix.goos == 'linux'
run: |
mkdir verifactu-api
mv verifactu-api 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 verifactu-api
mv verifactu-api.exe 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 }}-${{ matrix.goarch }}
path: verifactu-api-${{ matrix.goos }}-${{ matrix.goarch }}
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/* \
artifacts/verifactu-api-windows-amd64/*