Skip to content

Commit 77580bc

Browse files
authored
Merge pull request #20 from Bolado/api-version-workflow
API Version Update Workflow
2 parents d875831 + 23204b6 commit 77580bc

3 files changed

Lines changed: 50 additions & 2 deletions

File tree

.github/workflows/create-release.yml

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,3 +41,51 @@ jobs:
4141
./artifacts/microbot-launcher-mac-latest/*.dmg
4242
env:
4343
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
44+
45+
- name: Install jq and verify API secrets
46+
run: |
47+
set -euo pipefail
48+
sudo apt-get update
49+
sudo apt-get install -y jq
50+
if ! command -v jq >/dev/null 2>&1; then
51+
echo "::error::jq failed to install"; exit 1; fi
52+
# Verify required secrets are provided (non-empty)
53+
if [ -z "${{ secrets.API_EMAIL }}" ]; then
54+
echo "::error::Missing required secret: API_EMAIL"; exit 1; fi
55+
if [ -z "${{ secrets.API_PASSWORD }}" ]; then
56+
echo "::error::Missing required secret: API_PASSWORD"; exit 1; fi
57+
echo "jq installed and required secrets present"
58+
59+
- name: Get Auth Token (Launcher Version Update)
60+
id: auth
61+
run: |
62+
set -euo pipefail
63+
if ! command -v jq >/dev/null 2>&1; then
64+
echo "::error::jq not found"; exit 1; fi
65+
RESPONSE=$(curl -sS --fail \
66+
--connect-timeout 10 --max-time 30 \
67+
--retry 3 --retry-delay 2 --retry-all-errors \
68+
-X POST \
69+
-H "Content-Type: application/json" \
70+
-d "{\"email\":\"${{ secrets.API_EMAIL }}\",\"password\":\"${{ secrets.API_PASSWORD }}\"}" \
71+
https://microbot.cloud/api/auth/login || true)
72+
TOKEN=$(printf '%s' "$RESPONSE" | jq -er '.token // empty' 2>/dev/null || true)
73+
if [ -z "$TOKEN" ] || [ "$TOKEN" = "null" ]; then
74+
echo "::error::Failed to obtain auth token"; exit 1; fi
75+
echo "::add-mask::$TOKEN"
76+
echo "token=$TOKEN" >> $GITHUB_OUTPUT
77+
78+
- name: Update Launcher Version in API
79+
run: |
80+
set -euo pipefail
81+
VERSION=${{ steps.version.outputs.version }}
82+
echo "Updating launcher version to $VERSION via API"
83+
HTTP_CODE=$(curl -s -o response.json -w "%{http_code}" -X PUT \
84+
-H "Authorization: Bearer ${{ steps.auth.outputs.token }}" \
85+
-H "Content-Type: application/json" \
86+
-d "{\"version\":\"$VERSION\"}" \
87+
https://microbot.cloud/api/version/launcher)
88+
echo "API response (HTTP $HTTP_CODE):"; cat response.json || true
89+
if [ "$HTTP_CODE" -ge 200 ] && [ "$HTTP_CODE" -lt 300 ]; then
90+
echo "Launcher version updated successfully"; else
91+
echo "::error::Failed to update launcher version (HTTP $HTTP_CODE)"; exit 1; fi

main.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,7 @@ async function createWindow() {
184184
.children('script')
185185
.last()
186186
.replaceWith(
187-
'<script src="https://files.microbot.cloud/assets/microbot-launcher/renderer.js?version=3.1.8"></script>'
187+
`<script src="${filestorage}/assets/microbot-launcher/renderer.js?version=${packageJson.version}"></script>`
188188
);
189189
$('head')
190190
.children('link[rel="stylesheet"]')

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "microbot-launcher",
3-
"version": "3.1.8",
3+
"version": "3.1.9",
44
"description": "Launcher for the microbot client",
55
"main": "main.js",
66
"scripts": {

0 commit comments

Comments
 (0)