Ability to build release zips in CI

This commit is contained in:
Josh Klar 2019-07-20 16:14:58 -07:00
parent 8f5511327e
commit cd7d8a2e4c
No known key found for this signature in database
GPG Key ID: A4A0C7B4E8EEE222
4 changed files with 47 additions and 4 deletions

View File

@ -1,6 +1,22 @@
--- ---
version: 2 version: 2
jobs: jobs:
build:
docker:
- image: 'kmkfw/base'
environment:
KMK_TEST: 1
PIPENV_VENV_IN_PROJECT: 1
steps:
- checkout
- restore_cache:
keys:
- v2-kmk-venv-{{ checksum "Pipfile.lock" }}
- run: make dist
test: test:
docker: docker:
- image: 'kmkfw/base' - image: 'kmkfw/base'
@ -21,6 +37,13 @@ workflows:
version: 2 version: 2
build-deploy: build-deploy:
jobs: jobs:
- build:
filters:
branches:
# only: /master/
only: /.*/
tags:
only: /.*/
- test: - test:
filters: filters:
branches: branches:

1
.gitignore vendored
View File

@ -102,6 +102,7 @@ venv.bak/
# mypy # mypy
.mypy_cache/ .mypy_cache/
.compiled/
.ampy .ampy
.submodules .submodules

View File

@ -3,7 +3,7 @@ FROM python:3.7-alpine
RUN mkdir -p /app RUN mkdir -p /app
WORKDIR /app WORKDIR /app
RUN apk update && apk add alpine-sdk curl gettext git git-lfs openssh rsync wget RUN apk update && apk add alpine-sdk curl gettext git git-lfs openssh rsync wget zip
RUN pip install pipenv RUN pip install pipenv

View File

@ -6,6 +6,8 @@
.DEFAULT: all .DEFAULT: all
DIST_DESCRIBE_CMD = git describe --always --abbrev=0 --dirty --broken
DOCKER_BASE_TAG ?= latest DOCKER_BASE_TAG ?= latest
DOCKER_TAG ?= latest DOCKER_TAG ?= latest
@ -22,14 +24,31 @@ MPY_TARGET_DIR ?= .compiled
all: copy-kmk copy-bootpy copy-keymap all: copy-kmk copy-bootpy copy-keymap
compile: $(MPY_TARGET_DIR)/.mpy.compiled compile: $(MPY_TARGET_DIR)/.mpy.compiled
$(MPY_TARGET_DIR)/.mpy.compiled: $(shell find $(MPY_SOURCES) -name "*.py")
ifeq ($(MPY_CROSS),) ifeq ($(MPY_CROSS),)
@echo "===> Could not find mpy-cross in PATH, exiting" @echo "===> Could not find mpy-cross in PATH, exiting"
@false @false
endif endif
$(MPY_TARGET_DIR)/.mpy.compiled: $(shell find $(MPY_SOURCES) -name "*.py")
@mkdir -p $(MPY_TARGET_DIR) @mkdir -p $(MPY_TARGET_DIR)
@find $(MPY_SOURCES) -name "*.py" -exec sh -c 'mkdir -p $(MPY_TARGET_DIR)/$$(dirname {}) && mpy-cross $(MPY_FLAGS) {} -o $(MPY_TARGET_DIR)/$$(dirname {})/$$(basename -s .py {}).mpy' \; @find $(MPY_SOURCES) -name "*.py" -exec sh -c 'mkdir -p $(MPY_TARGET_DIR)/$$(dirname {}) && mpy-cross $(MPY_FLAGS) {} -o $(MPY_TARGET_DIR)/$$(dirname {})/$$(basename -s .py {}).mpy' \;
@touch $(MPY_TARGET_DIR)/.mpy.compiled
dist: dist/latest.zip dist/latest.unoptimized.zip dist/$(shell $(DIST_DESCRIBE_CMD)).zip dist/$(shell $(DIST_DESCRIBE_CMD)).unoptimized.zip
dist/latest.zip: compile
@mkdir -p dist
@cd $(MPY_TARGET_DIR) && zip -r ../dist/latest.zip kmk
dist/$(shell $(DIST_DESCRIBE_CMD)).zip: dist/latest.zip
@cp dist/latest.zip dist/$$($(DIST_DESCRIBE_CMD)).zip
dist/latest.unoptimized.zip:
@mkdir -p dist
@zip -r dist/latest.unoptimized.zip kmk
dist/$(shell $(DIST_DESCRIBE_CMD)).unoptimized.zip: dist/latest.unoptimized.zip
@cp dist/latest.unoptimized.zip dist/$$($(DIST_DESCRIBE_CMD)).unoptimized.zip
.docker_base: Dockerfile .docker_base: Dockerfile
@echo "===> Building Docker base image kmkfw/base:${DOCKER_BASE_TAG}" @echo "===> Building Docker base image kmkfw/base:${DOCKER_BASE_TAG}"
@ -57,7 +76,7 @@ fix-isort: devdeps
clean: clean-build-log clean: clean-build-log
@echo "===> Cleaning build artifacts" @echo "===> Cleaning build artifacts"
@rm -rf .devdeps build @rm -rf .devdeps build dist $(MPY_TARGET_DIR)
clean-build-log: clean-build-log:
@echo "===> Clearing previous .build.log" @echo "===> Clearing previous .build.log"