Skip to content
This repository was archived by the owner on Oct 30, 2024. It is now read-only.

Commit e1e0b39

Browse files
committed
chore: workflow
1 parent 70a8cae commit e1e0b39

File tree

3 files changed

+64
-18
lines changed

3 files changed

+64
-18
lines changed

.github/workflows/main.yml

+62-6
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
name: Release
22

33
on:
4+
workflow_dispatch:
45
push:
56
tags:
67
- "v*"
@@ -9,14 +10,13 @@ env:
910
GO_VERSION: "1.22.x"
1011

1112
jobs:
12-
release-github:
13-
name: Build & Release Binaries
13+
build:
14+
name: Build Binaries
1415
runs-on: ${{ matrix.os }}
1516
strategy:
1617
matrix:
1718
os: [ ubuntu-22.04, macos-latest ]
1819
steps:
19-
# Setup
2020
- uses: actions/checkout@v4
2121
- name: Setup Go environment
2222
uses: actions/setup-go@v5
@@ -33,10 +33,65 @@ jobs:
3333
echo 'eval "$(/opt/homebrew/bin/brew shellenv)"' >> ~/.zprofile
3434
eval "$(/opt/homebrew/bin/brew shellenv)"
3535
brew install mingw-w64
36-
# Go Build
3736
- name: Build Binary
3837
run: make build-cross
39-
# Create Git Release
38+
- name: Upload Artifacts
39+
uses: actions/upload-artifact@v4
40+
with:
41+
name: ${{ matrix.os }}-artifacts
42+
path: dist/*
43+
retention-days: 1
44+
if-no-files-found: error
45+
46+
collect-artifacts:
47+
name: Collect Artifacts and Generate Checksums
48+
runs-on: ubuntu-22.04
49+
needs: build
50+
steps:
51+
- name: Download Artifacts
52+
uses: actions/download-artifact@v4
53+
with:
54+
name: ubuntu-22.04-artifacts
55+
path: dist
56+
merge-multiple: true
57+
- name: Download Artifacts
58+
uses: actions/download-artifact@v4
59+
with:
60+
name: macos-latest-artifacts
61+
path: dist
62+
merge-multiple: true
63+
- name: Calculate Checksums
64+
run: |
65+
cd dist
66+
sha256sum knowledge-* > checksums.txt
67+
- name: Upload Checksums
68+
uses: actions/upload-artifact@v4
69+
with:
70+
name: checksums
71+
path: dist/checksums.txt
72+
73+
release:
74+
name: Create Release
75+
runs-on: ubuntu-22.04
76+
needs: collect-artifacts
77+
steps:
78+
- name: Download Artifacts
79+
uses: actions/download-artifact@v4
80+
with:
81+
name: ubuntu-22.04-artifacts
82+
path: dist
83+
merge-multiple: true
84+
- name: Download Artifacts
85+
uses: actions/download-artifact@v4
86+
with:
87+
name: macos-latest-artifacts
88+
path: dist
89+
- name: Download Checksums
90+
uses: actions/download-artifact@v4
91+
with:
92+
name: checksums
93+
path: dist
94+
merge-multiple: true
4095
- name: Extract Tag from Ref
4196
if: startsWith(github.ref, 'refs/tags/')
4297
id: tag
@@ -53,7 +108,8 @@ jobs:
53108
with:
54109
allowUpdates: true
55110
artifactErrorsFailBuild: true
56-
artifacts: dist/*
111+
artifacts: |
112+
dist/*
57113
makeLatest: ${{ steps.semver.outputs.prerelease == '' }}
58114
generateReleaseNotes: true
59115
prerelease: ${{ steps.semver.outputs.prerelease != '' }}

Makefile

+1-2
Original file line numberDiff line numberDiff line change
@@ -69,5 +69,4 @@ validate-docs:
6969
;fi
7070

7171
gen-checksum:
72-
$(eval ARTIFACTS_TO_PUBLISH := $(shell ls dist/*))
73-
$$(sha256sum $(ARTIFACTS_TO_PUBLISH) > dist/checksums.txt)
72+
$$(cd dist && sha256sum knowledge-* > checksums.txt)

scripts/cross-build.sh

+1-10
Original file line numberDiff line numberDiff line change
@@ -6,24 +6,15 @@ LD_FLAGS="-s -w -X github.com/gptscript-ai/knowledge/version.Version=${GIT_TAG}"
66

77
export CGO_ENABLED=1
88

9-
mkdir -p dist/
10-
touch dist/checksums.txt
11-
129
if [ "$(go env GOOS)" = "linux" ]; then
1310
# Linux: amd64, arm64
1411
GOARCH=amd64 go build -o dist/knowledge-linux-amd64 -tags "${GO_TAGS}" -ldflags "${LD_FLAGS}\" -extldflags \"-static\" " .
15-
16-
# Checksum
17-
sha256sum dist/knowledge-linux-amd64 >> dist/checksums.txt
1812
else
1913

2014
# Windows: amd64
21-
CC=x86_64-w64-mingw32-gcc GOOS=windows GOARCH=amd64 go build -o dist/knowledge-windows-amd64 -tags "${GO_TAGS}" -ldflags "${LD_FLAGS}" .
15+
CC=x86_64-w64-mingw32-gcc GOOS=windows GOARCH=amd64 go build -o dist/knowledge-windows-amd64.exe -tags "${GO_TAGS}" -ldflags "${LD_FLAGS}" .
2216

2317
# Darwin: amd64, arm64
2418
GOARCH=amd64 go build -o dist/knowledge-darwin-amd64 -tags "${GO_TAGS}" -ldflags "${LD_FLAGS}" .
2519
GOARCH=arm64 go build -o dist/knowledge-darwin-arm64 -tags "${GO_TAGS}" -ldflags "${LD_FLAGS}" .
26-
27-
# Checksum
28-
shasum -a 256 dist/knowledge-windows-amd64 dist/knowledge-darwin-amd64 dist/knowledge-darwin-arm64 >> dist/checksums.txt
2920
fi

0 commit comments

Comments
 (0)