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 platform: Windows goos: windows extension: .exe archive: zip - name: Linux platform: Linux goos: linux extension: '' archive: tar.gz - name: macOS platform: 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_${{ matrix.platform }}" binary_name="Home-Vue-Go${{ 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: Home-Vue-Go_${{ matrix.platform }} path: Home-Vue-Go_${{ matrix.platform }}.${{ 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: Checkout uses: actions/checkout@v4 - name: Select release notes id: notes shell: bash run: | notes_file=".github/release-notes/${GITHUB_REF_NAME}.md" if [ -f "${notes_file}" ]; then echo "path=${notes_file}" >> "${GITHUB_OUTPUT}" else echo "path=" >> "${GITHUB_OUTPUT}" fi - name: Download package artifacts uses: actions/download-artifact@v4 with: pattern: Home-Vue-Go_* path: release merge-multiple: true - name: Publish release uses: softprops/action-gh-release@v2 with: name: Home-Vue-Go ${{ github.ref_name }} body_path: ${{ steps.notes.outputs.path }} generate_release_notes: ${{ steps.notes.outputs.path == '' }} files: release/*