diff --git a/.github/workflows/linux.yml b/.github/workflows/linux.yml new file mode 100644 index 00000000..f48992c3 --- /dev/null +++ b/.github/workflows/linux.yml @@ -0,0 +1,28 @@ +name: Release to Linux repository + +on: + release: + types: + - published + +jobs: + build: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4 + with: + fetch-depth: 0 + - name: Setup Go + uses: actions/setup-go@v5 + with: + go-version: ^1.22 + - name: Publish release + uses: goreleaser/goreleaser-action@v5 + with: + distribution: goreleaser-pro + version: latest + args: goreleaser release -f .goreleaser.fury.yaml --clean + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + GORELEASER_KEY: ${{ secrets.GORELEASER_KEY }} diff --git a/.goreleaser.fury.yaml b/.goreleaser.fury.yaml new file mode 100644 index 00000000..7150cc78 --- /dev/null +++ b/.goreleaser.fury.yaml @@ -0,0 +1,80 @@ +project_name: sing-box +builds: + - id: main + main: ./cmd/sing-box + flags: + - -v + - -trimpath + ldflags: + - -X github.com/sagernet/sing-box/constant.Version={{ .Version }} -s -w -buildid= + tags: + - with_gvisor + - with_quic + - with_dhcp + - with_wireguard + - with_ech + - with_utls + - with_reality_server + - with_acme + - with_clash_api + env: + - CGO_ENABLED=0 + targets: + - linux_386 + - linux_amd64_v1 + - linux_arm64 + - linux_arm_7 + - linux_s390x + - linux_riscv64 + mod_timestamp: '{{ .CommitTimestamp }}' +snapshot: + name_template: "{{ .Version }}.{{ .ShortCommit }}" +nfpms: + - &template + id: package + package_name: sing-box + file_name_template: '{{ .ProjectName }}_{{ .Version }}_{{ .Os }}_{{ .Arch }}{{ with .Arm }}v{{ . }}{{ end }}{{ with .Mips }}_{{ . }}{{ end }}{{ if not (eq .Amd64 "v1") }}{{ .Amd64 }}{{ end }}' + builds: + - main + vendor: sagernet + homepage: https://sing-box.sagernet.org/ + maintainer: nekohasekai + description: The universal proxy platform. + license: GPLv3 or later + formats: + - deb + - rpm + priority: extra + contents: + - src: release/config/config.json + dst: /etc/sing-box/config.json + type: config + - src: release/config/sing-box.service + dst: /etc/systemd/system/sing-box.service + - src: release/config/sing-box@.service + dst: /etc/systemd/system/sing-box@.service + - src: LICENSE + dst: /usr/share/licenses/sing-box/LICENSE + conflicts: + - sing-box-beta + - id: package_beta + <<: *template + package_name: sing-box-beta + formats: + - deb + - rpm + conflicts: + - sing-box +release: + disable: true +furies: + - account: sagernet + ids: + - package + skip: |- + {{ eq .Prerelease "" }} + - account: sagernet + ids: + - package_beta + skip: |- + {{ ne .Prerelease "" }} diff --git a/.goreleaser.yaml b/.goreleaser.yaml index 558ec92c..7247b623 100644 --- a/.goreleaser.yaml +++ b/.goreleaser.yaml @@ -1,6 +1,7 @@ project_name: sing-box builds: - - id: main + - &template + id: main main: ./cmd/sing-box flags: - -v @@ -32,16 +33,10 @@ builds: - windows_386 - windows_arm64 - darwin_amd64_v1 - - darwin_amd64_v3 - darwin_arm64 mod_timestamp: '{{ .CommitTimestamp }}' - id: legacy - main: ./cmd/sing-box - flags: - - -v - - -trimpath - ldflags: - - -X github.com/sagernet/sing-box/constant.Version={{ .Version }} -s -w -buildid= + <<: *template tags: - with_gvisor - with_quic @@ -59,24 +54,8 @@ builds: - windows_amd64_v1 - windows_386 - darwin_amd64_v1 - mod_timestamp: '{{ .CommitTimestamp }}' - id: android - main: ./cmd/sing-box - flags: - - -v - - -trimpath - ldflags: - - -X github.com/sagernet/sing-box/constant.Version={{ .Version }} -s -w -buildid= - tags: - - with_gvisor - - with_quic - - with_dhcp - - with_wireguard - - with_ech - - with_utls - - with_reality_server - - with_acme - - with_clash_api + <<: *template env: - CGO_ENABLED=1 overrides: @@ -107,11 +86,11 @@ builds: - android_arm64 - android_386 - android_amd64 - mod_timestamp: '{{ .CommitTimestamp }}' snapshot: name_template: "{{ .Version }}.{{ .ShortCommit }}" archives: - - id: archive + - &template + id: archive builds: - main - android @@ -124,20 +103,16 @@ archives: - LICENSE name_template: '{{ .ProjectName }}-{{ .Version }}-{{ .Os }}-{{ .Arch }}{{ with .Arm }}v{{ . }}{{ end }}{{ with .Mips }}_{{ . }}{{ end }}{{ if not (eq .Amd64 "v1") }}{{ .Amd64 }}{{ end }}' - id: archive-legacy + <<: *template builds: - legacy - format: tar.gz - format_overrides: - - goos: windows - format: zip - wrap_in_directory: true - files: - - LICENSE name_template: '{{ .ProjectName }}-{{ .Version }}-{{ .Os }}-{{ .Arch }}-legacy' nfpms: - id: package package_name: sing-box file_name_template: '{{ .ProjectName }}_{{ .Version }}_{{ .Os }}_{{ .Arch }}{{ with .Arm }}v{{ . }}{{ end }}{{ with .Mips }}_{{ . }}{{ end }}{{ if not (eq .Amd64 "v1") }}{{ .Amd64 }}{{ end }}' + builds: + - main vendor: sagernet homepage: https://sing-box.sagernet.org/ maintainer: nekohasekai @@ -158,6 +133,20 @@ nfpms: dst: /etc/systemd/system/sing-box@.service - src: LICENSE dst: /usr/share/licenses/sing-box/LICENSE + deb: + signature: + key_file: "{{ .Env.NFPM_KEY_PATH }}" + rpm: + signature: + key_file: "{{ .Env.NFPM_KEY_PATH }}" + overrides: + deb: + conflicts: + - sing-box-beta + rpm: + conflicts: + - sing-box-beta + source: enabled: false name_template: '{{ .ProjectName }}-{{ .Version }}.source' @@ -171,6 +160,10 @@ release: github: owner: SagerNet name: sing-box - name_template: '{{ if .IsSnapshot }}{{ nightly }}{{ else }}{{ .Version }}{{ end }}' draft: true - mode: replace \ No newline at end of file + prerelease: auto + mode: replace + ids: + - archive + - package + skip_upload: true \ No newline at end of file diff --git a/Makefile b/Makefile index 104c232f..887bf013 100644 --- a/Makefile +++ b/Makefile @@ -64,7 +64,7 @@ proto_install: go install -v google.golang.org/grpc/cmd/protoc-gen-go-grpc@latest release: - go run ./cmd/internal/build goreleaser release --clean --skip-publish || exit 1 + go run ./cmd/internal/build goreleaser release --clean --skip publish --skip fury mkdir dist/release mv dist/*.tar.gz \ dist/*.zip \ @@ -77,6 +77,9 @@ release: ghr --replace --draft --prerelease -p 3 "v${VERSION}" dist/release rm -r dist/release +release_repo: + go run ./cmd/internal/build goreleaser release -f .goreleaser.fury.yaml --clean + release_install: go install -v github.com/goreleaser/goreleaser@latest go install -v github.com/tcnksm/ghr@latest diff --git a/docs/installation/package-manager.md b/docs/installation/package-manager.md index c605ffb0..8e6a5899 100644 --- a/docs/installation/package-manager.md +++ b/docs/installation/package-manager.md @@ -4,6 +4,35 @@ icon: material/package # Package Manager +## :material-tram: Repository Installation + +=== ":material-debian: Debian / APT" + + ```bash + sudo curl -fsSL https://deb.sagernet.org/gpg.key -o /etc/apt/keyrings/sagernet.asc + sudo chmod a+r /etc/apt/keyrings/sagernet.asc + echo "deb [arch=`dpkg --print-architecture` signed-by=/etc/apt/keyrings/sagernet.asc] https://deb.sagernet.org/ * *" | \ + sudo tee /etc/apt/sources.list.d/sagernet.list > /dev/null + sudo apt-get update + sudo apt-get install sing-box # or sing-box-beta + ``` + +=== ":material-redhat: Redhat / DNF" + + ```bash + sudo dnf -y install dnf-plugins-core + sudo dnf config-manager --add-repo https://sing-box.app/rpm.repo + sudo dnf install sing-box # or sing-box-beta + ``` + +=== ":material-redhat: CentOS / YUM" + + ```bash + sudo yum install -y yum-utils + sudo yum-config-manager --add-repo https://sing-box.app/rpm.repo + sudo yum install sing-box # or sing-box-beta + ``` + ## :material-download-box: Manual Installation === ":material-debian: Debian / DEB" diff --git a/docs/installation/package-manager.zh.md b/docs/installation/package-manager.zh.md index e3c40630..4eb522a1 100644 --- a/docs/installation/package-manager.zh.md +++ b/docs/installation/package-manager.zh.md @@ -4,6 +4,35 @@ icon: material/package # 包管理器 +## :material-tram: 仓库安装 + +=== ":material-debian: Debian / APT" + + ```bash + sudo curl -fsSL https://deb.sagernet.org/gpg.key -o /etc/apt/keyrings/sagernet.asc + sudo chmod a+r /etc/apt/keyrings/sagernet.asc + echo "deb [arch=`dpkg --print-architecture` signed-by=/etc/apt/keyrings/sagernet.asc] https://deb.sagernet.org/ * *" | \ + sudo tee /etc/apt/sources.list.d/sagernet.list > /dev/null + sudo apt-get update + sudo apt-get install sing-box # or sing-box-beta + ``` + +=== ":material-redhat: Redhat / DNF" + + ```bash + sudo dnf -y install dnf-plugins-core + sudo dnf config-manager --add-repo https://sing-box.app/rpm.repo + sudo dnf install sing-box # or sing-box-beta + ``` + +=== ":material-redhat: CentOS / YUM" + + ```bash + sudo yum install -y yum-utils + sudo yum-config-manager --add-repo https://sing-box.app/rpm.repo + sudo yum install sing-box # or sing-box-beta + ``` + ## :material-download-box: 手动安装 === ":material-debian: Debian / DEB" diff --git a/docs/installation/scripts/arch-install.sh b/docs/installation/tools/arch-install.sh similarity index 100% rename from docs/installation/scripts/arch-install.sh rename to docs/installation/tools/arch-install.sh diff --git a/docs/installation/scripts/deb-install.sh b/docs/installation/tools/deb-install.sh similarity index 100% rename from docs/installation/scripts/deb-install.sh rename to docs/installation/tools/deb-install.sh diff --git a/docs/installation/scripts/rpm-install.sh b/docs/installation/tools/rpm-install.sh similarity index 100% rename from docs/installation/scripts/rpm-install.sh rename to docs/installation/tools/rpm-install.sh diff --git a/docs/installation/tools/rpm.repo b/docs/installation/tools/rpm.repo new file mode 100644 index 00000000..a2d0c86c --- /dev/null +++ b/docs/installation/tools/rpm.repo @@ -0,0 +1,6 @@ +[sing-box] +name=sing-box +baseurl=https://rpm.sagernet.org/ +enabled=1 +gpgcheck=1 +gpgkey=https://deb.sagernet.org/gpg.key