From 4e5d7bd8b1817b85e8342375feb7af7419ef0b22 Mon Sep 17 00:00:00 2001 From: lite Date: Sun, 17 May 2026 17:25:34 -0400 Subject: [PATCH] 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 --- .github/workflows/build.yml | 50 ++++++++++++++++++++++++++++++++++--- 1 file changed, 46 insertions(+), 4 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 6eef313..cb5578d 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -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/*