ci: unify workflows - split build per component, single tag-triggered pipeline
CI / server-core-test (push) Failing after 4s
CI / device-agent-test (push) Failing after 4s
CI / dashboard-test (push) Failing after 4s
CI / build-docs (push) Failing after 9s
CI / build-server-core (push) Has been skipped
CI / build-device-agent (push) Has been skipped
CI / build-dashboard (push) Has been skipped
CI / release (push) Has been skipped
CI / server-core-test (push) Failing after 4s
CI / device-agent-test (push) Failing after 4s
CI / dashboard-test (push) Failing after 4s
CI / build-docs (push) Failing after 9s
CI / build-server-core (push) Has been skipped
CI / build-device-agent (push) Has been skipped
CI / build-dashboard (push) Has been skipped
CI / release (push) Has been skipped
This commit is contained in:
@@ -0,0 +1,122 @@
|
||||
name: Release
|
||||
|
||||
on:
|
||||
workflow_call:
|
||||
inputs:
|
||||
prerelease:
|
||||
description: 'Mark as prerelease'
|
||||
required: false
|
||||
type: boolean
|
||||
default: false
|
||||
|
||||
permissions:
|
||||
contents: write
|
||||
|
||||
jobs:
|
||||
release:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
with:
|
||||
fetch-depth: 0
|
||||
|
||||
- name: Download all artifacts
|
||||
uses: actions/download-artifact@v4
|
||||
with:
|
||||
path: ./artifacts
|
||||
|
||||
- name: Generate latest.json
|
||||
run: |
|
||||
VERSION="${{ gitea.ref_name }}"
|
||||
RELEASE_DATE="$(date -u +'%Y-%m-%dT%H:%M:%SZ')"
|
||||
REPO="${{ gitea.repository }}"
|
||||
SERVER="${{ gitea.server_url }}"
|
||||
cat > latest.json << ENDJSON
|
||||
{
|
||||
"version": "$VERSION",
|
||||
"release_date": "$RELEASE_DATE",
|
||||
"download_urls": {
|
||||
"server-core": "${SERVER}/${REPO}/releases/download/${VERSION}/server-core-linux-amd64",
|
||||
"device-agent-linux-amd64": "${SERVER}/${REPO}/releases/download/${VERSION}/nexus-device-agent-linux-amd64",
|
||||
"device-agent-linux-arm64": "${SERVER}/${REPO}/releases/download/${VERSION}/nexus-device-agent-linux-arm64",
|
||||
"device-agent-windows-amd64": "${SERVER}/${REPO}/releases/download/${VERSION}/nexus-device-agent-windows-amd64.exe",
|
||||
"dashboard-ui": "${SERVER}/${REPO}/releases/download/${VERSION}/dashboard-ui-dist.tar.gz"
|
||||
}
|
||||
}
|
||||
ENDJSON
|
||||
|
||||
- name: Create Release and upload assets
|
||||
env:
|
||||
TOKEN: ${{ secrets.BUILD_TOKEN }}
|
||||
run: |
|
||||
REPO="${{ gitea.repository }}"
|
||||
TAG="${{ gitea.ref_name }}"
|
||||
API="${{ gitea.server_url }}/api/v1"
|
||||
|
||||
# Delete existing release if present
|
||||
EXISTING_ID=$(curl -s -H "Authorization: token $TOKEN" "$API/repos/$REPO/releases/tags/$TAG" | grep -o '"id":[0-9]*' | head -n 1 | cut -d':' -f2 || true)
|
||||
if [ -n "$EXISTING_ID" ] && [ "$EXISTING_ID" != "null" ]; then
|
||||
echo "Deleting existing release $EXISTING_ID..."
|
||||
curl -s -X DELETE -H "Authorization: token $TOKEN" "$API/repos/$REPO/releases/$EXISTING_ID"
|
||||
fi
|
||||
|
||||
# Create release
|
||||
JSON_BODY=$(printf '{"tag_name":"%s","name":"%s","body":"Release %s","draft":false,"prerelease":%s}' "$TAG" "$TAG" "$TAG" "${{ inputs.prerelease }}")
|
||||
RELEASE_RESP=$(curl -s -X POST \
|
||||
-H "Authorization: token $TOKEN" \
|
||||
-H "Content-Type: application/json" \
|
||||
-d "$JSON_BODY" \
|
||||
"$API/repos/$REPO/releases")
|
||||
|
||||
RELEASE_ID=$(echo "$RELEASE_RESP" | grep -o '"id":[0-9]*' | head -n 1 | cut -d':' -f2 || true)
|
||||
if [ -z "$RELEASE_ID" ] || [ "$RELEASE_ID" = "null" ]; then
|
||||
echo "Failed to create release. Response: $RELEASE_RESP"
|
||||
exit 1
|
||||
fi
|
||||
echo "Release ID: $RELEASE_ID"
|
||||
|
||||
# Upload assets
|
||||
upload_asset() {
|
||||
local file="$1"
|
||||
local name="$2"
|
||||
if [ -f "$file" ]; then
|
||||
echo "Uploading $name..."
|
||||
curl -s -X POST \
|
||||
-H "Authorization: token $TOKEN" \
|
||||
-F "attachment=@$file" \
|
||||
"$API/repos/$REPO/releases/$RELEASE_ID/assets?name=$name"
|
||||
fi
|
||||
}
|
||||
|
||||
# Server Core
|
||||
upload_asset "artifacts/server-core-linux-amd64/server-core" "server-core-linux-amd64"
|
||||
|
||||
# Device Agent (all platforms)
|
||||
for platform in linux-amd64 linux-arm64 windows-amd64; do
|
||||
EXT=""
|
||||
if [ "$platform" = "windows-amd64" ]; then EXT=".exe"; fi
|
||||
upload_asset "artifacts/nexus-device-agent-${platform}/nexus-device-agent-${platform}${EXT}" "nexus-device-agent-${platform}${EXT}"
|
||||
done
|
||||
|
||||
# Dashboard UI tar.gz
|
||||
if [ -d "artifacts/dashboard-ui-dist/dist" ]; then
|
||||
cd artifacts/dashboard-ui-dist
|
||||
tar -czf ../../dashboard-ui-dist.tar.gz dist/
|
||||
cd ../..
|
||||
upload_asset "dashboard-ui-dist.tar.gz" "dashboard-ui-dist.tar.gz"
|
||||
fi
|
||||
|
||||
# Docs tar.gz
|
||||
if [ -d "artifacts/docs-dist" ]; then
|
||||
cd artifacts/docs-dist
|
||||
tar -czf ../../docs-dist.tar.gz ./
|
||||
cd ../..
|
||||
upload_asset "docs-dist.tar.gz" "docs-dist.tar.gz"
|
||||
fi
|
||||
|
||||
# latest.json
|
||||
upload_asset "latest.json" "latest.json"
|
||||
|
||||
- name: Cleanup
|
||||
if: always()
|
||||
run: rm -rf artifacts/ latest.json dashboard-ui-dist.tar.gz docs-dist.tar.gz
|
||||
Reference in New Issue
Block a user