From b7a0f0ea249f77dee0da9fd6f898c4406479ebc0 Mon Sep 17 00:00:00 2001 From: Philipp Grathwohl Date: Sat, 27 Nov 2021 21:17:00 +0100 Subject: [PATCH 1/4] Build craftbeerpi4 package via github artifacts --- .github/workflows/build.yml | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 1970a08..858f949 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -11,6 +11,34 @@ env: image-name: ghcr.io/${{ github.repository_owner }}/craftbeerpi4 jobs: + build: + runs-on: ubuntu-latest + name: Builds the source distribution package for CraftBeerPi + steps: + - name: Checkout source + uses: actions/checkout@v2 + + - name: Setup python environment + uses: actions/setup-python@v2 + with: + python-version: '3.7' + + - name: Clean + run: python setup.py clean --all + +# - name: Run tests +# run: python -m unittest tests + + - name: Build source distribution package for CraftBeerPi + run: python setup.py sdist + + - name: Upload CraftBeerPi package to be used in next step + uses: actions/upload-artifact@v2.2.4 + with: + name: craftbeerpi4 + path: dist/cbpi-*.tar.gz + if-no-files-found: error + docker: runs-on: ubuntu-latest steps: From 717f4da1838a389a4524f7f8148864d420612670 Mon Sep 17 00:00:00 2001 From: Philipp Grathwohl Date: Sat, 27 Nov 2021 21:34:22 +0100 Subject: [PATCH 2/4] Run build on PRs to validate changes To avoid a mess, do not publish packages on PR builds. --- .github/workflows/build.yml | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 858f949..05cc22d 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -6,6 +6,7 @@ on: - main - master - development + pull_request: env: image-name: ghcr.io/${{ github.repository_owner }}/craftbeerpi4 @@ -49,18 +50,22 @@ jobs: id: prep run: | + PUBLISH_IMAGE=false + TAGS="${{ env.image-name }}:dev" + if [[ $GITHUB_REF_NAME == master ]] || [[ $GITHUB_REF_NAME == main ]]; then # when building master/main use :latest tag and the version number # from the cbpi/__init__.py file VERSION=$(grep -o -E "(([0-9]{1,2}[.]?){3}[0-9]+)" cbpi/__init__.py) TAGS="${{ env.image-name }}:latest,${{ env.image-name }}:v${VERSION}" - else - # otherwise just use :dev tag - TAGS="${{ env.image-name }}:dev" + PUBLISH_IMAGE=true + elif [[ $GITHUB_REF_NAME == development ]]; then + PUBLISH_IMAGE=true fi # Set output parameters. echo ::set-output name=tags::${TAGS} + echo ::set-output name=publish_image::${PUBLISH_IMAGE} - name: Set up QEMU uses: docker/setup-qemu-action@master @@ -85,7 +90,7 @@ jobs: context: . file: ./Dockerfile platforms: linux/amd64,linux/arm64 - push: true + push: ${{ steps.prep.outputs.publish_image }} tags: ${{ steps.prep.outputs.tags }} labels: | org.opencontainers.image.title=${{ github.event.repository.name }} From 603764cdcc40c65258310e74f1a343ec2b2ea2eb Mon Sep 17 00:00:00 2001 From: Philipp Grathwohl Date: Sun, 28 Nov 2021 13:26:44 +0100 Subject: [PATCH 3/4] Use full python image to avoid build errors --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index b973b7b..2e747ba 100644 --- a/Dockerfile +++ b/Dockerfile @@ -3,7 +3,7 @@ RUN apk --no-cache add curl && mkdir /downloads # Download installation files RUN curl https://github.com/avollkopf/craftbeerpi4-ui/archive/main.zip -L -o ./downloads/cbpi-ui.zip -FROM python:3.7-slim +FROM python:3.7 # Install dependencies RUN apt-get update \ From 57be4fe6218fb66fff3a7da80c10f06d55f3da72 Mon Sep 17 00:00:00 2001 From: Philipp Grathwohl Date: Sun, 28 Nov 2021 13:38:46 +0100 Subject: [PATCH 4/4] Improve job names of build pipeline --- .github/workflows/build.yml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 05cc22d..0de6dcb 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -1,4 +1,4 @@ -name: 'Build Docker Image' +name: 'Build CraftBeerPi4' on: push: @@ -14,7 +14,7 @@ env: jobs: build: runs-on: ubuntu-latest - name: Builds the source distribution package for CraftBeerPi + name: Builds the source distribution package steps: - name: Checkout source uses: actions/checkout@v2 @@ -42,6 +42,7 @@ jobs: docker: runs-on: ubuntu-latest + name: Builds the docker image(s) steps: - name: Checkout uses: actions/checkout@v2