- Introduced `publish_build.sh` to automate frontend and server builds, including desktop binaries for Linux, Windows, and Mac. - Added `publish_setup.sh` for installing system and project dependencies. - Created `publish.sh` to handle release creation and asset uploads to Gitea.
66 lines
1.7 KiB
Bash
66 lines
1.7 KiB
Bash
#!/usr/bin/env bash
|
|
set -euo pipefail
|
|
|
|
echo "Creating release and uploading packages..."
|
|
|
|
# Variables passed from environment
|
|
TAG_NAME="${REF_NAME}"
|
|
REPO_OWNER="${REPO_OWNER}"
|
|
REPO_NAME="${REPO_NAME}"
|
|
GITEA_URL="${SERVER_URL}"
|
|
GITEA_TOKEN="${GITEA_TOKEN}"
|
|
|
|
echo "Release details:"
|
|
echo " Tag: $TAG_NAME"
|
|
echo " Repository: $REPO_OWNER/$REPO_NAME"
|
|
echo " Gitea URL: $GITEA_URL"
|
|
|
|
# Prepare body with hashes
|
|
HASHES=$(cat dist/SHA256SUMS | sed ':a;N;$!ba;s/\n/\\n/g')
|
|
|
|
# Create release
|
|
echo "Creating release for tag $TAG_NAME..."
|
|
RELEASE_RESPONSE=$(curl -s -X POST \
|
|
-H "Authorization: token $GITEA_TOKEN" \
|
|
-H "Content-Type: application/json" \
|
|
-d "{
|
|
\"tag_name\": \"$TAG_NAME\",
|
|
\"name\": \"Web News $TAG_NAME\",
|
|
\"body\": \"SHA256 Hashes:\\n\\n$HASHES\",
|
|
\"draft\": false,
|
|
\"prerelease\": false
|
|
}" \
|
|
"$GITEA_URL/api/v1/repos/$REPO_OWNER/$REPO_NAME/releases")
|
|
|
|
RELEASE_ID=$(echo "$RELEASE_RESPONSE" | grep -o '"id":[0-9]*' | head -1 | cut -d':' -f2)
|
|
|
|
if [ -z "$RELEASE_ID" ]; then
|
|
echo "Failed to create release. Response: $RELEASE_RESPONSE"
|
|
exit 1
|
|
fi
|
|
|
|
echo "Created release with ID: $RELEASE_ID"
|
|
|
|
# Upload each file to the release
|
|
for file in dist/*; do
|
|
if [ -f "$file" ]; then
|
|
filename=$(basename "$file")
|
|
echo "Uploading $filename..."
|
|
|
|
curl -X POST \
|
|
-H "Authorization: token $GITEA_TOKEN" \
|
|
-H "Content-Type: application/octet-stream" \
|
|
-T "$file" \
|
|
"$GITEA_URL/api/v1/repos/$REPO_OWNER/$REPO_NAME/releases/$RELEASE_ID/assets?name=$filename"
|
|
|
|
if [ $? -eq 0 ]; then
|
|
echo "Successfully uploaded $filename"
|
|
else
|
|
echo "Failed to upload $filename"
|
|
fi
|
|
fi
|
|
done
|
|
|
|
echo "Release created and packages uploaded."
|
|
|