mirror of
https://github.com/PiBrewing/craftbeerpi4.git
synced 2024-11-10 01:17:42 +01:00
Merge pull request #9 from papauorg/feature/improve-ci
Improve CI build and fix docker build issue
This commit is contained in:
commit
6c4561f011
2 changed files with 40 additions and 6 deletions
44
.github/workflows/build.yml
vendored
44
.github/workflows/build.yml
vendored
|
@ -1,4 +1,4 @@
|
||||||
name: 'Build Docker Image'
|
name: 'Build CraftBeerPi4'
|
||||||
|
|
||||||
on:
|
on:
|
||||||
push:
|
push:
|
||||||
|
@ -6,13 +6,43 @@ on:
|
||||||
- main
|
- main
|
||||||
- master
|
- master
|
||||||
- development
|
- development
|
||||||
|
pull_request:
|
||||||
|
|
||||||
env:
|
env:
|
||||||
image-name: ghcr.io/${{ github.repository_owner }}/craftbeerpi4
|
image-name: ghcr.io/${{ github.repository_owner }}/craftbeerpi4
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
|
build:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
name: Builds the source distribution package
|
||||||
|
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:
|
docker:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
name: Builds the docker image(s)
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout
|
- name: Checkout
|
||||||
uses: actions/checkout@v2
|
uses: actions/checkout@v2
|
||||||
|
@ -21,18 +51,22 @@ jobs:
|
||||||
id: prep
|
id: prep
|
||||||
run: |
|
run: |
|
||||||
|
|
||||||
|
PUBLISH_IMAGE=false
|
||||||
|
TAGS="${{ env.image-name }}:dev"
|
||||||
|
|
||||||
if [[ $GITHUB_REF_NAME == master ]] || [[ $GITHUB_REF_NAME == main ]]; then
|
if [[ $GITHUB_REF_NAME == master ]] || [[ $GITHUB_REF_NAME == main ]]; then
|
||||||
# when building master/main use :latest tag and the version number
|
# when building master/main use :latest tag and the version number
|
||||||
# from the cbpi/__init__.py file
|
# from the cbpi/__init__.py file
|
||||||
VERSION=$(grep -o -E "(([0-9]{1,2}[.]?){3}[0-9]+)" cbpi/__init__.py)
|
VERSION=$(grep -o -E "(([0-9]{1,2}[.]?){3}[0-9]+)" cbpi/__init__.py)
|
||||||
TAGS="${{ env.image-name }}:latest,${{ env.image-name }}:v${VERSION}"
|
TAGS="${{ env.image-name }}:latest,${{ env.image-name }}:v${VERSION}"
|
||||||
else
|
PUBLISH_IMAGE=true
|
||||||
# otherwise just use :dev tag
|
elif [[ $GITHUB_REF_NAME == development ]]; then
|
||||||
TAGS="${{ env.image-name }}:dev"
|
PUBLISH_IMAGE=true
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Set output parameters.
|
# Set output parameters.
|
||||||
echo ::set-output name=tags::${TAGS}
|
echo ::set-output name=tags::${TAGS}
|
||||||
|
echo ::set-output name=publish_image::${PUBLISH_IMAGE}
|
||||||
|
|
||||||
- name: Set up QEMU
|
- name: Set up QEMU
|
||||||
uses: docker/setup-qemu-action@master
|
uses: docker/setup-qemu-action@master
|
||||||
|
@ -57,7 +91,7 @@ jobs:
|
||||||
context: .
|
context: .
|
||||||
file: ./Dockerfile
|
file: ./Dockerfile
|
||||||
platforms: linux/amd64,linux/arm64
|
platforms: linux/amd64,linux/arm64
|
||||||
push: true
|
push: ${{ steps.prep.outputs.publish_image }}
|
||||||
tags: ${{ steps.prep.outputs.tags }}
|
tags: ${{ steps.prep.outputs.tags }}
|
||||||
labels: |
|
labels: |
|
||||||
org.opencontainers.image.title=${{ github.event.repository.name }}
|
org.opencontainers.image.title=${{ github.event.repository.name }}
|
||||||
|
|
|
@ -3,7 +3,7 @@ RUN apk --no-cache add curl && mkdir /downloads
|
||||||
# Download installation files
|
# Download installation files
|
||||||
RUN curl https://github.com/avollkopf/craftbeerpi4-ui/archive/main.zip -L -o ./downloads/cbpi-ui.zip
|
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
|
# Install dependencies
|
||||||
RUN apt-get update \
|
RUN apt-get update \
|
||||||
|
|
Loading…
Reference in a new issue