.
This commit is contained in:
parent
be75b54d71
commit
d716b0f9e9
70
publish.sh
Normal file → Executable file
70
publish.sh
Normal file → Executable file
@ -1,4 +1,5 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
set -e
|
||||||
|
|
||||||
# Publishes bb64 (both arm64 and amd64) to the Gitea Releases page for the repository.
|
# Publishes bb64 (both arm64 and amd64) to the Gitea Releases page for the repository.
|
||||||
|
|
||||||
@ -10,4 +11,73 @@
|
|||||||
|
|
||||||
# Prints a message to the user.
|
# Prints a message to the user.
|
||||||
|
|
||||||
|
# Increment version
|
||||||
|
if [ ! -f VERSION ]; then
|
||||||
|
echo 1 > VERSION
|
||||||
|
else
|
||||||
|
v=$(cat VERSION)
|
||||||
|
v=$((v+1))
|
||||||
|
echo $v > VERSION
|
||||||
|
fi
|
||||||
|
VERSION=$(cat VERSION)
|
||||||
|
TAG="v$VERSION"
|
||||||
|
|
||||||
|
# Build binaries
|
||||||
|
./build.sh
|
||||||
|
|
||||||
|
# Find repo info from .git/config
|
||||||
|
REPO_URL=$(git config --get remote.origin.url)
|
||||||
|
if [[ ! $REPO_URL =~ gitea ]]; then
|
||||||
|
echo "Remote origin is not a Gitea repository: $REPO_URL" >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
# Extract base URL, owner, and repo
|
||||||
|
# Example: https://gitea.example.com/username/reponame.git
|
||||||
|
BASE_URL=$(echo "$REPO_URL" | sed -E 's#(https?://[^/]+)/.*#\1#')
|
||||||
|
OWNER=$(echo "$REPO_URL" | sed -E 's#.*/([^/]+)/[^/]+(\.git)?$#\1#')
|
||||||
|
REPO=$(echo "$REPO_URL" | sed -E 's#.*/([^/]+)(\.git)?$#\1#')
|
||||||
|
|
||||||
|
API_URL="$BASE_URL/api/v1/repos/$OWNER/$REPO"
|
||||||
|
|
||||||
|
# Check for GITEA_TOKEN
|
||||||
|
if [ -z "$GITEA_TOKEN_DEPLOY" ]; then
|
||||||
|
echo "GITEA_TOKEN_DEPLOY environment variable not set!" >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Create release
|
||||||
|
RELEASE_DATA=$(cat <<EOF
|
||||||
|
{
|
||||||
|
"tag_name": "$TAG",
|
||||||
|
"name": "$TAG",
|
||||||
|
"body": "bb64 release $TAG",
|
||||||
|
"draft": false,
|
||||||
|
"prerelease": false
|
||||||
|
}
|
||||||
|
EOF
|
||||||
|
)
|
||||||
|
|
||||||
|
RELEASE_ID=$(curl -s -X POST "$API_URL/releases" \
|
||||||
|
-H "Content-Type: application/json" \
|
||||||
|
-H "Authorization: token $GITEA_TOKEN_DEPLOY" \
|
||||||
|
-d "$RELEASE_DATA" | grep -o '"id":[0-9]*' | head -1 | cut -d: -f2)
|
||||||
|
|
||||||
|
if [ -z "$RELEASE_ID" ]; then
|
||||||
|
echo "Failed to create release on Gitea." >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Upload binaries
|
||||||
|
for BIN in bb64 bb64.arm64; do
|
||||||
|
if [ -f "$BIN" ]; then
|
||||||
|
curl -s -X POST "$API_URL/releases/$RELEASE_ID/assets?name=$BIN" \
|
||||||
|
-H "Content-Type: application/octet-stream" \
|
||||||
|
-H "Authorization: token $GITEA_TOKEN_DEPLOY" \
|
||||||
|
--data-binary @"$BIN"
|
||||||
|
echo "Uploaded $BIN to release $TAG."
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
|
echo "Published bb64 version $VERSION to $REPO_URL (tag $TAG) with binaries."
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user