Update Gitea workflow
Some checks failed
Build Release Binaries / build-and-release (push) Failing after 5m43s
Some checks failed
Build Release Binaries / build-and-release (push) Failing after 5m43s
This commit is contained in:
@@ -1,11 +1,11 @@
|
|||||||
name: Build Release Binaries
|
name: Build Release Binaries
|
||||||
|
|
||||||
on:
|
on:
|
||||||
release:
|
|
||||||
types: [published]
|
|
||||||
push:
|
push:
|
||||||
tags:
|
tags:
|
||||||
- "v*"
|
- "v*"
|
||||||
|
release:
|
||||||
|
types: [published]
|
||||||
|
|
||||||
permissions:
|
permissions:
|
||||||
contents: write
|
contents: write
|
||||||
@@ -28,76 +28,64 @@ jobs:
|
|||||||
go-version-file: go.mod
|
go-version-file: go.mod
|
||||||
cache: true
|
cache: true
|
||||||
|
|
||||||
- name: Build all platform binaries
|
- name: Build Puppeteer bundle
|
||||||
|
run: |
|
||||||
|
chmod +x scripts/build_node_modules.sh
|
||||||
|
scripts/build_node_modules.sh
|
||||||
|
|
||||||
|
- name: Build platform binaries
|
||||||
run: |
|
run: |
|
||||||
mkdir -p dist
|
mkdir -p dist
|
||||||
|
|
||||||
build() {
|
build() {
|
||||||
GOOS=$1 GOARCH=$2 EXT=$3
|
GOOS="$1"
|
||||||
OUT="${BINARY_NAME}${EXT}"
|
GOARCH="$2"
|
||||||
echo "Building $1 $2 => $OUT"
|
EXT="$3"
|
||||||
env GOOS=$1 GOARCH=$2 CGO_ENABLED=0 go build -o "dist/${OUT}" .
|
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 amd64 ""
|
||||||
build linux arm64 ""
|
build linux arm64 ""
|
||||||
build darwin amd64 ""
|
build darwin amd64 ""
|
||||||
build darwin arm64 ""
|
build darwin arm64 ""
|
||||||
|
|
||||||
- name: Package binaries
|
- name: Create source tarball
|
||||||
run: |
|
run: |
|
||||||
cd dist
|
mkdir -p dist
|
||||||
|
git archive --format=tar.gz -o dist/streamed-tui_${GITHUB_REF_NAME}_source.tar.gz HEAD
|
||||||
|
|
||||||
pack() {
|
- name: Ensure release exists (create if missing)
|
||||||
NAME="$1"
|
id: ensure_release
|
||||||
EXT="$2"
|
|
||||||
|
|
||||||
if [[ "$EXT" == "zip" ]]; then
|
|
||||||
zip "${NAME}.zip" "${BINARY_NAME}${3}"
|
|
||||||
else
|
|
||||||
tar -czf "${NAME}.tar.gz" "${BINARY_NAME}${3}"
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
pack streamed-tui_linux_amd64 tar.gz ""
|
|
||||||
pack streamed-tui_linux_arm64 tar.gz ""
|
|
||||||
pack streamed-tui_darwin_amd64 tar.gz ""
|
|
||||||
pack streamed-tui_darwin_arm64 tar.gz ""
|
|
||||||
|
|
||||||
- name: Create release in Gitea
|
|
||||||
id: create_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 }}
|
||||||
API_BASE: ${{ env.API_BASE }}
|
API_BASE: ${{ env.API_BASE }}
|
||||||
run: |
|
run: |
|
||||||
if [ -z "$GITEA_TOKEN" ]; then
|
echo "Checking if release exists: $TAG"
|
||||||
echo "ERROR: Missing CI_TOKEN secret"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
echo "Creating release for tag: $TAG"
|
EXISTING=$(curl -s -H "Authorization: token ${GITEA_TOKEN}" \
|
||||||
|
"${API_BASE}/repos/${REPO}/releases/tags/${TAG}")
|
||||||
|
|
||||||
RESPONSE=$(curl -s -X POST \
|
RELEASE_ID=$(echo "$EXISTING" | grep -o '"id":[0-9]*' | head -1 | grep -o '[0-9]*' || true)
|
||||||
-H "Authorization: token ${GITEA_TOKEN}" \
|
|
||||||
-H "Content-Type: application/json" \
|
|
||||||
-d "{
|
|
||||||
\"tag_name\": \"${TAG}\",
|
|
||||||
\"name\": \"Release ${TAG}\",
|
|
||||||
\"body\": \"Automated release for ${TAG}\",
|
|
||||||
\"draft\": false,
|
|
||||||
\"prerelease\": false
|
|
||||||
}" \
|
|
||||||
"${API_BASE}/repos/${REPO}/releases")
|
|
||||||
|
|
||||||
echo "RESPONSE=$RESPONSE"
|
|
||||||
|
|
||||||
RELEASE_ID=$(echo "$RESPONSE" | grep -o '"id":[0-9]*' | head -1 | grep -o '[0-9]*')
|
|
||||||
echo "Release ID: $RELEASE_ID"
|
|
||||||
|
|
||||||
if [ -z "$RELEASE_ID" ]; then
|
if [ -z "$RELEASE_ID" ]; then
|
||||||
echo "ERROR: Failed to extract release ID"
|
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
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
@@ -106,20 +94,21 @@ jobs:
|
|||||||
- name: Upload release assets
|
- name: Upload release assets
|
||||||
env:
|
env:
|
||||||
GITEA_TOKEN: ${{ secrets.CI_TOKEN }}
|
GITEA_TOKEN: ${{ secrets.CI_TOKEN }}
|
||||||
RELEASE_ID: ${{ steps.create_release.outputs.release_id }}
|
RELEASE_ID: ${{ steps.ensure_release.outputs.release_id }}
|
||||||
API_BASE: ${{ env.API_BASE }}
|
API_BASE: ${{ env.API_BASE }}
|
||||||
REPO: ${{ github.repository }}
|
REPO: ${{ github.repository }}
|
||||||
run: |
|
run: |
|
||||||
echo "Uploading assets..."
|
echo "Uploading assets to release ${RELEASE_ID}"
|
||||||
cd dist
|
|
||||||
|
|
||||||
for file in *; do
|
for file in dist/*; do
|
||||||
echo "Uploading $file..."
|
name=$(basename "$file")
|
||||||
|
echo "Uploading $name..."
|
||||||
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=$file"
|
"${API_BASE}/repos/${REPO}/releases/${RELEASE_ID}/assets?name=${name}"
|
||||||
|
echo ""
|
||||||
done
|
done
|
||||||
|
|
||||||
echo "All assets uploaded."
|
echo "All assets uploaded."
|
||||||
|
|||||||
Reference in New Issue
Block a user