diff --git a/VERSION.txt b/VERSION.txt index ceab6e1..7e1b986 100644 --- a/VERSION.txt +++ b/VERSION.txt @@ -1 +1 @@ -0.1 \ No newline at end of file +0.3 //test gitea autoflow \ No newline at end of file diff --git a/makefile b/makefile index df525bd..05149e4 100644 --- a/makefile +++ b/makefile @@ -1,34 +1,50 @@ -MCU ?= atmega644pa -BUILD_TYPE ?= dev -VERSION ?= 0.1 +name: AVR Build -F_CPU ?= 8000000UL +on: + push: + branches: + - dev + - live + - main + pull_request: -CC = avr-gcc -OBJCOPY = avr-objcopy +jobs: + build: + runs-on: ubuntu-latest -SRC = src/main.c + steps: + - name: Checkout + uses: actions/checkout@v4 -OUTDIR = build/$(BUILD_TYPE) + - name: Install AVR toolchain + run: | + apt-get update + apt-get install -y gcc-avr avr-libc binutils-avr make cppcheck -ifeq ($(BUILD_TYPE),dev) - PREFIX = DEV_ENO -else - PREFIX = ENO -endif + - name: Set build type from branch + id: vars + run: | + BRANCH="${GITHUB_REF_NAME}" -TARGET = $(OUTDIR)/$(PREFIX)_$(VERSION) + if [ "$BRANCH" = "dev" ]; then + echo "BUILD_TYPE=dev" >> $GITHUB_ENV + echo "PREFIX=DEV_ENO" >> $GITHUB_ENV + else + echo "BUILD_TYPE=live" >> $GITHUB_ENV + echo "PREFIX=ENO" >> $GITHUB_ENV + fi -CFLAGS = -mmcu=$(MCU) -DF_CPU=$(F_CPU) -Os -DVERSION=\"$(VERSION)\" + echo "VERSION=${GITHUB_SHA::7}" >> $GITHUB_ENV -all: $(TARGET).hex + - name: Code check + run: cppcheck --enable=all --error-exitcode=1 src/ -$(TARGET).elf: - @mkdir -p $(OUTDIR) - $(CC) $(CFLAGS) $(SRC) -o $@ + - name: Build firmware + run: | + make BUILD_TYPE=$BUILD_TYPE PREFIX=$PREFIX VERSION=$VERSION -$(TARGET).hex: $(TARGET).elf - $(OBJCOPY) -O ihex -R .eeprom $< $@ - -clean: - rm -rf build \ No newline at end of file + - name: Upload hex + uses: actions/upload-artifact@v4 + with: + name: firmware-${{ env.BUILD_TYPE }} + path: build/**/*.hex \ No newline at end of file diff --git a/makefile-gitlab b/makefile-gitlab new file mode 100644 index 0000000..9789a1c --- /dev/null +++ b/makefile-gitlab @@ -0,0 +1,34 @@ +MCU ?= atmega644pa +BUILD_TYPE ?= dev +VERSION ?= 0.1 + +F_CPU ?= 8000000UL + +CC = avr-gcc +OBJCOPY = avr-objcopy + +SRC = src/main.c + +OUTDIR = build/$(BUILD_TYPE) + +ifeq ($(BUILD_TYPE),dev) + PREFIX = DEV_ENO +else + PREFIX = ENO +endif + +TARGET = $(OUTDIR)/$(PREFIX)_$(VERSION) + +CFLAGS = -mmcu=$(MCU) -DF_CPU=$(F_CPU) -Os -DVERSION=\"$(VERSION)\" + +all: $(TARGET).hex + +$(TARGET).elf: + @mkdir -p $(OUTDIR) + $(CC) $(CFLAGS) $(SRC) -o $@ + +$(TARGET).hex: $(TARGET).elf + $(OBJCOPY) -O ihex -R .eeprom $< $@ + +clean: + rm -rf build \ No newline at end of file