owpengram-server/.github/workflows/build.yml
2026-09-01 12:06:31 +03:00

130 lines
2.9 KiB
YAML

name: Build and Release
on:
workflow_dispatch:
push:
tags:
- 'v*'
permissions:
contents: read
concurrency:
group: build-${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: false
jobs:
ci:
name: CI
uses: ./.github/workflows/ci.yml
build:
name: Build ${{ matrix.goos }}/${{ matrix.goarch }}
runs-on: ubuntu-24.04
timeout-minutes: 30
strategy:
fail-fast: false
matrix:
include:
- goos: linux
goarch: amd64
- goos: linux
goarch: arm64
- goos: windows
goarch: amd64
- goos: windows
goarch: arm64
steps:
- name: Checkout
uses: actions/checkout@v7
- name: Set up Go
uses: actions/setup-go@v7
with:
go-version-file: go.mod
cache-dependency-path: go.sum
- name: Set up Node
uses: actions/setup-node@v6
with:
node-version: '22'
cache: npm
cache-dependency-path: cmd/telesrv-admin/web/package-lock.json
- name: Build admin web assets
working-directory: cmd/telesrv-admin/web
run: |
npm ci
npm run build
- name: Download Go modules
run: go mod download
- name: Build binaries
env:
CGO_ENABLED: '0'
GOOS: ${{ matrix.goos }}
GOARCH: ${{ matrix.goarch }}
run: |
mkdir -p dist
suffix=""
if [ "${GOOS}" = "windows" ]; then
suffix=".exe"
fi
go build \
-trimpath \
-ldflags="-s -w" \
-o "dist/gramsrv-${GOOS}-${GOARCH}${suffix}" \
./cmd/telesrv
go build \
-trimpath \
-ldflags="-s -w" \
-o "dist/gramsrv-admin-${GOOS}-${GOARCH}${suffix}" \
./cmd/telesrv-admin
- name: Upload build artifact
uses: actions/upload-artifact@v4
with:
name: gramsrv-${{ matrix.goos }}-${{ matrix.goarch }}
path: dist/*
if-no-files-found: error
retention-days: 7
release:
name: Publish GitHub Release
needs:
- ci
- build
if: startsWith(github.ref, 'refs/tags/v')
runs-on: ubuntu-24.04
timeout-minutes: 15
permissions:
contents: write
steps:
- name: Download build artifacts
uses: actions/download-artifact@v4
with:
pattern: gramsrv-*
path: dist
merge-multiple: true
- name: Generate combined checksums
working-directory: dist
run: |
sha256sum gramsrv-* > SHA256SUMS
- name: Publish GitHub Release
env:
GH_TOKEN: ${{ github.token }}
run: |
gh release create "${{ github.ref_name }}" \
dist/* \
--title "${{ github.ref_name }}" \
--generate-notes