add release binary builds and dl.hanzo.space worker

- publish.yml: push to both ghcr.io/hanzoai/s3 and ghcr.io/hanzoai/storage
- publish.yml: build linux/darwin/windows binaries on tag push
- workers/dl/: Cloudflare Worker to proxy GitHub release assets at dl.hanzo.space
This commit is contained in:
Hanzo Dev
2026-02-23 00:32:52 -08:00
parent 759177dfec
commit 8fe77d4d8a
3 changed files with 130 additions and 4 deletions
+56 -4
View File
@@ -1,4 +1,4 @@
name: Publish to GHCR
name: Publish
on:
push:
@@ -8,10 +8,10 @@ on:
env:
REGISTRY: ghcr.io
IMAGE_NAME: hanzoai/storage
jobs:
build-and-push:
docker:
name: Build and push Docker images
runs-on: ubuntu-latest
permissions:
contents: read
@@ -37,7 +37,9 @@ jobs:
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
images: |
${{ env.REGISTRY }}/hanzoai/s3
${{ env.REGISTRY }}/hanzoai/storage
tags: |
type=raw,value=latest,enable={{is_default_branch}}
type=sha,prefix=
@@ -54,3 +56,53 @@ jobs:
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max
binaries:
name: Build and upload release binaries
runs-on: ubuntu-latest
if: startsWith(github.ref, 'refs/tags/v')
permissions:
contents: write
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: '1.24'
- name: Get version from tag
id: version
run: echo "version=${GITHUB_REF_NAME#v}" >> "$GITHUB_OUTPUT"
- name: Build binaries
env:
VERSION: ${{ steps.version.outputs.version }}
COMMIT_ID: ${{ github.sha }}
run: |
LDFLAGS="-s -w \
-X github.com/minio/minio/cmd.Version=${VERSION} \
-X github.com/minio/minio/cmd.CopyrightYear=2026 \
-X github.com/minio/minio/cmd.ReleaseTag=RELEASE.${VERSION} \
-X github.com/minio/minio/cmd.CommitID=${COMMIT_ID:0:12} \
-X github.com/minio/minio/cmd.ShortCommitID=${COMMIT_ID:0:12}"
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -tags kqueue -trimpath -ldflags "${LDFLAGS}" -o s3-linux-amd64 .
CGO_ENABLED=0 GOOS=linux GOARCH=arm64 go build -tags kqueue -trimpath -ldflags "${LDFLAGS}" -o s3-linux-arm64 .
CGO_ENABLED=0 GOOS=darwin GOARCH=amd64 go build -tags kqueue -trimpath -ldflags "${LDFLAGS}" -o s3-darwin-amd64 .
CGO_ENABLED=0 GOOS=darwin GOARCH=arm64 go build -tags kqueue -trimpath -ldflags "${LDFLAGS}" -o s3-darwin-arm64 .
CGO_ENABLED=0 GOOS=windows GOARCH=amd64 go build -tags kqueue -trimpath -ldflags "${LDFLAGS}" -o s3-windows-amd64.exe .
- name: Upload to release
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
gh release upload "$GITHUB_REF_NAME" \
s3-linux-amd64 \
s3-linux-arm64 \
s3-darwin-amd64 \
s3-darwin-arm64 \
s3-windows-amd64.exe \
--clobber
+66
View File
@@ -0,0 +1,66 @@
/**
* dl.hanzo.space — Download proxy for Hanzo S3 server binaries.
*
* Routes:
* /server/s3/release/linux-amd64/s3 → GitHub release asset s3-linux-amd64
* /server/s3/release/linux-arm64/s3 → GitHub release asset s3-linux-arm64
* /server/s3/release/darwin-amd64/s3 → GitHub release asset s3-darwin-amd64
* /server/s3/release/darwin-arm64/s3 → GitHub release asset s3-darwin-arm64
* /server/s3/release/windows-amd64/s3.exe → GitHub release asset s3-windows-amd64.exe
*/
const REPO = 'hanzoai/s3';
const CACHE_TTL = 3600; // 1 hour
const ASSET_MAP = {
'/server/s3/release/linux-amd64/s3': 's3-linux-amd64',
'/server/s3/release/linux-arm64/s3': 's3-linux-arm64',
'/server/s3/release/darwin-amd64/s3': 's3-darwin-amd64',
'/server/s3/release/darwin-arm64/s3': 's3-darwin-arm64',
'/server/s3/release/windows-amd64/s3.exe': 's3-windows-amd64.exe',
};
export default {
async fetch(request) {
const url = new URL(request.url);
const path = url.pathname;
if (path === '/' || path === '') {
return new Response('Hanzo S3 Downloads\nhttps://github.com/hanzoai/s3\n', {
headers: { 'content-type': 'text/plain' },
});
}
const assetName = ASSET_MAP[path];
if (!assetName) {
return new Response('Not found\n', { status: 404 });
}
// Get latest release
const releaseResp = await fetch(
`https://api.github.com/repos/${REPO}/releases/latest`,
{
headers: {
'User-Agent': 'dl.hanzo.space',
'Accept': 'application/vnd.github.v3+json',
},
}
);
if (!releaseResp.ok) {
return new Response('Failed to fetch release info\n', { status: 502 });
}
const release = await releaseResp.json();
const asset = release.assets?.find(a => a.name === assetName);
if (!asset) {
return new Response(`Asset ${assetName} not found in release ${release.tag_name}\n`, {
status: 404,
});
}
// Redirect to the download URL
return Response.redirect(asset.browser_download_url, 302);
},
};
+8
View File
@@ -0,0 +1,8 @@
name = "dl-hanzo-space"
main = "src/worker.js"
compatibility_date = "2024-01-01"
[env.production]
routes = [
{ pattern = "dl.hanzo.space/*", zone_name = "hanzo.space" }
]