version: 2
env:
  - SKIP_PUBLISH={{ if index .Env "SKIP_PUBLISH" }}{{ .Env.SKIP_PUBLISH }}{{ else }}true{{ end }}
  - SKIP_DOCKER_PUSH={{ if index .Env "SKIP_DOCKER_PUSH" }}{{ .Env.SKIP_DOCKER_PUSH }}{{ else }}false{{ end }}
project_name: netbird
builds:
  - id: netbird-wasm
    dir: client/wasm/cmd
    binary: netbird
    env: [GOOS=js, GOARCH=wasm, CGO_ENABLED=0]
    goos:
      - js
    goarch:
      - wasm
    ldflags:
      - -s -w -X github.com/netbirdio/netbird/version.version={{.Version}} -X main.commit={{.Commit}} -X main.date={{.CommitDate}} -X main.builtBy=goreleaser
    mod_timestamp: "{{ .CommitTimestamp }}"

  - id: netbird
    dir: client
    binary: netbird
    env: [CGO_ENABLED=0]
    goos:
      - linux
      - darwin
      - windows
    goarch:
      - arm
      - amd64
      - arm64
      - 386
    ignore:
      - goos: windows
        goarch: arm
      - goos: windows
        goarch: 386
    ldflags:
      - -s -w -X github.com/netbirdio/netbird/version.version={{.Version}} -X main.commit={{.Commit}} -X main.date={{.CommitDate}} -X main.builtBy=goreleaser
    mod_timestamp: "{{ .CommitTimestamp }}"
    tags:
      - load_wgnt_from_rsrc

  - id: netbird-static
    dir: client
    binary: netbird
    env: [CGO_ENABLED=0]
    goos:
      - linux
    goarch:
      - mips
      - mipsle
      - mips64
      - mips64le
    gomips:
      - hardfloat
      - softfloat
    ldflags:
      - -s -w -X github.com/netbirdio/netbird/version.version={{.Version}} -X main.commit={{.Commit}} -X main.date={{.CommitDate}} -X main.builtBy=goreleaser
    mod_timestamp: "{{ .CommitTimestamp }}"
    tags:
      - load_wgnt_from_rsrc

  - id: netbird-mgmt
    dir: management
    env:
      - CGO_ENABLED=1
      - >-
        {{- if eq .Runtime.Goos "linux" }}
          {{- if eq .Arch "arm64"}}CC=aarch64-linux-gnu-gcc{{- end }}
          {{- if eq .Arch "arm"}}CC=arm-linux-gnueabihf-gcc{{- end }}
        {{- end }}
    binary: netbird-mgmt
    goos:
      - linux
    goarch:
      - amd64
      - arm64
      - arm
    goarm:
      - 7
    ldflags:
      - -s -w -X github.com/netbirdio/netbird/version.version={{.Version}} -X main.commit={{.Commit}} -X main.date={{.CommitDate}} -X main.builtBy=goreleaser
    mod_timestamp: "{{ .CommitTimestamp }}"

  - id: netbird-signal
    dir: signal
    env: [CGO_ENABLED=0]
    binary: netbird-signal
    goos:
      - linux
    goarch:
      - amd64
      - arm64
      - arm
    goarm:
      - 7
    ldflags:
      - -s -w -X github.com/netbirdio/netbird/version.version={{.Version}} -X main.commit={{.Commit}} -X main.date={{.CommitDate}} -X main.builtBy=goreleaser
    mod_timestamp: "{{ .CommitTimestamp }}"

  - id: netbird-relay
    dir: relay
    env: [CGO_ENABLED=0]
    binary: netbird-relay
    goos:
      - linux
    goarch:
      - amd64
      - arm64
      - arm
    goarm:
      - 7
    ldflags:
      - -s -w -X github.com/netbirdio/netbird/version.version={{.Version}} -X main.commit={{.Commit}} -X main.date={{.CommitDate}} -X main.builtBy=goreleaser
    mod_timestamp: "{{ .CommitTimestamp }}"

  - id: netbird-server
    dir: combined
    env:
      - CGO_ENABLED=1
      - >-
        {{- if eq .Runtime.Goos "linux" }}
          {{- if eq .Arch "arm64"}}CC=aarch64-linux-gnu-gcc{{- end }}
          {{- if eq .Arch "arm"}}CC=arm-linux-gnueabihf-gcc{{- end }}
        {{- end }}
    binary: netbird-server
    goos:
      - linux
    goarch:
      - amd64
      - arm64
      - arm
    goarm:
      - 7
    ldflags:
      - -s -w -X github.com/netbirdio/netbird/version.version={{.Version}} -X main.commit={{.Commit}} -X main.date={{.CommitDate}} -X main.builtBy=goreleaser
    mod_timestamp: "{{ .CommitTimestamp }}"

  - id: netbird-upload
    dir: upload-server
    env: [CGO_ENABLED=0]
    binary: netbird-upload
    goos:
      - linux
    goarch:
      - amd64
      - arm64
      - arm
    goarm:
      - 7
    ldflags:
      - -s -w -X github.com/netbirdio/netbird/version.version={{.Version}} -X main.commit={{.Commit}} -X main.date={{.CommitDate}} -X main.builtBy=goreleaser
    mod_timestamp: "{{ .CommitTimestamp }}"

  - id: netbird-proxy
    dir: proxy/cmd/proxy
    env: [CGO_ENABLED=0]
    binary: netbird-proxy
    goos:
      - linux
    goarch:
      - amd64
      - arm64
      - arm
    goarm:
      - 7
    ldflags:
      - -s -w -X main.Version={{.Version}} -X main.Commit={{.Commit}} -X main.BuildDate={{.CommitDate}}
    mod_timestamp: "{{ .CommitTimestamp }}"

  - id: netbird-idp-migrate
    dir: tools/idp-migrate
    env:
      - CGO_ENABLED=1
      - >-
        {{- if eq .Runtime.Goos "linux" }}
          {{- if eq .Arch "arm64"}}CC=aarch64-linux-gnu-gcc{{- end }}
          {{- if eq .Arch "arm"}}CC=arm-linux-gnueabihf-gcc{{- end }}
        {{- end }}
    binary: netbird-idp-migrate
    goos:
      - linux
    goarch:
      - amd64
      - arm64
      - arm
    goarm:
      - 7
    ldflags:
      - -s -w -X github.com/netbirdio/netbird/version.version={{.Version}} -X main.commit={{.Commit}} -X main.date={{.CommitDate}} -X main.builtBy=goreleaser
    mod_timestamp: "{{ .CommitTimestamp }}"

universal_binaries:
  - id: netbird

archives:
  - builds:
      - netbird
      - netbird-static
  - id: netbird-wasm
    builds:
      - netbird-wasm
    name_template: "{{ .ProjectName }}_{{ .Version }}"
    format: binary
  - id: netbird-idp-migrate
    builds:
      - netbird-idp-migrate
    name_template: "netbird-idp-migrate_{{ .Version }}_{{ .Os }}_{{ .Arch }}"

nfpms:
  - maintainer: Netbird <dev@netbird.io>
    description: Netbird client.
    homepage: https://netbird.io/
    license: BSD-3-Clause
    id: netbird_deb
    bindir: /usr/bin
    builds:
      - netbird
    formats:
      - deb
    scripts:
      postinstall: "release_files/post_install.sh"
      preremove: "release_files/pre_remove.sh"

  - maintainer: Netbird <dev@netbird.io>
    description: Netbird client.
    homepage: https://netbird.io/
    license: BSD-3-Clause
    id: netbird_rpm
    bindir: /usr/bin
    builds:
      - netbird
    formats:
      - rpm
    scripts:
      postinstall: "release_files/post_install.sh"
      preremove: "release_files/pre_remove.sh"
    rpm:
      signature:
        key_file: '{{ if index .Env "GPG_RPM_KEY_FILE" }}{{ .Env.GPG_RPM_KEY_FILE }}{{ end }}'
dockers_v2:
   - id: netbird
     disable: "{{ .Env.SKIP_DOCKER_PUSH }}"
     ids:
       - netbird
     images:
       - netbirdio/netbird
       - ghcr.io/netbirdio/netbird
     tags:
       - "v{{ .Version }}"
       - "{{ if eq .Env.SKIP_PUBLISH \"false\" }}latest{{ end }}"
     dockerfile: client/Dockerfile
     extra_files:
       - client/netbird-entrypoint.sh
     platforms:
       - linux/amd64
       - linux/arm64
       - linux/arm/6
     annotations:
       "org.opencontainers.image.created": "{{.Date}}"
       "org.opencontainers.image.title": "{{.ProjectName}}"
       "org.opencontainers.image.version": "{{.Version}}"
       "org.opencontainers.image.revision": "{{.FullCommit}}"
       "org.opencontainers.image.source": "{{.GitURL}}"
       "maintainer": "dev@netbird.io"
   - id: netbird-rootless
     disable: "{{ .Env.SKIP_DOCKER_PUSH }}"
     ids:
       - netbird
     images:
       - netbirdio/netbird
       - ghcr.io/netbirdio/netbird
     tags:
       - "v{{ .Version }}-rootless"
       - "{{ if eq .Env.SKIP_PUBLISH \"false\" }}latest{{ end }}"
     dockerfile: client/Dockerfile-rootless
     extra_files:
       - client/netbird-entrypoint.sh
     platforms:
       - linux/amd64
       - linux/arm64
       - linux/arm/6
     annotations:
       "org.opencontainers.image.created": "{{.Date}}"
       "org.opencontainers.image.title": "{{.ProjectName}}"
       "org.opencontainers.image.version": "{{.Version}}"
       "org.opencontainers.image.revision": "{{.FullCommit}}"
       "org.opencontainers.image.source": "{{.GitURL}}"
       "maintainer": "dev@netbird.io"
   - id: relay
     disable: "{{ .Env.SKIP_DOCKER_PUSH }}"
     ids:
       - netbird-relay
     images:
       - netbirdio/relay
       - ghcr.io/netbirdio/relay
     tags:
       - "v{{ .Version }}"
       - "{{ if eq .Env.SKIP_PUBLISH \"false\" }}latest{{ end }}"
     dockerfile: relay/Dockerfile
     platforms:
       - linux/amd64
       - linux/arm64
       - linux/arm
     annotations:
       "org.opencontainers.image.created": "{{.Date}}"
       "org.opencontainers.image.title": "{{.ProjectName}}"
       "org.opencontainers.image.version": "{{.Version}}"
       "org.opencontainers.image.revision": "{{.FullCommit}}"
       "org.opencontainers.image.source": "{{.GitURL}}"
       "maintainer": "dev@netbird.io"
   - id: signal
     disable: "{{ .Env.SKIP_DOCKER_PUSH }}"
     ids:
       - netbird-signal
     images:
       - netbirdio/signal
       - ghcr.io/netbirdio/signal
     tags:
       - "v{{ .Version }}"
       - "{{ if eq .Env.SKIP_PUBLISH \"false\" }}latest{{ end }}"
     dockerfile: signal/Dockerfile
     platforms:
       - linux/amd64
       - linux/arm64
       - linux/arm
     annotations:
       "org.opencontainers.image.created": "{{.Date}}"
       "org.opencontainers.image.title": "{{.ProjectName}}"
       "org.opencontainers.image.version": "{{.Version}}"
       "org.opencontainers.image.revision": "{{.FullCommit}}"
       "org.opencontainers.image.source": "{{.GitURL}}"
       "maintainer": "dev@netbird.io"
   - id: management
     disable: "{{ .Env.SKIP_DOCKER_PUSH }}"
     ids:
       - netbird-mgmt
     images:
       - netbirdio/management
       - ghcr.io/netbirdio/management
     tags:
       - "v{{ .Version }}"
       - "{{ if eq .Env.SKIP_PUBLISH \"false\" }}latest{{ end }}"
     dockerfile: management/Dockerfile
     platforms:
       - linux/amd64
       - linux/arm64
       - linux/arm
     annotations:
       "org.opencontainers.image.created": "{{.Date}}"
       "org.opencontainers.image.title": "{{.ProjectName}}"
       "org.opencontainers.image.version": "{{.Version}}"
       "org.opencontainers.image.revision": "{{.FullCommit}}"
       "org.opencontainers.image.source": "{{.GitURL}}"
       "maintainer": "dev@netbird.io"
   - id: upload
     disable: "{{ .Env.SKIP_DOCKER_PUSH }}"
     ids:
       - netbird-upload
     images:
       - netbirdio/upload
       - ghcr.io/netbirdio/upload
     tags:
       - "v{{ .Version }}"
       - "{{ if eq .Env.SKIP_PUBLISH \"false\" }}latest{{ end }}"
     dockerfile: upload-server/Dockerfile
     platforms:
       - linux/amd64
       - linux/arm64
       - linux/arm
     annotations:
       "org.opencontainers.image.created": "{{.Date}}"
       "org.opencontainers.image.title": "{{.ProjectName}}"
       "org.opencontainers.image.version": "{{.Version}}"
       "org.opencontainers.image.revision": "{{.FullCommit}}"
       "org.opencontainers.image.source": "{{.GitURL}}"
       "maintainer": "dev@netbird.io"
   - id: netbird-server
     disable: "{{ .Env.SKIP_DOCKER_PUSH }}"
     ids:
       - netbird-server
     images:
       - netbirdio/netbird-server
       - ghcr.io/netbirdio/netbird-server
     tags:
       - "v{{ .Version }}"
       - "{{ if eq .Env.SKIP_PUBLISH \"false\" }}latest{{ end }}"
     dockerfile: combined/Dockerfile
     platforms:
       - linux/amd64
       - linux/arm64
       - linux/arm
     annotations:
       "org.opencontainers.image.created": "{{.Date}}"
       "org.opencontainers.image.title": "{{.ProjectName}}"
       "org.opencontainers.image.version": "{{.Version}}"
       "org.opencontainers.image.revision": "{{.FullCommit}}"
       "org.opencontainers.image.source": "{{.GitURL}}"
       "maintainer": "dev@netbird.io"
   - id: netbird-proxy
     disable: "{{ .Env.SKIP_DOCKER_PUSH }}"
     ids:
       - netbird-proxy
     images:
       - netbirdio/reverse-proxy
       - ghcr.io/netbirdio/reverse-proxy
     tags:
       - "v{{ .Version }}"
       - "{{ if eq .Env.SKIP_PUBLISH \"false\" }}latest{{ end }}"
     dockerfile: proxy/Dockerfile
     platforms:
       - linux/amd64
       - linux/arm64
       - linux/arm
     annotations:
       "org.opencontainers.image.created": "{{.Date}}"
       "org.opencontainers.image.title": "{{.ProjectName}}"
       "org.opencontainers.image.version": "{{.Version}}"
       "org.opencontainers.image.revision": "{{.FullCommit}}"
       "org.opencontainers.image.source": "{{.GitURL}}"
       "maintainer": "dev@netbird.io"

brews:
  - ids:
      - default
    skip_upload: "{{ .Env.SKIP_PUBLISH }}"
    repository:
      owner: netbirdio
      name: homebrew-tap
      token: "{{ .Env.HOMEBREW_TAP_GITHUB_TOKEN }}"
    commit_author:
      name: Netbird
      email: dev@netbird.io
    description: Netbird project.
    download_strategy: CurlDownloadStrategy
    homepage: https://netbird.io/
    license: "BSD3"
    test: |
      system "#{bin}/{{ .ProjectName	}} version"

uploads:
  - name: debian
    skip: "{{ .Env.SKIP_PUBLISH }}"
    ids:
      - netbird_deb
    mode: archive
    target: https://pkgs.wiretrustee.com/debian/pool/{{ .ArtifactName }};deb.distribution=stable;deb.component=main;deb.architecture={{ if .Arm }}armhf{{ else }}{{ .Arch }}{{ end }};deb.package=
    username: dev@wiretrustee.com
    method: PUT

  - name: yum
    skip: "{{ .Env.SKIP_PUBLISH }}"
    ids:
      - netbird_rpm
    mode: archive
    target: https://pkgs.wiretrustee.com/yum/{{ .Arch }}{{ if .Arm }}{{ .Arm }}{{ end }}
    username: dev@wiretrustee.com
    method: PUT

checksum:
  extra_files:
    - glob: ./infrastructure_files/getting-started-with-zitadel.sh
    - glob: ./release_files/install.sh
    - glob: ./infrastructure_files/getting-started.sh

release:
  extra_files:
    - glob: ./infrastructure_files/getting-started-with-zitadel.sh
    - glob: ./release_files/install.sh
    - glob: ./infrastructure_files/getting-started.sh
