Compare commits
1 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 3ec52f2aea |
@@ -67,25 +67,32 @@ jobs:
|
|||||||
-o bin/${OUTPUT_NAME} ./cmd/safelineApi
|
-o bin/${OUTPUT_NAME} ./cmd/safelineApi
|
||||||
echo "BINARY_NAME=${OUTPUT_NAME}" >> $GITHUB_ENV
|
echo "BINARY_NAME=${OUTPUT_NAME}" >> $GITHUB_ENV
|
||||||
|
|
||||||
- name: Create or Update Release
|
- name: Create Release (first run only)
|
||||||
run: |
|
run: |
|
||||||
VERSION="${{ steps.version.outputs.VERSION }}"
|
VERSION="${{ steps.version.outputs.VERSION }}"
|
||||||
REPO="${{ gitea.repository }}"
|
REPO="${{ gitea.repository }}"
|
||||||
SERVER="${{ gitea.server_url }}"
|
SERVER="${{ gitea.server_url }}"
|
||||||
TOKEN="${{ secrets.GITEA_TOKEN }}"
|
TOKEN="${{ secrets.GITEA_TOKEN }}"
|
||||||
|
|
||||||
# Try to create release (ignore error if already exists)
|
# Check if release exists
|
||||||
curl -X POST "${SERVER}/api/v1/repos/${REPO}/releases" \
|
RESPONSE=$(curl -s -o /dev/null -w "%{http_code}" "${SERVER}/api/v1/repos/${REPO}/releases/tags/${VERSION}" \
|
||||||
-H "Authorization: token ${TOKEN}" \
|
-H "Authorization: token ${TOKEN}")
|
||||||
-H "Content-Type: application/json" \
|
|
||||||
-d '{
|
if [ "$RESPONSE" = "404" ]; then
|
||||||
"tag_name": "'${VERSION}'",
|
# Create release if it doesn't exist
|
||||||
"target_commitish": "main",
|
curl -X POST "${SERVER}/api/v1/repos/${REPO}/releases" \
|
||||||
"name": "Release '${VERSION}'",
|
-H "Authorization: token ${TOKEN}" \
|
||||||
"body": "# SafelineAPI '${VERSION}'\n\n## Available Downloads\n\n### Linux\n- **amd64**: safelineApi-linux-amd64\n- **ARM64**: safelineApi-linux-arm64\n- **ARMv7**: safelineApi-linux-armv7\n- **386**: safelineApi-linux-386\n- **PowerPC 64LE**: safelineApi-linux-ppc64le\n\n### Windows\n- **amd64**: safelineApi-windows-amd64.exe\n- **386**: safelineApi-windows-386.exe",
|
-H "Content-Type: application/json" \
|
||||||
"draft": false,
|
-d '{
|
||||||
"prerelease": false
|
"tag_name": "'${VERSION}'",
|
||||||
}' || true
|
"name": "Release '${VERSION}'",
|
||||||
|
"body": "# SafelineAPI '${VERSION}'\n\n## Available Downloads\n\n### Linux\n- **amd64**: safelineApi-linux-amd64\n- **ARM64**: safelineApi-linux-arm64\n- **ARMv7**: safelineApi-linux-armv7\n- **386**: safelineApi-linux-386\n- **PowerPC 64LE**: safelineApi-linux-ppc64le\n\n### Windows\n- **amd64**: safelineApi-windows-amd64.exe\n- **386**: safelineApi-windows-386.exe",
|
||||||
|
"draft": false,
|
||||||
|
"prerelease": false
|
||||||
|
}'
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "Release checked/created"
|
||||||
|
|
||||||
- name: Upload Binary Asset
|
- name: Upload Binary Asset
|
||||||
run: |
|
run: |
|
||||||
@@ -95,11 +102,21 @@ jobs:
|
|||||||
TOKEN="${{ secrets.GITEA_TOKEN }}"
|
TOKEN="${{ secrets.GITEA_TOKEN }}"
|
||||||
BINARY="${{ env.BINARY_NAME }}"
|
BINARY="${{ env.BINARY_NAME }}"
|
||||||
|
|
||||||
# Get release ID
|
# Get release data
|
||||||
RELEASE_ID=$(curl -s "${SERVER}/api/v1/repos/${REPO}/releases/tags/${VERSION}" \
|
RELEASE_DATA=$(curl -s "${SERVER}/api/v1/repos/${REPO}/releases/tags/${VERSION}" \
|
||||||
-H "Authorization: token ${TOKEN}" | grep '"id"' | head -1 | grep -o '[0-9]*')
|
-H "Authorization: token ${TOKEN}")
|
||||||
|
|
||||||
|
RELEASE_ID=$(echo "$RELEASE_DATA" | grep -o '"id":[0-9]*' | head -1 | grep -o '[0-9]*')
|
||||||
|
|
||||||
|
if [ -z "$RELEASE_ID" ]; then
|
||||||
|
echo "Failed to get release ID"
|
||||||
|
echo "$RELEASE_DATA"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "Uploading $BINARY to release $RELEASE_ID"
|
||||||
|
|
||||||
# Upload the binary
|
# Upload the binary
|
||||||
curl -X POST "${SERVER}/api/v1/repos/${REPO}/releases/${RELEASE_ID}/assets" \
|
curl -X POST "${SERVER}/api/v1/repos/${REPO}/releases/${RELEASE_ID}/assets" \
|
||||||
-H "Authorization: token ${TOKEN}" \
|
-H "Authorization: token ${TOKEN}" \
|
||||||
-F "attachment=@bin/${BINARY}" || true
|
-F "attachment=@bin/${BINARY}"
|
||||||
|
|||||||
Reference in New Issue
Block a user