Skip to content

Commit 64bbce5

Browse files
committed
use JSON api
1 parent af0df40 commit 64bbce5

19 files changed

Lines changed: 375 additions & 468 deletions

File tree

.env

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
OPENSHOCK_API_DOMAIN=api.openshock.app
2-
OPENSHOCK_FW_CDN_DOMAIN=firmware.openshock.org
2+
OPENSHOCK_REPO_DOMAIN=repo.openshock.org
33
OPENSHOCK_FW_HOSTNAME=OpenShock
44
OPENSHOCK_FW_AP_PREFIX=OpenShock-
55
OPENSHOCK_URI_BUFFER_SIZE=256

.github/actions/cdn-bump-version/action.yml

Lines changed: 0 additions & 51 deletions
This file was deleted.

.github/actions/cdn-prepare/action.yml

Lines changed: 0 additions & 20 deletions
This file was deleted.

.github/actions/cdn-upload-firmware/action.yml

Lines changed: 0 additions & 68 deletions
This file was deleted.

.github/actions/cdn-upload-version-info/action.yml

Lines changed: 0 additions & 47 deletions
This file was deleted.
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
name: repo-publish-version
2+
description: Publishes firmware version metadata to the repository server
3+
inputs:
4+
repo-server-url:
5+
description: Repository server base URL
6+
required: true
7+
repo-admin-token:
8+
description: Admin authentication token
9+
required: true
10+
fw-version:
11+
description: Firmware semantic version
12+
required: true
13+
release-channel:
14+
description: Release channel (stable, beta, develop)
15+
required: true
16+
commit-hash:
17+
description: Git commit hash
18+
required: true
19+
release-url:
20+
description: GitHub release URL (optional)
21+
required: false
22+
default: ''
23+
24+
runs:
25+
using: composite
26+
steps:
27+
- name: Publish version metadata to repository server
28+
shell: bash
29+
run: |
30+
set -euo pipefail
31+
32+
REPO_URL="${{ inputs.repo-server-url }}"
33+
VERSION="${{ inputs.fw-version }}"
34+
RELEASE_URL="${{ inputs.release-url }}"
35+
36+
REQUEST_BODY=$(jq -n \
37+
--arg channel "${{ inputs.release-channel }}" \
38+
--arg commitHash "${{ inputs.commit-hash }}" \
39+
--arg releaseUrl "$RELEASE_URL" \
40+
'{
41+
"channel": $channel,
42+
"releaseDate": (now | strftime("%Y-%m-%dT%H:%M:%SZ")),
43+
"commitHash": $commitHash,
44+
"releaseUrl": (if $releaseUrl == "" then null else $releaseUrl end),
45+
"releaseNotes": []
46+
}')
47+
48+
echo "Publishing version $VERSION to repository server..."
49+
50+
HTTP_CODE=$(curl -s -o /tmp/repo-response.txt -w "%{http_code}" \
51+
-X PUT \
52+
-H "Content-Type: application/json" \
53+
-H "Authorization: ${{ inputs.repo-admin-token }}" \
54+
-d "$REQUEST_BODY" \
55+
"${REPO_URL}/v2/firmware/admin/versions/${VERSION}")
56+
57+
if [ "$HTTP_CODE" -ge 200 ] && [ "$HTTP_CODE" -lt 300 ]; then
58+
echo "Successfully published version $VERSION (HTTP $HTTP_CODE)"
59+
else
60+
echo "Failed to publish version $VERSION (HTTP $HTTP_CODE)"
61+
cat /tmp/repo-response.txt
62+
exit 1
63+
fi
Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
name: repo-upload-board
2+
description: Uploads firmware binaries for a single board to the repository server
3+
inputs:
4+
repo-server-url:
5+
description: Repository server base URL
6+
required: true
7+
repo-admin-token:
8+
description: Admin authentication token
9+
required: true
10+
fw-version:
11+
description: Firmware semantic version
12+
required: true
13+
board:
14+
description: Board name
15+
required: true
16+
17+
runs:
18+
using: composite
19+
steps:
20+
- name: Download static filesystem partition
21+
uses: actions/download-artifact@v4
22+
with:
23+
name: firmware_staticfs
24+
path: upload_staging
25+
26+
- name: Download firmware build
27+
uses: actions/download-artifact@v4
28+
with:
29+
name: firmware_build_${{ inputs.board }}
30+
path: upload_staging
31+
32+
- name: Download merged firmware binary
33+
uses: actions/download-artifact@v4
34+
with:
35+
name: firmware_merged_${{ inputs.board }}
36+
path: upload_staging
37+
38+
- name: Rename merged binary
39+
shell: bash
40+
run: |
41+
cd upload_staging
42+
if ls OpenShock_*.bin 1>/dev/null 2>&1; then
43+
mv OpenShock_*.bin firmware.bin
44+
fi
45+
46+
- name: Upload artifacts to repository server
47+
shell: bash
48+
run: |
49+
set -euo pipefail
50+
51+
REPO_URL="${{ inputs.repo-server-url }}"
52+
CURL_ARGS=(-s -w "\n%{http_code}" \
53+
-X PUT \
54+
-H "Authorization: ${{ inputs.repo-admin-token }}" \
55+
"${REPO_URL}/v2/firmware/admin/versions/${{ inputs.fw-version }}/boards/${{ inputs.board }}/upload")
56+
57+
# Add file fields based on what exists
58+
[ -f upload_staging/app.bin ] && CURL_ARGS+=(-F "app=@upload_staging/app.bin")
59+
[ -f upload_staging/staticfs.bin ] && CURL_ARGS+=(-F "staticfs=@upload_staging/staticfs.bin")
60+
[ -f upload_staging/firmware.bin ] && CURL_ARGS+=(-F "merged=@upload_staging/firmware.bin")
61+
[ -f upload_staging/bootloader.bin ] && CURL_ARGS+=(-F "bootloader=@upload_staging/bootloader.bin")
62+
[ -f upload_staging/partitions.bin ] && CURL_ARGS+=(-F "partitions=@upload_staging/partitions.bin")
63+
64+
RESPONSE=$(curl "${CURL_ARGS[@]}")
65+
HTTP_CODE=$(echo "$RESPONSE" | tail -1)
66+
BODY=$(echo "$RESPONSE" | sed '$d')
67+
68+
if [ "$HTTP_CODE" -ge 200 ] && [ "$HTTP_CODE" -lt 300 ]; then
69+
echo "Successfully uploaded artifacts for board ${{ inputs.board }} (HTTP $HTTP_CODE)"
70+
echo "$BODY" | jq . 2>/dev/null || echo "$BODY"
71+
else
72+
echo "Failed to upload artifacts for board ${{ inputs.board }} (HTTP $HTTP_CODE)"
73+
echo "$BODY"
74+
exit 1
75+
fi

0 commit comments

Comments
 (0)