Compare commits
2 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 3ec52f2aea | |||
| 30f4ebbd6d |
@@ -67,31 +67,56 @@ 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: Upload Release Asset
|
- name: Create Release (first run only)
|
||||||
uses: gitea-github-actions/actions/gitea-release@main
|
run: |
|
||||||
with:
|
VERSION="${{ steps.version.outputs.VERSION }}"
|
||||||
files: bin/${{ env.BINARY_NAME }}
|
REPO="${{ gitea.repository }}"
|
||||||
draft: false
|
SERVER="${{ gitea.server_url }}"
|
||||||
prerelease: false
|
TOKEN="${{ secrets.GITEA_TOKEN }}"
|
||||||
allowUpdates: true
|
|
||||||
title: Release ${{ steps.version.outputs.VERSION }}
|
|
||||||
body: |
|
|
||||||
# SafelineAPI ${{ steps.version.outputs.VERSION }}
|
|
||||||
|
|
||||||
## Available Downloads
|
# Check if release exists
|
||||||
|
RESPONSE=$(curl -s -o /dev/null -w "%{http_code}" "${SERVER}/api/v1/repos/${REPO}/releases/tags/${VERSION}" \
|
||||||
|
-H "Authorization: token ${TOKEN}")
|
||||||
|
|
||||||
### Linux
|
if [ "$RESPONSE" = "404" ]; then
|
||||||
- **amd64**: safelineApi-linux-amd64
|
# Create release if it doesn't exist
|
||||||
- **ARM64**: safelineApi-linux-arm64
|
curl -X POST "${SERVER}/api/v1/repos/${REPO}/releases" \
|
||||||
- **ARMv7**: safelineApi-linux-armv7
|
-H "Authorization: token ${TOKEN}" \
|
||||||
- **386**: safelineApi-linux-386
|
-H "Content-Type: application/json" \
|
||||||
- **PowerPC 64LE**: safelineApi-linux-ppc64le
|
-d '{
|
||||||
|
"tag_name": "'${VERSION}'",
|
||||||
|
"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
|
||||||
|
|
||||||
### Windows
|
echo "Release checked/created"
|
||||||
- **amd64**: safelineApi-windows-amd64.exe
|
|
||||||
- **386**: safelineApi-windows-386.exe
|
|
||||||
|
|
||||||
Built at: ${{ github.event.head_commit.timestamp }}
|
- name: Upload Binary Asset
|
||||||
env:
|
run: |
|
||||||
GITEA_TOKEN: ${{ secrets.GITEA_TOKEN }}
|
VERSION="${{ steps.version.outputs.VERSION }}"
|
||||||
GITEA_SERVER: ${{ gitea.server_url }}
|
REPO="${{ gitea.repository }}"
|
||||||
|
SERVER="${{ gitea.server_url }}"
|
||||||
|
TOKEN="${{ secrets.GITEA_TOKEN }}"
|
||||||
|
BINARY="${{ env.BINARY_NAME }}"
|
||||||
|
|
||||||
|
# Get release data
|
||||||
|
RELEASE_DATA=$(curl -s "${SERVER}/api/v1/repos/${REPO}/releases/tags/${VERSION}" \
|
||||||
|
-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
|
||||||
|
curl -X POST "${SERVER}/api/v1/repos/${REPO}/releases/${RELEASE_ID}/assets" \
|
||||||
|
-H "Authorization: token ${TOKEN}" \
|
||||||
|
-F "attachment=@bin/${BINARY}"
|
||||||
|
|||||||
Reference in New Issue
Block a user