github: submit SDKs to prod & dev (#3060)
* github: submit SDKs to prod & dev * github: increased limit of queried SDKs Co-authored-by: あく <alleteam@gmail.com>
This commit is contained in:
parent
4705812d24
commit
77d6c41914
54
.github/actions/submit_sdk/action.yml
vendored
Normal file
54
.github/actions/submit_sdk/action.yml
vendored
Normal file
@ -0,0 +1,54 @@
|
|||||||
|
name: Submit SDK to Catalog
|
||||||
|
author: hedger
|
||||||
|
description: |
|
||||||
|
This action checks if SDK exists in the catalog and if not, adds and/or publishes it.
|
||||||
|
|
||||||
|
inputs:
|
||||||
|
catalog-url:
|
||||||
|
description: The URL of the Catalog API
|
||||||
|
required: true
|
||||||
|
catalog-token:
|
||||||
|
description: The token to use to authenticate with the Catalog API
|
||||||
|
required: true
|
||||||
|
firmware-api:
|
||||||
|
description: Fimware's API version, major.minor
|
||||||
|
required: true
|
||||||
|
firmware-target:
|
||||||
|
description: Firmware's target, e.g. f7/f18
|
||||||
|
required: true
|
||||||
|
firmware-version:
|
||||||
|
description: Firmware's version, e.g. 0.13.37-rc3
|
||||||
|
required: true
|
||||||
|
|
||||||
|
runs:
|
||||||
|
using: composite
|
||||||
|
steps:
|
||||||
|
- name: Submit SDK
|
||||||
|
run: |
|
||||||
|
curl -sX 'GET' \
|
||||||
|
'${{ inputs.catalog-url }}/api/v0/0/sdk?length=500' \
|
||||||
|
-H 'Accept: application/json' > sdk_versions.json
|
||||||
|
if jq -r -e ".[] | select((.api == \"${{ inputs.firmware-api }}\") and .target == \"${{ inputs.firmware-target }}\")" sdk_versions.json > found_sdk.json ; then
|
||||||
|
echo "API version ${{ inputs.firmware-api }} already exists in catalog"
|
||||||
|
if [ $(jq -r -e ".released_at" found_sdk.json) != "null" ] ; then
|
||||||
|
echo "API version is already released"
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
if ! echo "${{ inputs.firmware-version }}" | grep -q "-rc" ; then
|
||||||
|
SDK_ID=$(jq -r ._id found_sdk.json)
|
||||||
|
echo "Marking SDK $SDK_ID as released"
|
||||||
|
curl -X 'POST' \
|
||||||
|
"${{ inputs.catalog-url }}/api/v0/0/sdk/${SDK_ID}/release" \
|
||||||
|
-H 'Accept: application/json' \
|
||||||
|
-H 'Authorization: Bearer ${{ inputs.catalog-token }}' \
|
||||||
|
-d ''
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
echo "API version ${{ inputs.firmware-api }} doesn't exist in catalog, adding"
|
||||||
|
curl -X 'POST' \
|
||||||
|
'${{ inputs.catalog-url }}/api/v0/0/sdk' \
|
||||||
|
-H 'Accept: application/json' \
|
||||||
|
-H 'Authorization: Bearer ${{ inputs.catalog-token }}' \
|
||||||
|
-H 'Content-Type: application/json' \
|
||||||
|
-d "{\"name\": \"${{ inputs.firmware-version }}\", \"target\": \"${{ inputs.firmware-target }}\", \"api\": \"${{ inputs.firmware-api }}\"}\"
|
||||||
|
fi
|
||||||
50
.github/workflows/build.yml
vendored
50
.github/workflows/build.yml
vendored
@ -57,8 +57,10 @@ jobs:
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
- name: 'Build the firmware and apps'
|
- name: 'Build the firmware and apps'
|
||||||
|
id: build-fw
|
||||||
run: |
|
run: |
|
||||||
./fbt TARGET_HW=$TARGET_HW $FBT_BUILD_TYPE copro_dist updater_package fap_dist
|
./fbt TARGET_HW=$TARGET_HW $FBT_BUILD_TYPE copro_dist updater_package fap_dist
|
||||||
|
echo "firmware_api=$(./fbt TARGET_HW=$TARGET_HW get_apiversion)" >> $GITHUB_OUTPUT
|
||||||
|
|
||||||
- name: 'Check for uncommitted changes'
|
- name: 'Check for uncommitted changes'
|
||||||
run: |
|
run: |
|
||||||
@ -144,34 +146,22 @@ jobs:
|
|||||||
- [☁️ Web/App updater](https://lab.flipper.net/?url=https://update.flipperzero.one/builds/firmware/${{steps.names.outputs.branch_name}}/flipper-z-${{steps.names.outputs.default_target}}-update-${{steps.names.outputs.suffix}}.tgz&channel=${{steps.names.outputs.branch_name}}&version=${{steps.names.outputs.commit_sha}})
|
- [☁️ Web/App updater](https://lab.flipper.net/?url=https://update.flipperzero.one/builds/firmware/${{steps.names.outputs.branch_name}}/flipper-z-${{steps.names.outputs.default_target}}-update-${{steps.names.outputs.suffix}}.tgz&channel=${{steps.names.outputs.branch_name}}&version=${{steps.names.outputs.commit_sha}})
|
||||||
edit-mode: replace
|
edit-mode: replace
|
||||||
|
|
||||||
- name: 'Check if API version exists'
|
- name: 'SDK submission to dev catalog'
|
||||||
if: ${{ steps.names.outputs.event_type == 'tag' && matrix.target == env.DEFAULT_TARGET }}
|
if: ${{ steps.names.outputs.event_type == 'tag' && matrix.target == env.DEFAULT_TARGET }}
|
||||||
run: |
|
uses: ./.github/actions/submit_sdk
|
||||||
FIRMWARE_API=$(./fbt TARGET_HW=$TARGET_HW get_apiversion)
|
with:
|
||||||
curl -sX 'GET' \
|
catalog-url: ${{ secrets.CATALOG_STAGING_URL }}
|
||||||
'${{ secrets.CATALOG_URL }}/api/v0/0/sdk?length=200' \
|
catalog-api-token: ${{ secrets.CATALOG_STAGING_API_TOKEN }}
|
||||||
-H 'Accept: application/json' > sdk_versions.json
|
firmware-api: ${{ steps.build-fw.outputs.firmware_api }}
|
||||||
if jq -r -e ".[] | select((.api == \"${FIRMWARE_API}\") and .target == \"f${TARGET_HW}\")" sdk_versions.json > found_sdk.json ; then
|
firwmare-target: ${{ matrix.target }}
|
||||||
echo "API version $FIRMWARE_API already exists in catalog"
|
firmware-version: ${{ steps.names.outputs.suffix }}
|
||||||
if [ $(jq -r -e ".released_at" found_sdk.json) != "null" ] ; then
|
|
||||||
echo "API version is already released"
|
- name: 'SDK submission to prod catalog'
|
||||||
exit 0
|
if: ${{ steps.names.outputs.event_type == 'tag' && matrix.target == env.DEFAULT_TARGET }}
|
||||||
fi
|
uses: ./.github/actions/submit_sdk
|
||||||
if ! echo "$SUFFIX" | grep -q "-rc" ; then
|
with:
|
||||||
SDK_ID=$(jq -r ._id found_sdk.json)
|
catalog-url: ${{ secrets.CATALOG_URL }}
|
||||||
echo "Marking SDK $SDK_ID as released"
|
catalog-api-token: ${{ secrets.CATALOG_API_TOKEN }}
|
||||||
curl -X 'POST' \
|
firmware-api: ${{ steps.build-fw.outputs.firmware_api }}
|
||||||
"${{ secrets.CATALOG_URL }}/api/v0/0/sdk/${SDK_ID}/release" \
|
firwmare-target: ${{ matrix.target }}
|
||||||
-H 'Accept: application/json' \
|
firmware-version: ${{ steps.names.outputs.suffix }}
|
||||||
-H 'Authorization: Bearer ${{ secrets.CATALOG_API_TOKEN }}' \
|
|
||||||
-d ''
|
|
||||||
fi
|
|
||||||
else
|
|
||||||
echo "API version $FIRMWARE_API doesn't exist in catalog, adding"
|
|
||||||
curl -X 'POST' \
|
|
||||||
'${{ secrets.CATALOG_URL }}/api/v0/0/sdk' \
|
|
||||||
-H 'Accept: application/json' \
|
|
||||||
-H 'Authorization: Bearer ${{ secrets.CATALOG_API_TOKEN }}' \
|
|
||||||
-H 'Content-Type: application/json' \
|
|
||||||
-d "{\"name\": \"${SUFFIX}\", \"target\": \"f${TARGET_HW}\", \"api\": \"${FIRMWARE_API}\"}\"
|
|
||||||
fi
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user