@@ -124,33 +124,6 @@ jobs:
124124 if : startsWith(github.ref, 'refs/tags/v')
125125 permissions :
126126 contents : write
127- strategy :
128- fail-fast : false
129- matrix :
130- include :
131- # Linux
132- - os : ubuntu-latest
133- goos : linux
134- goarch : amd64
135- ext : ' '
136- - os : ubuntu-latest
137- goos : linux
138- goarch : arm64
139- ext : ' '
140- # Windows
141- - os : windows-latest
142- goos : windows
143- goarch : amd64
144- ext : .exe
145- # macOS
146- - os : macos-latest
147- goos : darwin
148- goarch : amd64
149- ext : ' '
150- - os : macos-latest
151- goos : darwin
152- goarch : arm64
153- ext : ' '
154127 steps :
155128 - name : Checkout code
156129 uses : actions/checkout@v4
@@ -164,41 +137,73 @@ jobs:
164137 working-directory : oho
165138 run : go mod download
166139
167- - name : Build Release
140+ - name : Build Linux amd64
168141 working-directory : oho
169142 env :
170- GOOS : ${{ matrix.goos }}
171- GOARCH : ${{ matrix.goarch }}
143+ GOOS : linux
144+ GOARCH : amd64
145+ run : |
146+ mkdir -p dist
147+ go build -ldflags="-s -w -X main.Version=${GITHUB_REF#refs/tags/}" -o "dist/${{ env.APP_NAME }}-linux-amd64" ./cmd
148+ cd dist && sha256sum ${{ env.APP_NAME }}-linux-amd64 > ${{ env.APP_NAME }}-linux-amd64.sha256
149+
150+ - name : Build Linux arm64
151+ working-directory : oho
152+ env :
153+ GOOS : linux
154+ GOARCH : arm64
155+ run : |
156+ mkdir -p dist
157+ go build -ldflags="-s -w -X main.Version=${GITHUB_REF#refs/tags/}" -o "dist/${{ env.APP_NAME }}-linux-arm64" ./cmd
158+ cd dist && sha256sum ${{ env.APP_NAME }}-linux-arm64 > ${{ env.APP_NAME }}-linux-arm64.sha256
159+
160+ - name : Build Windows amd64
161+ working-directory : oho
162+ env :
163+ GOOS : windows
164+ GOARCH : amd64
172165 run : |
173166 mkdir -p dist
174- OUTPUT_NAME="${{ env.APP_NAME }}-${{ matrix.goos }}-${{ matrix.goarch }} ${{ matrix.ext }}"
175- go build -ldflags="-s -w -X main.Version=${GITHUB_REF#refs/tags/ }" -o "dist/${OUTPUT_NAME}" ./cmd
167+ go build -ldflags="-s -w -X main.Version=${GITHUB_REF#refs/tags/}" -o "dist/ ${{ env.APP_NAME }}-windows-amd64.exe" ./cmd
168+ cd dist && powershell -Command "Get-FileHash -Path ${{ env.APP_NAME }}-windows-amd64.exe -Algorithm SHA256 | ForEach-Object { `$_.Hash + ' ' + `$_.Path }" > ${{ env.APP_NAME }}-windows-amd64.exe.sha256
176169
177- - name : Create checksums (Windows)
178- if : matrix.goos == 'windows'
179- working-directory : oho/dist
180- shell : pwsh
170+ - name : Build macOS amd64
171+ working-directory : oho
172+ env :
173+ GOOS : darwin
174+ GOARCH : amd64
181175 run : |
182- Get-ChildItem ${{ env.APP_NAME }}-${{ matrix.goos }}-${{ matrix.goarch }}${{ matrix.ext }} | ForEach-Object {
183- $hash = (Get-FileHash -Path $_.FullName -Algorithm SHA256).Hash
184- "$hash $($_.Name)" | Out-File -FilePath "$($_.Name).sha256" -Encoding ASCII -NoNewline
185- }
176+ mkdir -p dist
177+ go build -ldflags="-s -w -X main.Version=${GITHUB_REF#refs/tags/}" -o "dist/${{ env.APP_NAME }}-darwin-amd64" ./cmd
178+ cd dist && sha256sum ${{ env.APP_NAME }}-darwin-amd64 > ${{ env.APP_NAME }}-darwin-amd64.sha256
186179
187- - name : Create checksums (Unix)
188- if : matrix.goos != 'windows'
189- working-directory : oho/dist
190- run : sha256sum ${{ env.APP_NAME }}-${{ matrix.goos }}-${{ matrix.goarch }}${{ matrix.ext }} > ${{ env.APP_NAME }}-${{ matrix.goos }}-${{ matrix.goarch }}${{ matrix.ext }}.sha256
180+ - name : Build macOS arm64
181+ working-directory : oho
182+ env :
183+ GOOS : darwin
184+ GOARCH : arm64
185+ run : |
186+ mkdir -p dist
187+ go build -ldflags="-s -w -X main.Version=${GITHUB_REF#refs/tags/}" -o "dist/${{ env.APP_NAME }}-darwin-arm64" ./cmd
188+ cd dist && sha256sum ${{ env.APP_NAME }}-darwin-arm64 > ${{ env.APP_NAME }}-darwin-arm64.sha256
191189
192- - name : Upload Release Asset
190+ - name : Upload Release Assets
193191 uses : softprops/action-gh-release@v2
194192 with :
195193 tag_name : ${{ github.ref_name }}
196194 files : |
197- oho/dist/${{ env.APP_NAME }}-${{ matrix.goos }}-${{ matrix.goarch }}${{ matrix.ext }}
198- oho/dist/${{ env.APP_NAME }}-${{ matrix.goos }}-${{ matrix.goarch }}${{ matrix.ext }}.sha256
195+ oho/dist/${{ env.APP_NAME }}-linux-amd64
196+ oho/dist/${{ env.APP_NAME }}-linux-amd64.sha256
197+ oho/dist/${{ env.APP_NAME }}-linux-arm64
198+ oho/dist/${{ env.APP_NAME }}-linux-arm64.sha256
199+ oho/dist/${{ env.APP_NAME }}-windows-amd64.exe
200+ oho/dist/${{ env.APP_NAME }}-windows-amd64.exe.sha256
201+ oho/dist/${{ env.APP_NAME }}-darwin-amd64
202+ oho/dist/${{ env.APP_NAME }}-darwin-amd64.sha256
203+ oho/dist/${{ env.APP_NAME }}-darwin-arm64
204+ oho/dist/${{ env.APP_NAME }}-darwin-arm64.sha256
199205 env :
200206 GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
201-
202207 # ===========================================
203208 # Job 5: 通知 (发布成功后)
204209 # ===========================================
0 commit comments