b222105e1f
ci / vet, staticcheck, test, build (push) Successful in 2m10s
- Add build steps for linux/arm64, darwin/amd64, darwin/arm64 - Rename Windows output to glint-<tag>-windows-amd64.exe (consistent with Taskfile and INSTALL.md) - Add -X main.version=<tag> to all ldflags (was missing, causing release binaries to report "dev" as version) - Use $TAG variable in upload loop instead of repeating the expression Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
111 lines
3.3 KiB
YAML
111 lines
3.3 KiB
YAML
name: release
|
|
|
|
on:
|
|
push:
|
|
tags:
|
|
- 'v*'
|
|
|
|
jobs:
|
|
release:
|
|
name: Build and publish release
|
|
runs-on: ubuntu-latest
|
|
container:
|
|
image: golang:1.26-alpine
|
|
|
|
steps:
|
|
- name: Install tools
|
|
run: apk add --no-cache curl git jq
|
|
|
|
- name: Checkout
|
|
env:
|
|
TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
SERVER_URL: ${{ github.server_url }}
|
|
REPO: ${{ github.repository }}
|
|
REF: ${{ github.ref_name }}
|
|
run: |
|
|
git clone --depth 1 --branch "$REF" \
|
|
"$(echo "$SERVER_URL" | sed "s|https://|https://oauth2:${TOKEN}@|")/${REPO}.git" .
|
|
|
|
- name: Build Linux (amd64)
|
|
env:
|
|
GOOS: linux
|
|
GOARCH: amd64
|
|
CGO_ENABLED: "0"
|
|
run: |
|
|
go build -trimpath \
|
|
-ldflags="-s -w -X main.version=${{ github.ref_name }}" \
|
|
-o glint-${{ github.ref_name }}-linux-amd64 \
|
|
./cmd/glint/...
|
|
|
|
- name: Build Linux (arm64)
|
|
env:
|
|
GOOS: linux
|
|
GOARCH: arm64
|
|
CGO_ENABLED: "0"
|
|
run: |
|
|
go build -trimpath \
|
|
-ldflags="-s -w -X main.version=${{ github.ref_name }}" \
|
|
-o glint-${{ github.ref_name }}-linux-arm64 \
|
|
./cmd/glint/...
|
|
|
|
- name: Build macOS (amd64)
|
|
env:
|
|
GOOS: darwin
|
|
GOARCH: amd64
|
|
CGO_ENABLED: "0"
|
|
run: |
|
|
go build -trimpath \
|
|
-ldflags="-s -w -X main.version=${{ github.ref_name }}" \
|
|
-o glint-${{ github.ref_name }}-darwin-amd64 \
|
|
./cmd/glint/...
|
|
|
|
- name: Build macOS (arm64)
|
|
env:
|
|
GOOS: darwin
|
|
GOARCH: arm64
|
|
CGO_ENABLED: "0"
|
|
run: |
|
|
go build -trimpath \
|
|
-ldflags="-s -w -X main.version=${{ github.ref_name }}" \
|
|
-o glint-${{ github.ref_name }}-darwin-arm64 \
|
|
./cmd/glint/...
|
|
|
|
- name: Build Windows (amd64)
|
|
env:
|
|
GOOS: windows
|
|
GOARCH: amd64
|
|
CGO_ENABLED: "0"
|
|
run: |
|
|
go build -trimpath \
|
|
-ldflags="-s -w -X main.version=${{ github.ref_name }}" \
|
|
-o glint-${{ github.ref_name }}-windows-amd64.exe \
|
|
./cmd/glint/...
|
|
|
|
- name: Create release and upload assets
|
|
env:
|
|
TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
TAG: ${{ github.ref_name }}
|
|
API_URL: ${{ github.api_url }}
|
|
REPO: ${{ github.repository }}
|
|
run: |
|
|
release_id=$(curl -sf -X POST \
|
|
-H "Authorization: token $TOKEN" \
|
|
-H "Content-Type: application/json" \
|
|
"$API_URL/repos/$REPO/releases" \
|
|
-d "{\"tag_name\":\"$TAG\",\"name\":\"$TAG\",\"draft\":false,\"prerelease\":false}" \
|
|
| jq -r .id)
|
|
|
|
for file in \
|
|
glint-${TAG}-linux-amd64 \
|
|
glint-${TAG}-linux-arm64 \
|
|
glint-${TAG}-darwin-amd64 \
|
|
glint-${TAG}-darwin-arm64 \
|
|
glint-${TAG}-windows-amd64.exe; do
|
|
curl -sf -X POST \
|
|
-H "Authorization: token $TOKEN" \
|
|
-H "Content-Type: application/octet-stream" \
|
|
"$API_URL/repos/$REPO/releases/$release_id/assets?name=$file" \
|
|
--data-binary "@$file"
|
|
echo "uploaded: $file"
|
|
done
|