fix
All checks were successful
Build Release Binaries / build-and-release (push) Successful in 10m31s

This commit is contained in:
Salastil
2025-11-23 12:40:15 -05:00
parent 37bfd30a84
commit 5ea24f3b0b

View File

@@ -1,8 +1,6 @@
name: Build Release Binaries name: Build Release Binaries
on: on:
release:
types: [published]
push: push:
tags: tags:
- "v*" - "v*"
@@ -13,6 +11,7 @@ permissions:
env: env:
BINARY_NAME: streamed-tui BINARY_NAME: streamed-tui
API_BASE: https://git.salastil.com/api/v1 API_BASE: https://git.salastil.com/api/v1
GITEA_ENV: gitea.env
jobs: jobs:
build-and-release: build-and-release:
@@ -28,88 +27,121 @@ jobs:
go-version-file: go.mod go-version-file: go.mod
cache: true cache: true
- name: Bundle Node.js dependencies #######################################################
# 1. Bundle puppeteer-extra + stealth plugin
#######################################################
- name: Bundle extractor node_modules
run: | run: |
bash scripts/build_node_modules.sh chmod +x ./scripts/build_node_modules.sh
./scripts/build_node_modules.sh
- name: Build all platform binaries #######################################################
# 2. Build all platform binaries
#######################################################
- name: Build binaries
run: | run: |
mkdir -p dist mkdir -p dist
build() { build() {
GOOS=$1 GOOS="$1" GOARCH="$2"
GOARCH=$2 OUT="${BINARY_NAME}_${1}_${2}"
EXT=$3 echo "Building $1 $2 => $OUT"
OUT="${BINARY_NAME}_${GOOS}_${GOARCH}${EXT}"
echo "Building $GOOS $GOARCH => $OUT" env \
env GOOS=$1 GOARCH=$2 CGO_ENABLED=0 go build -o "dist/${OUT}" . GOOS="$1" \
GOARCH="$2" \
CGO_ENABLED=0 \
go build -o "dist/${OUT}" .
} }
build linux amd64 "" build linux amd64
build linux arm64 "" build linux arm64
build darwin amd64 "" build darwin amd64
build darwin arm64 "" build darwin arm64
- name: Create release in Gitea #######################################################
id: create_release # 3. Check if release exists → create if needed
#######################################################
- name: Ensure release exists
id: ensure_release
env: env:
GITEA_TOKEN: ${{ secrets.CI_TOKEN }} GITEA_TOKEN: ${{ secrets.CI_TOKEN }}
TAG: ${{ github.ref_name }} TAG: ${{ github.ref_name }}
REPO: ${{ github.repository }} REPO: ${{ github.repository }}
run: | run: |
if [ -z "$GITEA_TOKEN" ]; then set -e
echo "ERROR: Missing CI_TOKEN secret"
exit 1
fi
echo "Checking if release exists: $TAG" echo "Checking if release exists: $TAG"
# Check release existence # Query
CHECK=$(curl -s -o /dev/null -w "%{http_code}" \ STATUS=$(curl -s -o resp.json -w "%{http_code}" \
-H "Authorization: token ${GITEA_TOKEN}" \ -H "Authorization: token ${GITEA_TOKEN}" \
"${{ env.API_BASE }}/repos/${REPO}/releases/tags/${TAG}") "${API_BASE}/repos/${REPO}/releases/tags/${TAG}")
if [ "$CHECK" = "200" ]; then if [ "$STATUS" = "200" ]; then
echo "Release already exists." echo "Release already exists."
RELEASE_ID=$(curl -s \ RELEASE_ID=$(jq -r '.id' resp.json)
-H "Authorization: token ${GITEA_TOKEN}" \
"${{ env.API_BASE }}/repos/${REPO}/releases/tags/${TAG}" | \
grep -o '"id":[0-9]*' | grep -o '[0-9]*')
else else
echo "Release does not exist — creating" echo "Release does not exist — creating"
RESPONSE=$(curl -s -X POST \ CREATE=$(curl -s -o create.json -w "%{http_code}" \
-X POST \
-H "Authorization: token ${GITEA_TOKEN}" \ -H "Authorization: token ${GITEA_TOKEN}" \
-H "Content-Type: application/json" \ -H "Content-Type: application/json" \
-d "{ -d "{
\"tag_name\": \"${TAG}\", \"tag_name\": \"${TAG}\",
\"name\": \"Release ${TAG}\", \"name\": \"${TAG}\",
\"body\": \"Automated release ${TAG}\", \"body\": \"Automated release ${TAG}\",
\"draft\": false, \"draft\": false,
\"prerelease\": false \"prerelease\": false
}" \ }" \
"${{ env.API_BASE }}/repos/${REPO}/releases") "${API_BASE}/repos/${REPO}/releases")
RELEASE_ID=$(echo "$RESPONSE" | grep -o '"id":[0-9]*' | grep -o '[0-9]*') echo "Gitea API Response Code: $CREATE"
RELEASE_ID=$(jq -r '.id' create.json)
echo "New release id: $RELEASE_ID"
fi fi
echo "release_id=${RELEASE_ID}" >> $GITHUB_OUTPUT if [ -z "$RELEASE_ID" ] || [ "$RELEASE_ID" = "null" ]; then
echo "ERROR: Could not determine release ID"
exit 1
fi
- name: Upload release assets # Write to environment file (Gitea-compatible)
echo "RELEASE_ID=${RELEASE_ID}" >> "$GITEA_ENV"
#######################################################
# 4. Load RELEASE_ID into environment (Gitea-compatible)
#######################################################
- name: Load RELEASE_ID
run: |
if [ -f "$GITEA_ENV" ]; then
cat "$GITEA_ENV" >> "$GITHUB_ENV"
echo "Loaded RELEASE_ID=$RELEASE_ID"
else
echo "ERROR: gitea.env missing"
exit 1
fi
#######################################################
# 5. Upload all binaries as release assets
#######################################################
- name: Upload binaries to Gitea Release
env: env:
GITEA_TOKEN: ${{ secrets.CI_TOKEN }} GITEA_TOKEN: ${{ secrets.CI_TOKEN }}
RELEASE_ID: ${{ steps.create_release.outputs.release_id }}
API_BASE: ${{ env.API_BASE }}
REPO: ${{ github.repository }} REPO: ${{ github.repository }}
RELEASE_ID: ${{ env.RELEASE_ID }}
run: | run: |
echo "Uploading binaries..." echo "Uploading binaries..."
cd dist
for file in dist/*; do for file in *; do
echo "Uploading $file" echo "Uploading $file..."
curl -s -X POST \ curl -s -X POST \
-H "Authorization: token ${GITEA_TOKEN}" \ -H "Authorization: token ${GITEA_TOKEN}" \
-H "Content-Type: application/octet-stream" \ -H "Content-Type: application/octet-stream" \
--data-binary @"$file" \ --data-binary @"${file}" \
"${API_BASE}/repos/${REPO}/releases/${RELEASE_ID}/assets?name=$(basename "$file")" "${API_BASE}/repos/${REPO}/releases/${RELEASE_ID}/assets?name=${file}"
done done
echo "Done uploading release artifacts" echo "Upload complete."