All checks were successful
Build Release Binaries / build-and-release (push) Successful in 10m31s
148 lines
4.4 KiB
YAML
148 lines
4.4 KiB
YAML
name: Build Release Binaries
|
|
|
|
on:
|
|
push:
|
|
tags:
|
|
- "v*"
|
|
|
|
permissions:
|
|
contents: write
|
|
|
|
env:
|
|
BINARY_NAME: streamed-tui
|
|
API_BASE: https://git.salastil.com/api/v1
|
|
GITEA_ENV: gitea.env
|
|
|
|
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
|
|
|
|
#######################################################
|
|
# 1. Bundle puppeteer-extra + stealth plugin
|
|
#######################################################
|
|
- name: Bundle extractor node_modules
|
|
run: |
|
|
chmod +x ./scripts/build_node_modules.sh
|
|
./scripts/build_node_modules.sh
|
|
|
|
#######################################################
|
|
# 2. Build all platform binaries
|
|
#######################################################
|
|
- name: Build binaries
|
|
run: |
|
|
mkdir -p dist
|
|
|
|
build() {
|
|
GOOS="$1" GOARCH="$2"
|
|
OUT="${BINARY_NAME}_${1}_${2}"
|
|
echo "Building $1 $2 => $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
|
|
|
|
#######################################################
|
|
# 3. Check if release exists → create if needed
|
|
#######################################################
|
|
- name: Ensure release exists
|
|
id: ensure_release
|
|
env:
|
|
GITEA_TOKEN: ${{ secrets.CI_TOKEN }}
|
|
TAG: ${{ github.ref_name }}
|
|
REPO: ${{ github.repository }}
|
|
run: |
|
|
set -e
|
|
|
|
echo "Checking if release exists: $TAG"
|
|
|
|
# Query
|
|
STATUS=$(curl -s -o resp.json -w "%{http_code}" \
|
|
-H "Authorization: token ${GITEA_TOKEN}" \
|
|
"${API_BASE}/repos/${REPO}/releases/tags/${TAG}")
|
|
|
|
if [ "$STATUS" = "200" ]; then
|
|
echo "Release already exists."
|
|
RELEASE_ID=$(jq -r '.id' resp.json)
|
|
else
|
|
echo "Release does not exist — creating"
|
|
CREATE=$(curl -s -o create.json -w "%{http_code}" \
|
|
-X POST \
|
|
-H "Authorization: token ${GITEA_TOKEN}" \
|
|
-H "Content-Type: application/json" \
|
|
-d "{
|
|
\"tag_name\": \"${TAG}\",
|
|
\"name\": \"${TAG}\",
|
|
\"body\": \"Automated release ${TAG}\",
|
|
\"draft\": false,
|
|
\"prerelease\": false
|
|
}" \
|
|
"${API_BASE}/repos/${REPO}/releases")
|
|
|
|
echo "Gitea API Response Code: $CREATE"
|
|
|
|
RELEASE_ID=$(jq -r '.id' create.json)
|
|
echo "New release id: $RELEASE_ID"
|
|
fi
|
|
|
|
if [ -z "$RELEASE_ID" ] || [ "$RELEASE_ID" = "null" ]; then
|
|
echo "ERROR: Could not determine release ID"
|
|
exit 1
|
|
fi
|
|
|
|
# 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:
|
|
GITEA_TOKEN: ${{ secrets.CI_TOKEN }}
|
|
REPO: ${{ github.repository }}
|
|
RELEASE_ID: ${{ env.RELEASE_ID }}
|
|
run: |
|
|
echo "Uploading binaries..."
|
|
cd dist
|
|
|
|
for file in *; 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=${file}"
|
|
done
|
|
|
|
echo "Upload complete."
|