CI: Fix git.mk & post a quick flash link on PR builds (#670)
* CI: Fix git.mk & post a quick flash link on PR builds * Makefile: optimize shell invocation in git helper, conditional dependency load. * Github: better variable naming Co-authored-by: Aleksandr Kutuzov <alleteam@gmail.com>
This commit is contained in:
parent
dd8a90957f
commit
08f7a290a4
66
.github/workflows/build.yml
vendored
66
.github/workflows/build.yml
vendored
@ -32,6 +32,7 @@ jobs:
|
|||||||
with:
|
with:
|
||||||
fetch-depth: 0
|
fetch-depth: 0
|
||||||
submodules: true
|
submodules: true
|
||||||
|
ref: ${{ github.event.pull_request.head.sha }}
|
||||||
|
|
||||||
- name: 'Docker cache'
|
- name: 'Docker cache'
|
||||||
uses: satackey/action-docker-layer-caching@v0.0.11
|
uses: satackey/action-docker-layer-caching@v0.0.11
|
||||||
@ -49,21 +50,26 @@ jobs:
|
|||||||
mkdir artifacts
|
mkdir artifacts
|
||||||
|
|
||||||
- name: 'Generate suffix and folder name'
|
- name: 'Generate suffix and folder name'
|
||||||
|
id: names
|
||||||
run: |
|
run: |
|
||||||
REF=${{ github.ref }}
|
REF=${{ github.ref }}
|
||||||
if [[ ${{ github.event_name }} == 'pull_request' ]]; then
|
if [[ ${{ github.event_name }} == 'pull_request' ]]; then
|
||||||
REF=${{ github.head_ref }}
|
REF=${{ github.head_ref }}
|
||||||
fi
|
fi
|
||||||
REF=${REF##*/}
|
BRANCH_OR_TAG=${REF##*/}
|
||||||
|
SHA=$(git rev-parse --short HEAD)
|
||||||
|
|
||||||
if [[ "${{ github.ref }}" == "refs/tags/"* ]]; then
|
if [[ "${{ github.ref }}" == "refs/tags/"* ]]; then
|
||||||
SUFFIX=${REF}
|
SUFFIX=${BRANCH_OR_TAG}
|
||||||
else
|
else
|
||||||
SUFFIX=${REF}-$(date +'%d%m%Y')-$(echo ${GITHUB_SHA} | cut -c1-7)
|
SUFFIX=${BRANCH_OR_TAG}-$(date +'%d%m%Y')-${SHA}
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo "SUFFIX=${SUFFIX}" >> $GITHUB_ENV
|
echo "WORKFLOW_BRANCH_OR_TAG=${BRANCH_OR_TAG}" >> $GITHUB_ENV
|
||||||
echo "ARTIFACTS_PATH=${REF}" >> $GITHUB_ENV
|
echo "::set-output name=artifacts-path::${BRANCH_OR_TAG}"
|
||||||
|
echo "::set-output name=suffix::${SUFFIX}"
|
||||||
|
echo "::set-output name=short-hash::${SHA}"
|
||||||
|
echo "::set-output name=latest-target::${TARGETS[${#TARGETS[@]}-1]}"
|
||||||
|
|
||||||
- name: 'Build bootloader in docker'
|
- name: 'Build bootloader in docker'
|
||||||
uses: ./.github/actions/docker
|
uses: ./.github/actions/docker
|
||||||
@ -104,17 +110,17 @@ jobs:
|
|||||||
for TARGET in ${TARGETS}
|
for TARGET in ${TARGETS}
|
||||||
do
|
do
|
||||||
mv bootloader/.obj/${TARGET}/bootloader.dfu \
|
mv bootloader/.obj/${TARGET}/bootloader.dfu \
|
||||||
artifacts/flipper-z-${TARGET}-bootloader-${SUFFIX}.dfu
|
artifacts/flipper-z-${TARGET}-bootloader-${{steps.names.outputs.suffix}}.dfu
|
||||||
mv bootloader/.obj/${TARGET}/bootloader.bin \
|
mv bootloader/.obj/${TARGET}/bootloader.bin \
|
||||||
artifacts/flipper-z-${TARGET}-bootloader-${SUFFIX}.bin
|
artifacts/flipper-z-${TARGET}-bootloader-${{steps.names.outputs.suffix}}.bin
|
||||||
mv bootloader/.obj/${TARGET}/bootloader.elf \
|
mv bootloader/.obj/${TARGET}/bootloader.elf \
|
||||||
artifacts/flipper-z-${TARGET}-bootloader-${SUFFIX}.elf
|
artifacts/flipper-z-${TARGET}-bootloader-${{steps.names.outputs.suffix}}.elf
|
||||||
mv firmware/.obj/${TARGET}/firmware.dfu \
|
mv firmware/.obj/${TARGET}/firmware.dfu \
|
||||||
artifacts/flipper-z-${TARGET}-firmware-${SUFFIX}.dfu
|
artifacts/flipper-z-${TARGET}-firmware-${{steps.names.outputs.suffix}}.dfu
|
||||||
mv firmware/.obj/${TARGET}/firmware.bin \
|
mv firmware/.obj/${TARGET}/firmware.bin \
|
||||||
artifacts/flipper-z-${TARGET}-firmware-${SUFFIX}.bin
|
artifacts/flipper-z-${TARGET}-firmware-${{steps.names.outputs.suffix}}.bin
|
||||||
mv firmware/.obj/${TARGET}/firmware.elf \
|
mv firmware/.obj/${TARGET}/firmware.elf \
|
||||||
artifacts/flipper-z-${TARGET}-firmware-${SUFFIX}.elf
|
artifacts/flipper-z-${TARGET}-firmware-${{steps.names.outputs.suffix}}.elf
|
||||||
done
|
done
|
||||||
|
|
||||||
- name: 'Generate full dfu file'
|
- name: 'Generate full dfu file'
|
||||||
@ -126,7 +132,7 @@ jobs:
|
|||||||
do
|
do
|
||||||
hex2dfu \
|
hex2dfu \
|
||||||
-i firmware/.obj/${TARGET}/full.hex \
|
-i firmware/.obj/${TARGET}/full.hex \
|
||||||
-o artifacts/flipper-z-${TARGET}-full-${SUFFIX}.dfu \
|
-o artifacts/flipper-z-${TARGET}-full-${{steps.names.outputs.suffix}}.dfu \
|
||||||
-l "Flipper Zero $(echo $TARGET | tr a-z A-Z)"
|
-l "Flipper Zero $(echo $TARGET | tr a-z A-Z)"
|
||||||
done
|
done
|
||||||
|
|
||||||
@ -136,8 +142,8 @@ jobs:
|
|||||||
for TARGET in ${TARGETS}
|
for TARGET in ${TARGETS}
|
||||||
do
|
do
|
||||||
cp \
|
cp \
|
||||||
artifacts/flipper-z-${TARGET}-bootloader-${SUFFIX}.bin \
|
artifacts/flipper-z-${TARGET}-bootloader-${{steps.names.outputs.suffix}}.bin \
|
||||||
artifacts/flipper-z-${TARGET}-full-${SUFFIX}.bin
|
artifacts/flipper-z-${TARGET}-full-${{steps.names.outputs.suffix}}.bin
|
||||||
done
|
done
|
||||||
|
|
||||||
- name: 'Full flash asssembly: bootloader padding'
|
- name: 'Full flash asssembly: bootloader padding'
|
||||||
@ -145,7 +151,7 @@ jobs:
|
|||||||
run: |
|
run: |
|
||||||
for TARGET in ${TARGETS}
|
for TARGET in ${TARGETS}
|
||||||
do
|
do
|
||||||
truncate -s 32768 artifacts/flipper-z-${TARGET}-full-${SUFFIX}.bin
|
truncate -s 32768 artifacts/flipper-z-${TARGET}-full-${{steps.names.outputs.suffix}}.bin
|
||||||
done
|
done
|
||||||
|
|
||||||
- name: 'Full flash asssembly: append firmware'
|
- name: 'Full flash asssembly: append firmware'
|
||||||
@ -154,8 +160,8 @@ jobs:
|
|||||||
for TARGET in ${TARGETS}
|
for TARGET in ${TARGETS}
|
||||||
do
|
do
|
||||||
cat \
|
cat \
|
||||||
artifacts/flipper-z-${TARGET}-firmware-${SUFFIX}.bin \
|
artifacts/flipper-z-${TARGET}-firmware-${{steps.names.outputs.suffix}}.bin \
|
||||||
>> artifacts/flipper-z-${TARGET}-full-${SUFFIX}.bin
|
>> artifacts/flipper-z-${TARGET}-full-${{steps.names.outputs.suffix}}.bin
|
||||||
done
|
done
|
||||||
|
|
||||||
- name: 'Bundle core2 firmware'
|
- name: 'Bundle core2 firmware'
|
||||||
@ -169,17 +175,17 @@ jobs:
|
|||||||
lib/STM32CubeWB/Projects/STM32WB_Copro_Wireless_Binaries/STM32WB5x/stm32wb5x_FUS_fw_for_fus_0_5_3.bin \
|
lib/STM32CubeWB/Projects/STM32WB_Copro_Wireless_Binaries/STM32WB5x/stm32wb5x_FUS_fw_for_fus_0_5_3.bin \
|
||||||
lib/STM32CubeWB/Projects/STM32WB_Copro_Wireless_Binaries/STM32WB5x/stm32wb5x_BLE_Stack_full_fw.bin \
|
lib/STM32CubeWB/Projects/STM32WB_Copro_Wireless_Binaries/STM32WB5x/stm32wb5x_BLE_Stack_full_fw.bin \
|
||||||
core2_firmware
|
core2_firmware
|
||||||
tar czpf artifacts/flipper-z-any-core2_firmware-${SUFFIX}.tgz core2_firmware
|
tar czpf artifacts/flipper-z-any-core2_firmware-${{steps.names.outputs.suffix}}.tgz core2_firmware
|
||||||
|
|
||||||
- name: 'Bundle scripts'
|
- name: 'Bundle scripts'
|
||||||
if: ${{ !github.event.pull_request.head.repo.fork }}
|
if: ${{ !github.event.pull_request.head.repo.fork }}
|
||||||
run: |
|
run: |
|
||||||
tar czpf artifacts/flipper-z-any-scripts-${SUFFIX}.tgz scripts
|
tar czpf artifacts/flipper-z-any-scripts-${{steps.names.outputs.suffix}}.tgz scripts
|
||||||
|
|
||||||
- name: 'Bundle resources'
|
- name: 'Bundle resources'
|
||||||
if: ${{ !github.event.pull_request.head.repo.fork }}
|
if: ${{ !github.event.pull_request.head.repo.fork }}
|
||||||
run: |
|
run: |
|
||||||
tar czpf artifacts/flipper-z-any-resources-${SUFFIX}.tgz -C assets resources
|
tar czpf artifacts/flipper-z-any-resources-${{steps.names.outputs.suffix}}.tgz -C assets resources
|
||||||
|
|
||||||
- name: 'Upload artifacts to update server'
|
- name: 'Upload artifacts to update server'
|
||||||
if: ${{ !github.event.pull_request.head.repo.fork }}
|
if: ${{ !github.event.pull_request.head.repo.fork }}
|
||||||
@ -187,7 +193,7 @@ jobs:
|
|||||||
with:
|
with:
|
||||||
switches: -avzP --delete
|
switches: -avzP --delete
|
||||||
path: artifacts/
|
path: artifacts/
|
||||||
remote_path: "${{ secrets.RSYNC_DEPLOY_BASE_PATH }}${ARTIFACTS_PATH}/"
|
remote_path: "${{ secrets.RSYNC_DEPLOY_BASE_PATH }}${{steps.names.outputs.artifacts-path}}/"
|
||||||
remote_host: ${{ secrets.RSYNC_DEPLOY_HOST }}
|
remote_host: ${{ secrets.RSYNC_DEPLOY_HOST }}
|
||||||
remote_port: ${{ secrets.RSYNC_DEPLOY_PORT }}
|
remote_port: ${{ secrets.RSYNC_DEPLOY_PORT }}
|
||||||
remote_user: ${{ secrets.RSYNC_DEPLOY_USER }}
|
remote_user: ${{ secrets.RSYNC_DEPLOY_USER }}
|
||||||
@ -199,3 +205,21 @@ jobs:
|
|||||||
with:
|
with:
|
||||||
args: -X POST -F 'key=${{ secrets.REINDEX_KEY }}' ${{ secrets.REINDEX_URL }}
|
args: -X POST -F 'key=${{ secrets.REINDEX_KEY }}' ${{ secrets.REINDEX_URL }}
|
||||||
|
|
||||||
|
- name: Find Previous Comment
|
||||||
|
if: ${{ !github.event.pull_request.head.repo.fork && github.event.pull_request }}
|
||||||
|
uses: peter-evans/find-comment@v1
|
||||||
|
id: fc
|
||||||
|
with:
|
||||||
|
issue-number: ${{ github.event.pull_request.number }}
|
||||||
|
comment-author: 'github-actions[bot]'
|
||||||
|
body-includes: 'to flash the'
|
||||||
|
|
||||||
|
- name: Create or update comment
|
||||||
|
if: ${{ !github.event.pull_request.head.repo.fork && github.event.pull_request}}
|
||||||
|
uses: peter-evans/create-or-update-comment@v1
|
||||||
|
with:
|
||||||
|
comment-id: ${{ steps.fc.outputs.comment-id }}
|
||||||
|
issue-number: ${{ github.event.pull_request.number }}
|
||||||
|
body: |
|
||||||
|
[Click here](https://update.flipperzero.one/?url=https://update.flipperzero.one/builds/firmware/${{steps.names.outputs.artifacts-path}}/flipper-z-${{steps.names.outputs.latest-target}}-full-${{steps.names.outputs.suffix}}.dfu&channel=${{steps.names.outputs.artifacts-path}}&version=${{steps.names.outputs.short-hash}}) to flash the `${{steps.names.outputs.short-hash}}` version of this branch via WebUSB.
|
||||||
|
edit-mode: replace
|
||||||
|
6
.github/workflows/lint_c.yml
vendored
6
.github/workflows/lint_c.yml
vendored
@ -43,19 +43,19 @@ jobs:
|
|||||||
- name: 'Build docker image'
|
- name: 'Build docker image'
|
||||||
uses: ./.github/actions/docker
|
uses: ./.github/actions/docker
|
||||||
|
|
||||||
- name: 'Check syntax'
|
- name: 'Check code formatting'
|
||||||
id: syntax_check
|
id: syntax_check
|
||||||
uses: ./.github/actions/docker
|
uses: ./.github/actions/docker
|
||||||
with:
|
with:
|
||||||
run: SET_GH_OUTPUT=1 /syntax_check.sh
|
run: SET_GH_OUTPUT=1 /syntax_check.sh
|
||||||
|
|
||||||
- name: Report syntax errors
|
- name: Report code formatting errors
|
||||||
if: failure() && steps.syntax_check.outputs.errors && github.event.pull_request
|
if: failure() && steps.syntax_check.outputs.errors && github.event.pull_request
|
||||||
uses: peter-evans/create-or-update-comment@v1
|
uses: peter-evans/create-or-update-comment@v1
|
||||||
with:
|
with:
|
||||||
issue-number: ${{ github.event.pull_request.number }}
|
issue-number: ${{ github.event.pull_request.number }}
|
||||||
body: |
|
body: |
|
||||||
Please fix following syntax errors:
|
Please fix following code formatting errors:
|
||||||
```
|
```
|
||||||
${{ steps.syntax_check.outputs.errors }}
|
${{ steps.syntax_check.outputs.errors }}
|
||||||
```
|
```
|
||||||
|
20
make/git.mk
20
make/git.mk
@ -1,9 +1,13 @@
|
|||||||
GIT_COMMIT = $(shell git describe --always --exclude '*' || echo 'unknown')
|
GIT_COMMIT := $(shell git rev-parse --short HEAD || echo 'unknown')
|
||||||
GIT_BRANCH = $(shell git rev-parse --abbrev-ref HEAD || echo 'unknown')
|
GIT_BRANCH := $(shell echo $${WORKFLOW_BRANCH_OR_TAG-$$(git rev-parse --abbrev-ref HEAD || echo 'unknown')})
|
||||||
GIT_BRANCH_NUM = $(shell git rev-list --count $(GIT_BRANCH) || echo 'nan')
|
GIT_BRANCH_NUM := $(shell git rev-list --count HEAD || echo 'nan')
|
||||||
BUILD_DATE = $(shell date '+%d-%m-%Y' || echo 'unknown')
|
BUILD_DATE := $(shell date '+%d-%m-%Y' || echo 'unknown')
|
||||||
VERSION = $(shell git describe --tags --abbrev=0 || echo 'unknown')
|
VERSION := $(shell git describe --tags --abbrev=0 --exact-match || echo 'unknown')
|
||||||
|
|
||||||
CFLAGS += -DGIT_COMMIT="\"$(GIT_COMMIT)\"" -DGIT_BRANCH="\"$(GIT_BRANCH)\"" -DGIT_BRANCH_NUM="\"$(GIT_BRANCH_NUM)\""
|
|
||||||
CFLAGS += -DBUILD_DATE="\"$(BUILD_DATE)\"" -DTARGET="\"$(TARGET)\"" -DVERSION="\"$(VERSION)\""
|
|
||||||
|
|
||||||
|
CFLAGS += \
|
||||||
|
-DGIT_COMMIT="\"$(GIT_COMMIT)\"" \
|
||||||
|
-DGIT_BRANCH="\"$(GIT_BRANCH)\"" \
|
||||||
|
-DGIT_BRANCH_NUM="\"$(GIT_BRANCH_NUM)\"" \
|
||||||
|
-DBUILD_DATE="\"$(BUILD_DATE)\"" \
|
||||||
|
-DTARGET="\"$(TARGET)\"" \
|
||||||
|
-DVERSION="\"$(VERSION)\""
|
||||||
|
@ -127,4 +127,6 @@ generate_cscope_db:
|
|||||||
@rm -rf $(OBJ_DIR)/source.list $(OBJ_DIR)/source.list.p
|
@rm -rf $(OBJ_DIR)/source.list $(OBJ_DIR)/source.list.p
|
||||||
|
|
||||||
|
|
||||||
|
ifneq ("$(wildcard $(OBJ_DIR)/*.d)","")
|
||||||
-include $(DEPS)
|
-include $(DEPS)
|
||||||
|
endif
|
||||||
|
Loading…
Reference in New Issue
Block a user