Files
streamed-tui/.gitea/workflows/release.yml
Salastil 37bfd30a84
Some checks failed
Build Release Binaries / build-and-release (push) Failing after 10m29s
Unique filenames for builds
2025-11-23 05:42:55 -05:00

116 lines
3.3 KiB
YAML

name: Build Release Binaries
on:
release:
types: [published]
push:
tags:
- "v*"
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: Bundle Node.js dependencies
run: |
bash scripts/build_node_modules.sh
- name: Build all platform binaries
run: |
mkdir -p dist
build() {
GOOS=$1
GOARCH=$2
EXT=$3
OUT="${BINARY_NAME}_${GOOS}_${GOARCH}${EXT}"
echo "Building $GOOS $GOARCH => $OUT"
env GOOS=$1 GOARCH=$2 CGO_ENABLED=0 go build -o "dist/${OUT}" .
}
build linux amd64 ""
build linux arm64 ""
build darwin amd64 ""
build darwin arm64 ""
- name: Create release in Gitea
id: create_release
env:
GITEA_TOKEN: ${{ secrets.CI_TOKEN }}
TAG: ${{ github.ref_name }}
REPO: ${{ github.repository }}
run: |
if [ -z "$GITEA_TOKEN" ]; then
echo "ERROR: Missing CI_TOKEN secret"
exit 1
fi
echo "Checking if release exists: $TAG"
# Check release existence
CHECK=$(curl -s -o /dev/null -w "%{http_code}" \
-H "Authorization: token ${GITEA_TOKEN}" \
"${{ env.API_BASE }}/repos/${REPO}/releases/tags/${TAG}")
if [ "$CHECK" = "200" ]; then
echo "Release already exists."
RELEASE_ID=$(curl -s \
-H "Authorization: token ${GITEA_TOKEN}" \
"${{ env.API_BASE }}/repos/${REPO}/releases/tags/${TAG}" | \
grep -o '"id":[0-9]*' | grep -o '[0-9]*')
else
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}\",
\"body\": \"Automated release ${TAG}\",
\"draft\": false,
\"prerelease\": false
}" \
"${{ env.API_BASE }}/repos/${REPO}/releases")
RELEASE_ID=$(echo "$RESPONSE" | grep -o '"id":[0-9]*' | grep -o '[0-9]*')
fi
echo "release_id=${RELEASE_ID}" >> $GITHUB_OUTPUT
- name: Upload release assets
env:
GITEA_TOKEN: ${{ secrets.CI_TOKEN }}
RELEASE_ID: ${{ steps.create_release.outputs.release_id }}
API_BASE: ${{ env.API_BASE }}
REPO: ${{ github.repository }}
run: |
echo "Uploading binaries..."
for file in dist/*; do
echo "Uploading $file"
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=$(basename "$file")"
done
echo "Done uploading release artifacts"