Skip to content

Commit a732465

Browse files
authored
Merge branch 'main' into feature/alicloud-kms
Signed-off-by: Peili Qian <115339223+peiliqiancdt@users.noreply.github.com>
2 parents 6ce9146 + 0ae24f4 commit a732465

5 files changed

Lines changed: 247 additions & 27 deletions

File tree

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
name: Custom Release
2+
3+
on:
4+
push:
5+
tags: [ 'v*' ]
6+
workflow_dispatch:
7+
8+
permissions:
9+
contents: write # For creating the GitHub release.
10+
11+
jobs:
12+
release:
13+
runs-on: ubuntu-latest
14+
15+
steps:
16+
- name: Checkout
17+
uses: actions/checkout@v4
18+
with:
19+
fetch-depth: 0
20+
21+
- name: Setup Go
22+
uses: actions/setup-go@v5
23+
with:
24+
go-version: 1.26
25+
26+
- name: Run GoReleaser
27+
uses: goreleaser/goreleaser-action@v6
28+
with:
29+
version: latest
30+
args: release --clean --config .goreleaser-custom.yaml
31+
env:
32+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

.github/workflows/release.yml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
name: Release
22

33
on:
4-
push:
5-
tags: [ 'v*' ]
4+
workflow_dispatch:
5+
# push:
6+
# tags: [ 'v*' ]
67

78
permissions:
89
contents: read

.goreleaser-custom.yaml

Lines changed: 159 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,159 @@
1+
# yaml-language-server: $schema=https://goreleaser.com/static/schema.json
2+
3+
project_name: sops
4+
5+
before:
6+
hooks:
7+
- go mod download
8+
9+
env:
10+
- CGO_ENABLED=0
11+
- PKG=github.com/getsops/sops/v3/version
12+
13+
report_sizes: true
14+
15+
builds:
16+
- id: binary-linux
17+
main: ./cmd/sops
18+
binary: "{{ .ProjectName }}"
19+
flags:
20+
- -trimpath
21+
- -mod=readonly
22+
ldflags:
23+
- >
24+
-s -w
25+
-X "{{ .Env.PKG }}.Version={{ .Version }}"
26+
goos:
27+
- linux
28+
goarch:
29+
- amd64
30+
- arm64
31+
mod_timestamp: "{{ .CommitTimestamp }}"
32+
33+
- id: binary-darwin
34+
main: ./cmd/sops
35+
binary: "{{ .ProjectName }}"
36+
flags:
37+
- -trimpath
38+
- -mod=readonly
39+
ldflags:
40+
- >
41+
-s -w
42+
-X {{ .Env.PKG }}.Version={{ .Version }}
43+
goos:
44+
- darwin
45+
goarch:
46+
- amd64
47+
- arm64
48+
mod_timestamp: "{{ .CommitTimestamp }}"
49+
50+
- id: binary-windows
51+
main: ./cmd/sops
52+
binary: "{{ .ProjectName }}"
53+
flags:
54+
- -trimpath
55+
- -buildmode=pie
56+
- -mod=readonly
57+
ldflags:
58+
- >
59+
-s -w
60+
-X {{ .Env.PKG }}.Version={{ .Version }}
61+
goos:
62+
- windows
63+
goarch:
64+
- amd64
65+
- arm64
66+
mod_timestamp: "{{ .CommitTimestamp }}"
67+
68+
universal_binaries:
69+
- id: binary-darwin-universal
70+
ids:
71+
- binary-darwin
72+
name_template: '{{ .ProjectName }}'
73+
replace: false
74+
mod_timestamp: "{{ .CommitTimestamp }}"
75+
76+
nfpms:
77+
- id: deb
78+
package_name: '{{ .ProjectName }}'
79+
file_name_template: '{{ .ConventionalFileName }}'
80+
vendor: custom-sops
81+
homepage: https://github.com/{{ .Env.GITHUB_REPOSITORY }}
82+
maintainer: custom-sops <custom@example.com>
83+
description: Simple and flexible tool for managing secrets
84+
license: MPL-2.0
85+
formats:
86+
- deb
87+
- rpm
88+
89+
snapshot:
90+
name_template: "{{ incpatch .Version }}-dev-{{ .ShortCommit }}"
91+
92+
archives:
93+
- id: archive-unix
94+
format: binary
95+
builds:
96+
- binary-linux
97+
- binary-darwin
98+
name_template: '{{ .ProjectName }}-v{{ .Version }}.{{ .Os }}.{{ .Arch }}'
99+
100+
- id: archive-windows
101+
format: binary
102+
builds:
103+
- binary-windows
104+
name_template: '{{ .ProjectName }}-v{{ .Version }}.{{ .Arch }}'
105+
106+
- id: archive-darwin-universal
107+
format: binary
108+
builds:
109+
- binary-darwin-universal
110+
name_template: '{{ .ProjectName }}-v{{ .Version }}.darwin'
111+
112+
checksum:
113+
name_template: "{{ .ProjectName }}-v{{ .Version }}.checksums.txt"
114+
algorithm: sha256
115+
ids:
116+
- archive-unix
117+
- archive-windows
118+
- archive-darwin-universal
119+
120+
changelog:
121+
use: github-native
122+
123+
release:
124+
prerelease: auto
125+
draft: false # 自动发布,而不是存为草稿
126+
header: |
127+
## Installation
128+
129+
To install `{{ .ProjectName }}`, download one of the pre-built binaries provided for your platform from the artifacts attached to this release.
130+
131+
For instance, if you are using Linux on an AMD64 architecture:
132+
133+
```shell
134+
# Download the binary
135+
curl -LO https://github.com/{{ .Env.GITHUB_REPOSITORY }}/releases/download/{{ .Tag }}/{{ .ProjectName }}-v{{ .Version }}.linux.amd64
136+
137+
# Move the binary in to your PATH
138+
mv {{ .ProjectName }}-v{{ .Version }}.linux.amd64 /usr/local/bin/{{ .ProjectName }}
139+
140+
# Make the binary executable
141+
chmod +x /usr/local/bin/{{ .ProjectName }}
142+
```
143+
144+
brews:
145+
- name: sops
146+
repository:
147+
owner: peiliqiancdt
148+
name: sops
149+
token: "{{ .Env.GITHUB_TOKEN }}"
150+
directory: Formula
151+
homepage: "https://github.com/peiliqiancdt/sops"
152+
description: "Editor of encrypted files"
153+
license: "MPL-2.0"
154+
ids:
155+
- archive-unix
156+
install: |
157+
bin.install "sops-v#{version}.#{OS.kernel_name.downcase}.#{Hardware::CPU.arch}" => "sops"
158+
test: |
159+
system "#{bin}/sops", "--version"

Formula/sops.rb

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
# typed: false
2+
# frozen_string_literal: true
3+
4+
# This file was generated by GoReleaser. DO NOT EDIT.
5+
class Sops < Formula
6+
desc "Editor of encrypted files"
7+
homepage "https://github.com/peiliqiancdt/sops"
8+
version "3.12.1-acs-0.10"
9+
license "MPL-2.0"
10+
11+
on_macos do
12+
if Hardware::CPU.intel?
13+
url "https://github.com/peiliqiancdt/sops/releases/download/v3.12.1-acs-0.10/sops-v3.12.1-acs-0.10.darwin.amd64"
14+
sha256 "532f6ea17e7a7bba9b6d7daeea77191ef02c4276befeaefa93492067b397281c"
15+
16+
define_method(:install) do
17+
bin.install "sops-v#{version}.#{OS.kernel_name.downcase}.#{Hardware::CPU.arch}" => "sops"
18+
end
19+
end
20+
if Hardware::CPU.arm?
21+
url "https://github.com/peiliqiancdt/sops/releases/download/v3.12.1-acs-0.10/sops-v3.12.1-acs-0.10.darwin.arm64"
22+
sha256 "f6353471f28a4664b0b71dd08d8c3dedb3f78624bdd692a716ac74ed90ee539e"
23+
24+
define_method(:install) do
25+
bin.install "sops-v#{version}.#{OS.kernel_name.downcase}.#{Hardware::CPU.arch}" => "sops"
26+
end
27+
end
28+
end
29+
30+
on_linux do
31+
if Hardware::CPU.intel? && Hardware::CPU.is_64_bit?
32+
url "https://github.com/peiliqiancdt/sops/releases/download/v3.12.1-acs-0.10/sops-v3.12.1-acs-0.10.linux.amd64"
33+
sha256 "6f586bc6ff82813bbb43391ff49ef5255bd4f62ae6165782430862880516b06b"
34+
define_method(:install) do
35+
bin.install "sops-v#{version}.#{OS.kernel_name.downcase}.#{Hardware::CPU.arch}" => "sops"
36+
end
37+
end
38+
if Hardware::CPU.arm? && Hardware::CPU.is_64_bit?
39+
url "https://github.com/peiliqiancdt/sops/releases/download/v3.12.1-acs-0.10/sops-v3.12.1-acs-0.10.linux.arm64"
40+
sha256 "2adbb84a230773f7a4dd5f159252bb0258ef4c632f2c2534fed5655a3fb2466e"
41+
define_method(:install) do
42+
bin.install "sops-v#{version}.#{OS.kernel_name.downcase}.#{Hardware::CPU.arch}" => "sops"
43+
end
44+
end
45+
end
46+
47+
test do
48+
system "#{bin}/sops", "--version"
49+
end
50+
end

version/version.go

Lines changed: 3 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -29,31 +29,9 @@ func PrintVersion(c *cli.Context) {
2929

3030
out.WriteString(fmt.Sprintf("%s %s", c.App.Name, c.App.Version))
3131

32-
if c.Bool("disable-version-check") && !c.Bool("check-for-updates") {
33-
out.WriteString("\n")
34-
} else {
35-
upstreamVersion, upstreamURL, err := RetrieveLatestReleaseVersion()
36-
if err != nil {
37-
out.WriteString(fmt.Sprintf("\n[warning] failed to retrieve latest version from upstream: %v\n", err))
38-
} else {
39-
outdated, err := AIsNewerThanB(upstreamVersion, Version)
40-
if err != nil {
41-
out.WriteString(fmt.Sprintf("\n[warning] failed to compare current version with latest: %v\n", err))
42-
} else {
43-
if outdated {
44-
out.WriteString(fmt.Sprintf("\n[info] a new version of sops (%s) is available, you can update by visiting: %s\n", upstreamVersion, upstreamURL))
45-
} else {
46-
out.WriteString(" (latest)\n")
47-
}
48-
}
49-
}
50-
if !c.Bool("check-for-updates") {
51-
out.WriteString(
52-
"\n[warning] Note that in a future version, sops will no longer check whether the current version is the latest when asking for sops' version." +
53-
" If you want to explicitly check for the latest version, add the `--check-for-updates` option to `sops --version`." +
54-
" This will hide this deprecation warning and will always check, even if the default behavior changes in the future.\n")
55-
}
56-
}
32+
out.WriteString(`
33+
[warning] It's a custom version of sops with AlibabaCloud KMS integration, which is based on sops 3.12.1. If you want to check for the latest official version, please visit "https://github.com/getsops/sops/releases".
34+
`)
5735
fmt.Fprintf(c.App.Writer, "%s", out.String())
5836
}
5937

0 commit comments

Comments
 (0)