Skip to content

Commit 01b032e

Browse files
committed
add upload artifacts and release assets to ci
1 parent 7216055 commit 01b032e

File tree

2 files changed

+55
-28
lines changed

2 files changed

+55
-28
lines changed

.github/workflows/githubci.yml

Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -69,13 +69,28 @@ jobs:
6969
echo `echo $HOME/opt/xPacks/@xpack-dev-tools/arm-none-eabi-gcc/*/.content/bin` >> $GITHUB_PATH
7070
7171
- name: Build
72-
run: make BOARD=${{ matrix.board }}
72+
run: |
73+
make BOARD=${{ matrix.board }} all
74+
make BOARD=${{ matrix.board }} copy-artifact
7375
76+
- uses: actions/upload-artifact@v2
77+
with:
78+
name: ${{ matrix.board }}
79+
path: _bin/${{ matrix.board }}
80+
81+
- name: Creat Release Asset
82+
if: ${{ github.event_name == 'release' }}
83+
run: zip -jr ${{ matrix.board }}_bootloader-${{ github.event.release.tag_name }}.zip _bin/${{ matrix.board }}
84+
7485
- name: Upload Release Asset
75-
if: github.event_name == 'release' && (github.event.action == 'published' || github.event.action == 'rerequested')
76-
working-directory: tools
86+
id: upload-release-asset
87+
uses: actions/upload-release-asset@v1
7788
env:
78-
UPLOAD_URL: ${{ github.event.release.upload_url }}
79-
ADABOT_GITHUB_ACCESS_TOKEN: ${{ secrets.GITHUB_TOKEN }}
80-
run: "[ -z \"$ADABOT_GITHUB_ACCESS_TOKEN\" ] || python3 -u upload_release_files.py"
89+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
90+
if: ${{ github.event_name == 'release' }}
91+
with:
92+
upload_url: ${{ github.event.release.upload_url }}
93+
asset_path: ${{ matrix.board }}_bootloader-${{ github.event.release.tag_name }}.zip
94+
asset_name: ${{ matrix.board }}_bootloader-${{ github.event.release.tag_name }}.zip
95+
asset_content_type: application/zip
8196

Makefile

Lines changed: 34 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,10 @@ GIT_VERSION := $(shell git describe --dirty --always --tags)
2828
GIT_SUBMODULE_VERSIONS := $(shell git submodule status | cut -d" " -f3,4 | paste -s -d" " -)
2929

3030
# compiled file name
31-
OUT_FILE = $(BOARD)_bootloader-$(GIT_VERSION)
31+
OUT_NAME = $(BOARD)_bootloader-$(GIT_VERSION)
3232

3333
# merged file = compiled + sd
34-
MERGED_FILE = $(OUT_FILE)_$(SD_NAME)_$(SD_VERSION)
34+
MERGED_FILE = $(OUT_NAME)_$(SD_NAME)_$(SD_VERSION)
3535

3636
#------------------------------------------------------------------------------
3737
# Tool configure
@@ -46,6 +46,16 @@ OBJCOPY = $(CROSS_COMPILE)objcopy
4646
SIZE = $(CROSS_COMPILE)size
4747
GDB = $(CROSS_COMPILE)gdb
4848

49+
# Set make directory command, Windows tries to create a directory named "-p" if that flag is there.
50+
ifneq ($(OS), Windows_NT)
51+
MKDIR = mkdir -p
52+
else
53+
MKDIR = mkdir
54+
endif
55+
56+
RM = rm -rf
57+
CP = cp
58+
4959
# Flasher utility options
5060
NRFUTIL = adafruit-nrfutil
5161
NRFJPROG = nrfjprog
@@ -66,15 +76,6 @@ else
6676
$(error Unsupported flash utility: "$(FLASHER)")
6777
endif
6878

69-
# Set make directory command, Windows tries to create a directory named "-p" if that flag is there.
70-
ifneq ($(OS), Windows_NT)
71-
MK = mkdir -p
72-
else
73-
MK = mkdir
74-
endif
75-
76-
RM = rm -rf
77-
7879
# auto-detect BMP on macOS, otherwise have to specify
7980
BMP_PORT ?= $(shell ls -1 /dev/cu.usbmodem????????1 | head -1)
8081
GDB_BMP = $(GDB) -ex 'target extended-remote $(BMP_PORT)' -ex 'monitor swdp_scan' -ex 'attach 1'
@@ -93,6 +94,7 @@ endif
9394

9495
# Build directory
9596
BUILD = _build/build-$(BOARD)
97+
BIN = _bin/$(BOARD)
9698

9799
# Board specific
98100
-include src/boards/$(BOARD)/board.mk
@@ -334,7 +336,7 @@ INC_PATHS = $(addprefix -I,$(IPATH))
334336
.PHONY: all clean flash dfu-flash sd gdbflash gdb
335337

336338
# default target to build
337-
all: $(BUILD)/$(OUT_FILE).out $(BUILD)/$(OUT_FILE)-nosd.hex $(BUILD)/$(OUT_FILE)-nosd.uf2 $(BUILD)/$(MERGED_FILE).hex $(BUILD)/$(MERGED_FILE).zip
339+
all: $(BUILD)/$(OUT_NAME).out $(BUILD)/$(OUT_NAME)_nosd.hex $(BUILD)/update-$(OUT_NAME)_nosd.uf2 $(BUILD)/$(MERGED_FILE).hex $(BUILD)/$(MERGED_FILE).zip
338340

339341
# Print out the value of a make variable.
340342
# https://stackoverflow.com/questions/16467718/how-to-print-out-a-variable-in-makefile
@@ -345,10 +347,11 @@ print-%:
345347

346348
# Create build directories
347349
$(BUILD):
348-
@$(MK) "$@"
350+
@$(MKDIR) "$@"
349351

350352
clean:
351353
@$(RM) $(BUILD)
354+
@$(RM) $(BIN)
352355

353356
# Create objects from C SRC files
354357
$(BUILD)/%.o: %.c
@@ -361,37 +364,46 @@ $(BUILD)/%.o: %.S
361364
@$(CC) -x assembler-with-cpp $(ASFLAGS) $(INC_PATHS) -c -o $@ $<
362365

363366
# Link
364-
$(BUILD)/$(OUT_FILE).out: $(BUILD) $(OBJECTS)
367+
$(BUILD)/$(OUT_NAME).out: $(BUILD) $(OBJECTS)
365368
@echo LD $(notdir $@)
366369
@$(CC) -o $@ $(LDFLAGS) $(OBJECTS) -Wl,--start-group $(LIBS) -Wl,--end-group
367370
@$(SIZE) $@
368371

369372
#------------------- Binary generator -------------------
370373

371374
# Create hex file (no sd, no mbr)
372-
$(BUILD)/$(OUT_FILE).hex: $(BUILD)/$(OUT_FILE).out
375+
$(BUILD)/$(OUT_NAME).hex: $(BUILD)/$(OUT_NAME).out
373376
@echo Create $(notdir $@)
374377
@$(OBJCOPY) -O ihex $< $@
375378

376379
# Hex file with mbr (still no SD)
377-
$(BUILD)/$(OUT_FILE)-nosd.hex: $(BUILD)/$(OUT_FILE).hex
380+
$(BUILD)/$(OUT_NAME)_nosd.hex: $(BUILD)/$(OUT_NAME).hex
378381
@echo Create $(notdir $@)
379382
@python3 tools/hexmerge.py --overlap=replace -o $@ $< $(MBR_HEX)
380383

381-
# Bootolader only uf2
382-
$(BUILD)/$(OUT_FILE)-nosd.uf2: $(BUILD)/$(OUT_FILE)-nosd.hex
384+
# Bootolader self-update uf2
385+
$(BUILD)/update-$(OUT_NAME)_nosd.uf2: $(BUILD)/$(OUT_NAME)_nosd.hex
383386
@echo Create $(notdir $@)
384387
@python3 lib/uf2/utils/uf2conv.py -f 0xd663823c -c -o $@ $^
385388

386389
# merge bootloader and sd hex together
387-
$(BUILD)/$(MERGED_FILE).hex: $(BUILD)/$(OUT_FILE).hex
390+
$(BUILD)/$(MERGED_FILE).hex: $(BUILD)/$(OUT_NAME).hex
388391
@echo Create $(notdir $@)
389392
@python3 tools/hexmerge.py -o $@ $< $(SD_HEX)
390393

391394
# Create pkg zip file for bootloader+SD combo to use with DFU CDC
392-
$(BUILD)/$(MERGED_FILE).zip: $(BUILD)/$(OUT_FILE).hex
395+
$(BUILD)/$(MERGED_FILE).zip: $(BUILD)/$(OUT_NAME).hex
393396
@$(NRFUTIL) dfu genpkg --dev-type 0x0052 --dev-revision $(DFU_DEV_REV) --bootloader $< --softdevice $(SD_HEX) $@
394397

398+
#-------------- Artifacts --------------
399+
$(BIN):
400+
@$(MKDIR) -p $@
401+
402+
copy-artifact: $(BIN)
403+
@$(CP) $(BUILD)/update-$(OUT_NAME)_nosd.uf2 $(BIN)
404+
@$(CP) $(BUILD)/$(MERGED_FILE).hex $(BIN)
405+
@$(CP) $(BUILD)/$(MERGED_FILE).zip $(BIN)
406+
395407
#------------------- Flash target -------------------
396408

397409
check_defined = \
@@ -402,7 +414,7 @@ __check_defined = \
402414
$(error Undefined make flag: $1$(if $2, ($2))))
403415

404416
# Flash the compiled
405-
flash: $(BUILD)/$(OUT_FILE)-nosd.hex
417+
flash: $(BUILD)/$(OUT_NAME)_nosd.hex
406418
@echo Flashing: $(notdir $<)
407419
$(call FLASH_CMD,$<)
408420

@@ -433,5 +445,5 @@ gdbflash: $(BUILD)/$(MERGED_FILE).hex
433445
@echo Flashing: $<
434446
@$(GDB_BMP) -nx --batch -ex 'load $<' -ex 'compare-sections' -ex 'kill'
435447

436-
gdb: $(BUILD)/$(OUT_FILE).out
448+
gdb: $(BUILD)/$(OUT_NAME).out
437449
$(GDB_BMP) $<

0 commit comments

Comments
 (0)