6f07849a53
Build Packages / Test (push) Has been cancelled
Build Packages / Build macOS package (push) Has been cancelled
Build Packages / Build Linux package (push) Has been cancelled
Build Packages / Build Windows package (push) Has been cancelled
Build Packages / Publish GitHub Release (push) Has been cancelled
117 lines
3.0 KiB
YAML
117 lines
3.0 KiB
YAML
name: Build Packages
|
|
|
|
on:
|
|
push:
|
|
branches: [main]
|
|
tags: ['v*']
|
|
pull_request:
|
|
workflow_dispatch:
|
|
|
|
permissions:
|
|
contents: read
|
|
|
|
jobs:
|
|
test:
|
|
name: Test
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- name: Checkout
|
|
uses: actions/checkout@v4
|
|
- name: Set up Node.js
|
|
uses: actions/setup-node@v4
|
|
with:
|
|
node-version: 20
|
|
cache: npm
|
|
- name: Set up Go
|
|
uses: actions/setup-go@v5
|
|
with:
|
|
go-version: '1.23'
|
|
- name: Install frontend dependencies
|
|
run: npm ci
|
|
- name: Run frontend tests
|
|
run: npm test -- --run
|
|
- name: Build frontend assets
|
|
run: npm run build
|
|
- name: Run Go tests
|
|
run: go test -buildvcs=false ./...
|
|
|
|
build:
|
|
name: Build ${{ matrix.name }} package
|
|
needs: test
|
|
runs-on: ubuntu-latest
|
|
strategy:
|
|
fail-fast: false
|
|
matrix:
|
|
include:
|
|
- name: Windows
|
|
goos: windows
|
|
extension: .exe
|
|
archive: zip
|
|
- name: Linux
|
|
goos: linux
|
|
extension: ''
|
|
archive: tar.gz
|
|
- name: macOS
|
|
goos: darwin
|
|
extension: ''
|
|
archive: tar.gz
|
|
steps:
|
|
- name: Checkout
|
|
uses: actions/checkout@v4
|
|
- name: Set up Node.js
|
|
uses: actions/setup-node@v4
|
|
with:
|
|
node-version: 20
|
|
cache: npm
|
|
- name: Set up Go
|
|
uses: actions/setup-go@v5
|
|
with:
|
|
go-version: '1.23'
|
|
- name: Build embedded frontend
|
|
run: |
|
|
npm ci
|
|
npm run build
|
|
- name: Build binary and package
|
|
shell: bash
|
|
env:
|
|
GOOS: ${{ matrix.goos }}
|
|
GOARCH: amd64
|
|
CGO_ENABLED: 0
|
|
run: |
|
|
set -euo pipefail
|
|
package_name="home-vue-go-${GOOS}-amd64"
|
|
binary_name="${package_name}${{ matrix.extension }}"
|
|
go build -trimpath -buildvcs=false -ldflags="-s -w" -o "${binary_name}" .
|
|
mkdir package
|
|
cp "${binary_name}" README.md LICENSE package/
|
|
if [ "${{ matrix.archive }}" = "zip" ]; then
|
|
(cd package && zip -q -r "../${package_name}.zip" .)
|
|
else
|
|
tar -czf "${package_name}.tar.gz" -C package .
|
|
fi
|
|
- name: Upload package artifact
|
|
uses: actions/upload-artifact@v4
|
|
with:
|
|
name: package-${{ matrix.goos }}
|
|
path: home-vue-go-${{ matrix.goos }}-amd64.${{ matrix.archive }}
|
|
if-no-files-found: error
|
|
|
|
release:
|
|
name: Publish GitHub Release
|
|
if: startsWith(github.ref, 'refs/tags/v')
|
|
needs: build
|
|
runs-on: ubuntu-latest
|
|
permissions:
|
|
contents: write
|
|
steps:
|
|
- name: Download package artifacts
|
|
uses: actions/download-artifact@v4
|
|
with:
|
|
pattern: package-*
|
|
path: release
|
|
merge-multiple: true
|
|
- name: Publish release
|
|
uses: softprops/action-gh-release@v2
|
|
with:
|
|
files: release/*
|