Skip to content

Commit

Permalink
Adds auto detecting release action run which allow to create release …
Browse files Browse the repository at this point in the history
…package (#147)

- Now creates debian package when creates new tag without '.devel' suffix.
  • Loading branch information
Artanias committed Dec 28, 2022
1 parent ed1a962 commit 9d0a4dd
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 5 deletions.
6 changes: 6 additions & 0 deletions .github/workflows/check_n_push_image.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,13 +47,19 @@ jobs:
run: |
echo "ACCESS_TOKEN=${ACCESS_TOKEN}" > .env
- name: Provides release environment variable if created new tag.
if: ${{ startsWith(github.event.ref, 'refs/tags/v') }}
run: |
echo "IS_DEVELOPED=0" >> .env
- name: Get current util version
id: get_version
run: |
echo "::set-output name=version::$(grep --max-count 1 UTIL_VERSION Makefile | grep -Eo "[0-9]+[.][0-9]+[.][0-9]+")"
- name: Create main docker image, run tests and save image for the next job
run: |
export $(cat .env | xargs)
make docker-image DOCKER_TAG=${{ secrets.DOCKER_HUB_USERNAME }}/codeplag-ubuntu20.04:${{ steps.get_version.outputs.version }}
docker image save --output /tmp/codeplag-ubuntu20.04.tar ${{ secrets.DOCKER_HUB_USERNAME }}/codeplag-ubuntu20.04:${{ steps.get_version.outputs.version }}
Expand Down
11 changes: 10 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
UTIL_VERSION := 0.2.9
UTIL_VERSION := 0.3.0
UTIL_NAME := codeplag
PWD := $(shell pwd)

Expand All @@ -13,6 +13,7 @@ CODEPLAG_LOG_PATH := $(LOGS_PATH)/$(UTIL_NAME).log
CONFIG_PATH := /etc/$(UTIL_NAME)/settings.conf

SOURCE_SUB_FILES := src/$(UTIL_NAME)/consts.py
IS_DEVELOPED ?= 1
DEBIAN_SUB_FILES := debian/changelog \
debian/control \
debian/preinst \
Expand All @@ -23,10 +24,17 @@ DOCKER_SUB_FILES := docker/base_ubuntu2004.dockerfile \

PYTHON_REQUIRED_LIBS := $(shell python3 setup.py --install-requirements)


ifeq ($(IS_DEVELOPED), 1)
DEVEL_SUFFIX := .devel
endif


substitute = @sed \
-e "s|@UTIL_NAME@|${UTIL_NAME}|g" \
-e "s|@UTIL_VERSION@|${UTIL_VERSION}|g" \
-e "s|@CODEPLAG_LOG_PATH@|${CODEPLAG_LOG_PATH}|g" \
-e "s|@DEVEL_SUFFIX@|${DEVEL_SUFFIX}|g" \
-e "s|@PYTHON_REQUIRED_LIBS@|${PYTHON_REQUIRED_LIBS}|g" \
-e "s|@LOGS_PATH@|${LOGS_PATH}|g" \
-e "s|@CONFIG_PATH@|${CONFIG_PATH}|g" \
Expand Down Expand Up @@ -160,6 +168,7 @@ docker-autotest: docker-test-image
docker-build-package: docker-test-image
docker run --rm \
--volume $(PWD)/debian/deb:/usr/src/$(UTIL_NAME)/debian/deb \
--env IS_DEVELOPED=$(IS_DEVELOPED) \
"$(TEST_DOCKER_TAG)" bash -c \
"make package"

Expand Down
2 changes: 1 addition & 1 deletion debian/changelog.in
Original file line number Diff line number Diff line change
@@ -1 +1 @@
@UTIL_NAME@-util (@UTIL_VERSION@-1.devel) stable; urgency=medium
@UTIL_NAME@-util (@UTIL_VERSION@-1@DEVEL_SUFFIX@) stable; urgency=medium
4 changes: 2 additions & 2 deletions debian/rules
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ override_dh_builddeb:
dh_builddeb --destdir=$(DESTDIR)

override_dh_usrlocal:
echo "Skipping this step"
echo "Skipping dh_usrlocal ..."

override_dh_auto_test:
echo "Skipping this step"
echo "Skipping dh_auto_test ..."

.EXPORT_ALL_VARIABLES:
2 changes: 1 addition & 1 deletion docker/ubuntu2004.dockerfile.in
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
FROM @UTIL_NAME@-base-ubuntu20.04:@UTIL_VERSION@

ADD debian/deb/ /usr/src/@UTIL_NAME@/debian/deb
RUN apt-get install -y /usr/src/@UTIL_NAME@/debian/deb/@UTIL_NAME@-util_@UTIL_VERSION@-1.devel_amd64.deb
RUN apt-get install -y /usr/src/@UTIL_NAME@/debian/deb/@UTIL_NAME@-util_@UTIL_VERSION@-1@DEVEL_SUFFIX@_amd64.deb
# TODO: Fix this hook. apt-get don't install manpage into image.
RUN cp debian/deb/usr/share/man/man1/@UTIL_NAME@.1 /usr/share/man/man1/

Expand Down

0 comments on commit 9d0a4dd

Please sign in to comment.