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

Commit

Permalink
chore: workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
iwilltry42 committed Aug 6, 2024
1 parent 70a8cae commit 1a71abf
Show file tree
Hide file tree
Showing 3 changed files with 63 additions and 17 deletions.
68 changes: 62 additions & 6 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
name: Release

on:
workflow_dispatch:
push:
tags:
- "v*"
Expand All @@ -9,14 +10,13 @@ env:
GO_VERSION: "1.22.x"

jobs:
release-github:
name: Build & Release Binaries
build:
name: Build Binaries
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ ubuntu-22.04, macos-latest ]
steps:
# Setup
- uses: actions/checkout@v4
- name: Setup Go environment
uses: actions/setup-go@v5
Expand All @@ -33,10 +33,65 @@ jobs:
echo 'eval "$(/opt/homebrew/bin/brew shellenv)"' >> ~/.zprofile
eval "$(/opt/homebrew/bin/brew shellenv)"
brew install mingw-w64
# Go Build
- name: Build Binary
run: make build-cross
# Create Git Release
- name: Upload Artifacts
uses: actions/upload-artifact@v4
with:
name: ${{ matrix.os }}-artifacts
path: dist/*
retention-days: 1
if-no-files-found: error

collect-artifacts:
name: Collect Artifacts and Generate Checksums
runs-on: ubuntu-22.04
needs: build
steps:
- name: Download Artifacts
uses: actions/download-artifact@v4
with:
name: ubuntu-22.04-artifacts
path: dist
merge-multiple: true
- name: Download Artifacts
uses: actions/download-artifact@v4
with:
name: macos-latest-artifacts
path: dist
merge-multiple: true
- name: Calculate Checksums
run: |
cd dist
sha256sum knowledge-* > checksums.txt
- name: Upload Checksums
uses: actions/upload-artifact@v4
with:
name: checksums
path: dist/checksums.txt

release:
name: Create Release
runs-on: ubuntu-22.04
needs: collect-artifacts
steps:
- name: Download Artifacts
uses: actions/download-artifact@v4
with:
name: ubuntu-22.04-artifacts
path: dist
merge-multiple: true
- name: Download Artifacts
uses: actions/download-artifact@v4
with:
name: macos-latest-artifacts
path: dist
- name: Download Checksums
uses: actions/download-artifact@v4
with:
name: checksums
path: dist
merge-multiple: true
- name: Extract Tag from Ref
if: startsWith(github.ref, 'refs/tags/')
id: tag
Expand All @@ -53,7 +108,8 @@ jobs:
with:
allowUpdates: true
artifactErrorsFailBuild: true
artifacts: dist/*
artifacts: |
dist/*
makeLatest: ${{ steps.semver.outputs.prerelease == '' }}
generateReleaseNotes: true
prerelease: ${{ steps.semver.outputs.prerelease != '' }}
Expand Down
3 changes: 1 addition & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -69,5 +69,4 @@ validate-docs:
;fi

gen-checksum:
$(eval ARTIFACTS_TO_PUBLISH := $(shell ls dist/*))
$$(sha256sum $(ARTIFACTS_TO_PUBLISH) > dist/checksums.txt)
$$(cd dist && sha256sum knowledge-* > checksums.txt)
9 changes: 0 additions & 9 deletions scripts/cross-build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,9 @@ LD_FLAGS="-s -w -X github.com/gptscript-ai/knowledge/version.Version=${GIT_TAG}"

export CGO_ENABLED=1

mkdir -p dist/
touch dist/checksums.txt

if [ "$(go env GOOS)" = "linux" ]; then
# Linux: amd64, arm64
GOARCH=amd64 go build -o dist/knowledge-linux-amd64 -tags "${GO_TAGS}" -ldflags "${LD_FLAGS}\" -extldflags \"-static\" " .

# Checksum
sha256sum dist/knowledge-linux-amd64 >> dist/checksums.txt
else

# Windows: amd64
Expand All @@ -23,7 +17,4 @@ else
# Darwin: amd64, arm64
GOARCH=amd64 go build -o dist/knowledge-darwin-amd64 -tags "${GO_TAGS}" -ldflags "${LD_FLAGS}" .
GOARCH=arm64 go build -o dist/knowledge-darwin-arm64 -tags "${GO_TAGS}" -ldflags "${LD_FLAGS}" .

# Checksum
shasum -a 256 dist/knowledge-windows-amd64 dist/knowledge-darwin-amd64 dist/knowledge-darwin-arm64 >> dist/checksums.txt
fi

0 comments on commit 1a71abf

Please sign in to comment.