mirror of
https://github.com/juanfont/headscale.git
synced 2026-09-30 11:59:39 +09:00
97 lines
3.2 KiB
YAML
97 lines
3.2 KiB
YAML
name: Build
|
|
|
|
on:
|
|
push:
|
|
branches:
|
|
- main
|
|
pull_request:
|
|
|
|
concurrency:
|
|
group: ${{ github.workflow }}-$${{ github.head_ref || github.run_id }}
|
|
cancel-in-progress: true
|
|
|
|
defaults:
|
|
run:
|
|
shell: nix develop --fallback --command bash -e {0}
|
|
|
|
jobs:
|
|
build-nix:
|
|
runs-on: ubuntu-latest
|
|
permissions: write-all
|
|
steps:
|
|
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
|
|
with:
|
|
fetch-depth: 2
|
|
- name: Get changed files
|
|
id: changed-files
|
|
uses: dorny/paths-filter@ceb8a2b8f2d89434be7ff52d3de7ec3738c5cc9d # v4.0.3
|
|
with:
|
|
filters: |
|
|
files:
|
|
- '*.nix'
|
|
- 'go.*'
|
|
- '**/*.go'
|
|
- 'flake.lock'
|
|
- 'flakehashes.json'
|
|
- 'config-example.yaml'
|
|
- uses: NixOS/nix-installer-action@62c1943b776c509394b550f3f983adc14e9212d6 # main
|
|
if: steps.changed-files.outputs.files == 'true'
|
|
- uses: Mic92/hestia@dfed9ced335d28978ba74e513939a10db1f71025 # v3.1.0
|
|
if: steps.changed-files.outputs.files == 'true'
|
|
|
|
- name: Check vendor hash
|
|
id: vendorhash
|
|
if: steps.changed-files.outputs.files == 'true'
|
|
run: |
|
|
go run ./cmd/vendorhash check | tee check-result
|
|
{
|
|
grep '^expected_sri=' check-result || true
|
|
grep '^actual_sri=' check-result || true
|
|
} >> "$GITHUB_OUTPUT"
|
|
|
|
- name: Vendor hash diverging
|
|
uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9.0.0
|
|
if: failure() && steps.vendorhash.outcome == 'failure'
|
|
with:
|
|
github-token: ${{secrets.GITHUB_TOKEN}}
|
|
script: |
|
|
github.rest.pulls.createReviewComment({
|
|
pull_number: context.issue.number,
|
|
owner: context.repo.owner,
|
|
repo: context.repo.repo,
|
|
body: 'Vendor hash in `flakehashes.json` is stale (was `${{ steps.vendorhash.outputs.expected_sri }}`, should be `${{ steps.vendorhash.outputs.actual_sri }}`). Run `go run ./cmd/vendorhash update` and commit the result.'
|
|
})
|
|
|
|
- name: Run nix build
|
|
if: steps.changed-files.outputs.files == 'true'
|
|
run: nix build --fallback
|
|
|
|
- uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
|
|
if: steps.changed-files.outputs.files == 'true'
|
|
with:
|
|
name: headscale-linux
|
|
path: result/bin/headscale
|
|
build-cross:
|
|
runs-on: ubuntu-latest
|
|
strategy:
|
|
matrix:
|
|
env:
|
|
- "GOARCH=arm64 GOOS=linux"
|
|
- "GOARCH=amd64 GOOS=linux"
|
|
- "GOARCH=arm64 GOOS=darwin"
|
|
- "GOARCH=amd64 GOOS=darwin"
|
|
steps:
|
|
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
|
|
- uses: NixOS/nix-installer-action@62c1943b776c509394b550f3f983adc14e9212d6 # main
|
|
- uses: Mic92/hestia@dfed9ced335d28978ba74e513939a10db1f71025 # v3.1.0
|
|
|
|
- name: Run go cross compile
|
|
env:
|
|
CGO_ENABLED: 0
|
|
run: env ${{ matrix.env }} go build -o "headscale"
|
|
./cmd/headscale
|
|
- uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
|
|
with:
|
|
name: "headscale-${{ matrix.env }}"
|
|
path: "headscale"
|