version: 2
project_name: sing-box
builds:
  - &template
    id: main
    main: ./cmd/sing-box
    flags:
      - -v
      - -trimpath
    ldflags:
      - -X github.com/sagernet/sing-box/constant.Version={{ .Version }}
      - -s
      - -buildid=
    tags:
      - with_gvisor
      - with_quic
      - with_dhcp
      - with_wireguard
      - with_utls
      - with_acme
      - with_clash_api
      - with_tailscale
    env:
      - CGO_ENABLED=0
      - GOTOOLCHAIN=local
    targets:
      - linux_386
      - linux_amd64_v1
      - linux_arm64
      - linux_arm_6
      - linux_arm_7
      - linux_s390x
      - linux_riscv64
      - linux_mips
      - linux_mips_softfloat
      - linux_mipsle
      - linux_mipsle_softfloat
      - linux_mips64
      - linux_mips64le
      - windows_amd64_v1
      - windows_386
      - windows_arm64
      - darwin_amd64_v1
      - darwin_arm64
    mod_timestamp: '{{ .CommitTimestamp }}'
  - id: manager
    main: ./cmd/sing-box
    flags:
      - -v
      - -trimpath
    ldflags:
      - -X github.com/sagernet/sing-box/constant.Version={{ .Version }}
      - -s
      - -buildid=
    tags:
      - with_gvisor
      - with_quic
      - with_dhcp
      - with_wireguard
      - with_utls
      - with_acme
      - with_clash_api
      - with_tailscale
      - with_manager
      - with_admin_panel
    env:
      - CGO_ENABLED=0
      - GOTOOLCHAIN=local
    targets:
      - linux_386
      - linux_amd64_v1
      - linux_arm64
      - linux_arm_6
      - linux_arm_7
      - linux_s390x
      - linux_riscv64
      - linux_mips
      - linux_mips_softfloat
      - linux_mipsle
      - linux_mipsle_softfloat
      - linux_mips64
      - linux_mips64le
      - windows_amd64_v1
      - windows_386
      - windows_arm64
      - darwin_amd64_v1
      - darwin_arm64
    mod_timestamp: '{{ .CommitTimestamp }}'
  - id: legacy
    <<: *template
    tags:
      - with_gvisor
      - with_quic
      - with_dhcp
      - with_wireguard
      - with_utls
      - with_acme
      - with_clash_api
      - with_tailscale
    env:
      - CGO_ENABLED=0
    targets:
      - windows_amd64_v1
      - windows_386
  - id: android
    <<: *template
    env:
      - CGO_ENABLED=1
      - GOTOOLCHAIN=local
    overrides:
      - goos: android
        goarch: arm
        goarm: 7
        env:
          - CC=armv7a-linux-androideabi21-clang
          - CXX=armv7a-linux-androideabi21-clang++
      - goos: android
        goarch: arm64
        env:
          - CC=aarch64-linux-android21-clang
          - CXX=aarch64-linux-android21-clang++
      - goos: android
        goarch: 386
        env:
          - CC=i686-linux-android21-clang
          - CXX=i686-linux-android21-clang++
      - goos: android
        goarch: amd64
        goamd64: v1
        env:
          - CC=x86_64-linux-android21-clang
          - CXX=x86_64-linux-android21-clang++
    targets:
      - android_arm_7
      - android_arm64
      - android_386
      - android_amd64
archives:
  - &template
    id: archive
    builds:
      - main
      - android
    formats:
      - tar.gz
    format_overrides:
      - goos: windows
        formats:
          - zip
    wrap_in_directory: true
    files:
      - LICENSE
    name_template: '{{ .ProjectName }}-{{ .Version }}-{{ .Os }}-{{ .Arch }}{{ with .Arm }}v{{ . }}{{ end }}{{ if and .Mips (not (eq .Mips "hardfloat")) }}-{{ .Mips }}{{ end }}{{ if not (eq .Amd64 "v1") }}{{ .Amd64 }}{{ end }}'
  - id: archive_with_manager
    builds:
      - manager
    formats:
      - tar.gz
    format_overrides:
      - goos: windows
        formats:
          - zip
    wrap_in_directory: true
    files:
      - LICENSE
    name_template: '{{ .ProjectName }}-{{ .Version }}-with-manager-{{ .Os }}-{{ .Arch }}{{ with .Arm }}v{{ . }}{{ end }}{{ if and .Mips (not (eq .Mips "hardfloat")) }}-{{ .Mips }}{{ end }}{{ if not (eq .Amd64 "v1") }}{{ .Amd64 }}{{ end }}'
  - id: archive-legacy
    <<: *template
    builds:
      - legacy
    name_template: '{{ .ProjectName }}-{{ .Version }}-{{ .Os }}-{{ .Arch }}-legacy'
source:
  enabled: false
  name_template: '{{ .ProjectName }}-{{ .Version }}.source'
  prefix_template: '{{ .ProjectName }}-{{ .Version }}/'
checksum:
  disable: true
  name_template: '{{ .ProjectName }}-{{ .Version }}.checksum'
signs:
  - artifacts: checksum
release:
  github:
    owner: shtorm-7
    name: sing-box-extended
  draft: true
  prerelease: auto
  mode: replace
  ids:
    - archive
    - package
  skip_upload: true
