Skip to content

Commit

Permalink
CI improvements and fix the version.
Browse files Browse the repository at this point in the history
Signed-off-by: Alvaro Saurin <alvaro.saurin@gmail.com>
  • Loading branch information
inercia committed Jun 22, 2020
1 parent 46ddb0b commit ae9b8cc
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 10 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ before_install:
- make ci/setup

script:
- make ci/check
- make ci/build

# generate all the artifacts that will be published by the "deploy"
Expand Down Expand Up @@ -36,4 +37,3 @@ deploy:
secure: mEt1w/QZV5/UTx7KJ3YJk45Gs7tuW28KoVn03o/T/ZhapJeUAG8GNKbq/pxqeCsyl3Q84+/0nmjmUHAI6fT8mV6A6070NP4Hw2j6GbeQkrKGEyabtW9IcnYXeAXMrAC0EoE9Q9jEynu7fjroUSmuklGW+f7sJajMpk1X0Q8sQotL6PT3WYhB3u+uAwpYtRn3kB6zN1/7EFjmQYNIyn8Jy8C6bM93b3n6+S/XD3V0u3zE4iDZ23BwQ3vVm5Ay2jzf+UPi/y7NpFKqekMUPOo96LiiSzeCj48J/BxUv2o3GyTshvzQfi5wKbjxI+8Rk4VR7Qq/RZHa7UNsdNTGtRVmkmIn5+ar+xJ7MsV+nQ9lTpJmpfxyL/u4EBxh8coXoyjdgILVeHK2oT8WQAknC8Yq3yUWpWjsiOdl5CTY5OT8FPF9/9iwlX2wM6N6fjGj6Wo9E+tQ5FU/lXGSPkIsBrKy4lY/edZJNOXS23t9s6KjcpPSwtd3NkmktTKmeo1LsdGHtBMwLtN8SzrmI04sxZzxY6yVr4nsi2CMDAo5u/1S7cGO889VVy0ZjHjnohaHo6K1tACtcoslv6S3yN7m4o3zIq9ni9bbwbVJU7KZ5MKyR98Ge0iGbQfpMlO17kGtShTcTBZQY7K0Ct91OkmQS52YhH+ciJNz5m6kYFyHP1fKKX0=
file: com.github.inercia.k3x.flatpak
skip_cleanup: true

39 changes: 31 additions & 8 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -84,10 +84,12 @@ FLATHUB_PATCH = $(PROJECT_ROOT)/build-aux/flathub-diff.patch


# pep8 ignores
PEP8_IGNORE = E402,E501,E722
PEP8_IGNORE = E402,E501,E722,E127

TAG ?=
TAG_LATEST = $(shell git describe --abbrev=0)
# some git info
TAG ?=
GIT_TAG_LATEST = $(shell git describe --abbrev=0)
GIT_MODIFIED = $(shell git ls-files -m)

NINJA_TARGET ?=

Expand All @@ -113,7 +115,8 @@ help: ## Show this help screen
@echo ''
@awk 'BEGIN {FS = ":.*##"; printf "\nUsage:\n make \033[36m<target>\033[0m\n"} /^[a-zA-Z0-9_-]+:.*?##/ { printf " \033[36m%-15s\033[0m %s\n", $$1, $$2 } /^##@/ { printf "\n\033[1m%s\033[0m\n", substr($$0, 5) } ' $(MAKEFILE_LIST)

##############################
##############################PROJECT_GIT_VERSION = $(shell git describe --abbrev=0)

# Development
##############################
##@ Development
Expand Down Expand Up @@ -193,6 +196,13 @@ check: pep8 ## Check code style
pep8:
$(Q)find src -name \*.py -exec pycodestyle --ignore=$(PEP8_IGNORE) {} +

# checks that the version in meson.build matches the TAAG (or latest tag)
check-version:
$(Q)[ -n "$(TAG)" ] || { printf "$(CYN)>>> $(RED)No TAG provided$(END)\n" ; exit 1 ; }
$(Q)tag=`echo $(TAG) | tr -d "v"` ; \
grep -q "$$tag" "meson.build" || { printf "$(CYN)>>> $(RED)$$tag does not match the 'version' in 'meson.build'. Please update that file.$(END)\n" ; exit 1 ; }
@printf "$(CYN)>>> $(GRN)Version in meson.build looks fine.$(END)\n"

##############################
# Packaging
##############################
Expand Down Expand Up @@ -227,13 +237,24 @@ build-aux/flatpak-pip-generator:
##############################

release: ## Adds a new TAG and pushes it to the origin for forcing a new release
$(Q)[ -n "$(TAG)" ] || { printf "$(CYN)>>> $(RED)No TAG provided$(END)\n" ; exit 1 ; }
@printf "$(CYN)>>> $(GRN)Adding TAG=$(TAG$)$(END)\n"
$(Q)[ -n "$(TAG)" ] || { printf "$(CYN)>>> $(RED)No TAG provided. Re-run with something like 'make release TAG=v0.0.0'$(END)\n" ; exit 1 ; }

@printf "$(CYN)>>> $(GRN)Creating new release with TAG=$(TAG)$(END)\n"

$(Q)[ -z "$(GIT_MODIFIED)" ] || { printf "$(CYN)>>> $(RED)Some modified files detected. Please commit your changes before creating a new release.$(END)\n" ; exit 1 ; }
$(Q)git co master

$(Q)git tag | grep -v -q $(TAG) || { printf "$(CYN)>>> $(RED)Version $(TAG) already found in the list of previous tags (last tag=$(GIT_TAG_LATEST)).$(END)\n" ; exit 1 ; }
$(Q)make check-version

@printf "$(CYN)>>> $(GRN)Tag $(TAG) looks fine.$(END)\n"

@printf "$(CYN)>>> $(GRN)Adding new TAG=$(TAG$)$(END)\n"
$(Q)git tag -d $(TAG) 2>/dev/null || /bin/true
$(Q)git tag -a $(TAG) -m "New version $(TAG)" || { printf "$(CYN)>>> $(RED)Failed to add TAG=$(TAG) $(END)\n" ; exit 1 ; }

@printf "$(CYN)>>> $(GRN)Pushing tags $(TAG$)$(END)\n"
$(Q)git push --tags || { printf "$(CYN)>>> $(RED)Failed to push new tag $(TAG) to origin$(END)\n" ; exit 1 ; }
$(Q)git push || { printf "$(CYN)>>> $(RED)Failed to push new tag $(TAG) to origin$(END)\n" ; exit 1 ; }

##############################
# Flathub
Expand All @@ -259,7 +280,7 @@ flathub-update: pypi-dependencies.json ## Update the contents of the Flatub sub

@printf "$(CYN)>>> $(GRN)Patching manifest$(END)\n"
$(Q)cd $(FLATHUB_DIR) && \
cat $(FLATHUB_PATCH) | sed -e 's|@TAG@|$(TAG_LATEST)|g' | patch -p0
cat $(FLATHUB_PATCH) | sed -e 's|@TAG@|$(GIT_TAG_LATEST)|g' | patch -p0

##############################
# CI
Expand All @@ -277,6 +298,8 @@ ci/setup:
sudo apt-get -y install python3-pip
sudo pip3 install pycodestyle

ci/check: TAG=$(GIT_TAG_LATEST)
ci/check: check-version check

ci/build: build

Expand Down
2 changes: 1 addition & 1 deletion meson.build
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
project('k3x',
version: '0.1.0',
version: '0.2.7',
meson_version: '>= 0.50.0',
default_options: [ 'warning_level=2',
],
Expand Down

0 comments on commit ae9b8cc

Please sign in to comment.