Files
streamed-tui/.gitea/workflows/release.yml
Salastil 0f7f0219aa
Some checks failed
Build Release Binaries / build-and-release (push) Failing after 5m43s
Update Gitea workflow
2025-11-23 04:47:19 -05:00

115 lines
3.3 KiB
YAML

name: Build Release Binaries
on:
push:
tags:
- "v*"
release:
types: [published]
permissions:
contents: write
env:
BINARY_NAME: streamed-tui
API_BASE: https://git.salastil.com/api/v1
jobs:
build-and-release:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version-file: go.mod
cache: true
- name: Build Puppeteer bundle
run: |
chmod +x scripts/build_node_modules.sh
scripts/build_node_modules.sh
- name: Build platform binaries
run: |
mkdir -p dist
build() {
GOOS="$1"
GOARCH="$2"
EXT="$3"
OUT="streamed-tui_${GOOS}_${GOARCH}${EXT}"
echo "Building ${OUT}"
env GOOS=$GOOS GOARCH=$GOARCH CGO_ENABLED=0 go build -o dist/${OUT} .
}
build linux amd64 ""
build linux arm64 ""
build darwin amd64 ""
build darwin arm64 ""
- name: Create source tarball
run: |
mkdir -p dist
git archive --format=tar.gz -o dist/streamed-tui_${GITHUB_REF_NAME}_source.tar.gz HEAD
- name: Ensure release exists (create if missing)
id: ensure_release
env:
GITEA_TOKEN: ${{ secrets.CI_TOKEN }}
TAG: ${{ github.ref_name }}
REPO: ${{ github.repository }}
API_BASE: ${{ env.API_BASE }}
run: |
echo "Checking if release exists: $TAG"
EXISTING=$(curl -s -H "Authorization: token ${GITEA_TOKEN}" \
"${API_BASE}/repos/${REPO}/releases/tags/${TAG}")
RELEASE_ID=$(echo "$EXISTING" | grep -o '"id":[0-9]*' | head -1 | grep -o '[0-9]*' || true)
if [ -z "$RELEASE_ID" ]; then
echo "Release does not exist — creating"
RESPONSE=$(curl -s -X POST \
-H "Authorization: token ${GITEA_TOKEN}" \
-H "Content-Type: application/json" \
-d "{\"tag_name\":\"${TAG}\",\"name\":\"Release ${TAG}\",\"draft\":false}" \
"${API_BASE}/repos/${REPO}/releases")
RELEASE_ID=$(echo "$RESPONSE" | grep -o '"id":[0-9]*' | head -1 | grep -o '[0-9]*')
else
echo "Release already exists: $RELEASE_ID"
fi
if [ -z "$RELEASE_ID" ]; then
echo "Failed to create or fetch release"
exit 1
fi
echo "release_id=${RELEASE_ID}" >> $GITHUB_OUTPUT
- name: Upload release assets
env:
GITEA_TOKEN: ${{ secrets.CI_TOKEN }}
RELEASE_ID: ${{ steps.ensure_release.outputs.release_id }}
API_BASE: ${{ env.API_BASE }}
REPO: ${{ github.repository }}
run: |
echo "Uploading assets to release ${RELEASE_ID}"
for file in dist/*; do
name=$(basename "$file")
echo "Uploading $name..."
curl -s -X POST \
-H "Authorization: token ${GITEA_TOKEN}" \
-H "Content-Type: application/octet-stream" \
--data-binary @"$file" \
"${API_BASE}/repos/${REPO}/releases/${RELEASE_ID}/assets?name=${name}"
echo ""
done
echo "All assets uploaded."