2021-04-20 17:14:52 +03:00
|
|
|
# This pipeline aims at building Glances for the following targets:
|
|
|
|
# - Docker Hub
|
|
|
|
# - Pypi
|
2021-04-20 11:09:31 +03:00
|
|
|
|
2021-04-20 17:14:52 +03:00
|
|
|
name: CI
|
2021-04-20 11:09:31 +03:00
|
|
|
|
2021-04-20 17:14:52 +03:00
|
|
|
env:
|
|
|
|
DEFAULT_DOCKER_IMAGE: nicolargo/glances
|
|
|
|
NODE_ENV: ${{ (contains('refs/heads/master', github.ref) || startsWith(github.ref, 'refs/tags/v')) && 'prod' || 'dev' }}
|
|
|
|
PUSH_BRANCH: ${{ 'refs/heads/develop' == github.ref || 'refs/heads/master' == github.ref || startsWith(github.ref, 'refs/tags/v') }}
|
|
|
|
DOCKER_PLATFORMS: linux/amd64,linux/arm/v6,linux/arm/v7,linux/arm64,linux/386
|
|
|
|
|
|
|
|
on:
|
|
|
|
pull_request:
|
|
|
|
branches: [ develop ]
|
|
|
|
push:
|
|
|
|
branches: [ master, develop ]
|
|
|
|
tags:
|
|
|
|
- v*
|
2021-04-20 11:09:31 +03:00
|
|
|
|
|
|
|
jobs:
|
2021-05-15 10:43:26 +03:00
|
|
|
|
|
|
|
pypi:
|
|
|
|
runs-on: ubuntu-latest
|
|
|
|
steps:
|
|
|
|
|
|
|
|
- uses: actions/checkout@v2
|
|
|
|
|
|
|
|
- name: Install pip install build tools
|
|
|
|
run: >-
|
|
|
|
python -m
|
|
|
|
pip install
|
|
|
|
build
|
|
|
|
--user
|
|
|
|
|
|
|
|
- name: Build a binary wheel and a source tarball
|
|
|
|
run: >-
|
|
|
|
python -m
|
|
|
|
build
|
|
|
|
--sdist
|
|
|
|
--wheel
|
|
|
|
--outdir dist/
|
|
|
|
|
|
|
|
- name: Publish distribution package to Test PyPI
|
|
|
|
uses: pypa/gh-action-pypi-publish@master
|
|
|
|
with:
|
|
|
|
user: __token__
|
|
|
|
password: ${{ secrets.TEST_PYPI_API_TOKEN }}
|
|
|
|
repository_url: https://test.pypi.org/legacy/
|
|
|
|
skip_existing: true
|
|
|
|
|
|
|
|
- name: Publish distribution package to PyPI
|
|
|
|
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags')
|
|
|
|
uses: pypa/gh-action-pypi-publish@master
|
|
|
|
with:
|
|
|
|
user: __token__
|
|
|
|
password: ${{ secrets.PYPI_API_TOKEN }}
|
|
|
|
|
|
|
|
docker-images:
|
2021-04-20 11:09:31 +03:00
|
|
|
runs-on: ubuntu-latest
|
2021-05-15 10:43:26 +03:00
|
|
|
# Make sure we release the python package first. So we are sure to get the latest.
|
|
|
|
needs:
|
|
|
|
- pypi
|
2021-04-20 11:09:31 +03:00
|
|
|
steps:
|
2021-04-20 17:14:52 +03:00
|
|
|
- name: Checkout
|
|
|
|
uses: actions/checkout@v2
|
2021-04-20 11:09:31 +03:00
|
|
|
|
2021-04-20 17:14:52 +03:00
|
|
|
- name: Cache Docker layers
|
|
|
|
uses: actions/cache@v2
|
2021-04-20 11:09:31 +03:00
|
|
|
with:
|
2021-04-20 17:14:52 +03:00
|
|
|
path: /tmp/.buildx-cache
|
|
|
|
key: ${{ runner.os }}-buildx-${{ env.NODE_ENV }}-${{ github.sha }}
|
|
|
|
restore-keys: |
|
|
|
|
${{ runner.os }}-buildx-${{ env.NODE_ENV }}
|
2021-04-20 11:09:31 +03:00
|
|
|
|
2021-05-14 15:41:12 +03:00
|
|
|
- name: Configure
|
|
|
|
id: config
|
2021-04-20 17:14:52 +03:00
|
|
|
run: |
|
|
|
|
ls -la /tmp/.buildx-cache || true
|
2021-05-14 15:41:12 +03:00
|
|
|
DEFAULT_TAGET='minimal'
|
2021-04-20 17:14:52 +03:00
|
|
|
|
|
|
|
if [[ $GITHUB_REF == refs/tags/* ]]; then
|
|
|
|
VERSION=${GITHUB_REF#refs/tags/v}
|
2021-05-14 15:41:12 +03:00
|
|
|
DEFAULT_TAG="${VERSION}"s
|
|
|
|
FULL_TAG="${VERSION}-full"
|
2021-04-20 11:09:31 +03:00
|
|
|
|
2021-05-14 15:41:12 +03:00
|
|
|
elif [[ $GITHUB_REF == refs/heads/develop ]]; then
|
2021-04-20 17:14:52 +03:00
|
|
|
VERSION=dev
|
2021-05-14 15:41:12 +03:00
|
|
|
DEFAULT_TAG="${VERSION}"
|
|
|
|
DEFAULT_TAGET='dev'
|
|
|
|
|
|
|
|
else
|
|
|
|
VERSION=latest
|
|
|
|
DEFAULT_TAG="${VERSION}"
|
2021-04-20 17:14:52 +03:00
|
|
|
fi
|
|
|
|
|
2021-05-14 15:41:12 +03:00
|
|
|
echo "::set-output name=defaultTag::$DEFAULT_TAG"
|
|
|
|
echo "::set-output name=fullTag::$FULL_TAG"
|
|
|
|
echo "::set-output name=defaultTarget::$DEFAULT_TAGET"
|
2021-04-20 17:14:52 +03:00
|
|
|
|
2021-05-14 15:47:41 +03:00
|
|
|
- name: Retrieve Repository Docker metadata
|
|
|
|
id: docker_meta
|
|
|
|
uses: crazy-max/ghaction-docker-meta@v2.5.0
|
|
|
|
with:
|
|
|
|
images: ${{ env.DEFAULT_DOCKER_IMAGE }}
|
|
|
|
labels: |
|
|
|
|
org.opencontainers.image.url=https://nicolargo.github.io/glances/
|
|
|
|
|
2021-04-20 17:14:52 +03:00
|
|
|
- name: Set up QEMU
|
|
|
|
uses: docker/setup-qemu-action@v1
|
2021-04-20 11:09:31 +03:00
|
|
|
with:
|
2021-04-20 17:14:52 +03:00
|
|
|
platforms: all
|
2021-04-20 11:09:31 +03:00
|
|
|
|
2021-04-20 17:14:52 +03:00
|
|
|
- name: Set up Docker Buildx
|
|
|
|
id: buildx
|
|
|
|
uses: docker/setup-buildx-action@v1
|
|
|
|
with:
|
|
|
|
version: latest
|
2021-04-20 11:09:31 +03:00
|
|
|
|
2021-04-20 17:14:52 +03:00
|
|
|
- name: Login to DockerHub
|
|
|
|
uses: docker/login-action@v1
|
|
|
|
if: ${{ env.PUSH_BRANCH == 'true' }}
|
|
|
|
with:
|
|
|
|
username: ${{ secrets.DOCKER_USERNAME }}
|
|
|
|
password: ${{ secrets.DOCKER_PASSWORD }}
|
|
|
|
|
2021-05-14 15:41:12 +03:00
|
|
|
- name: Build and push minimal image
|
|
|
|
uses: docker/build-push-action@v2
|
|
|
|
with:
|
|
|
|
push: ${{ env.PUSH_BRANCH == 'true' }}
|
|
|
|
tags: ${{ steps.config.outputs.defaultTag }}
|
|
|
|
build-args: |
|
|
|
|
ACTION_ID=${{env.GITHUB_ACTION}}
|
|
|
|
context: .
|
|
|
|
file: docker-files/debian.Dockerfile
|
|
|
|
platforms: ${{env.DOCKER_PLATFORMS}}
|
|
|
|
target: ${{ steps.config.outputs.defaultTarget }}
|
2021-05-14 15:47:41 +03:00
|
|
|
labels: ${{ steps.docker_meta.outputs.labels }}
|
2021-05-14 15:41:12 +03:00
|
|
|
cache-from: type=local,src=/tmp/.buildx-cache
|
|
|
|
cache-to: type=local,dest=/tmp/.buildx-cache,mode=max
|
|
|
|
|
|
|
|
- name: Build and push full image
|
|
|
|
if: ${{ steps.config.outputs.fullTag != '' }}
|
2021-04-20 17:14:52 +03:00
|
|
|
uses: docker/build-push-action@v2
|
|
|
|
with:
|
|
|
|
push: ${{ env.PUSH_BRANCH == 'true' }}
|
2021-05-14 15:41:12 +03:00
|
|
|
tags: ${{ steps.config.outputs.fullTag }}
|
2021-04-20 17:14:52 +03:00
|
|
|
build-args: |
|
2021-05-15 10:43:26 +03:00
|
|
|
CHANGING_ARG=${{env.GITHUB_SHA}}
|
2021-04-20 17:14:52 +03:00
|
|
|
context: .
|
2021-05-14 15:41:12 +03:00
|
|
|
file: docker-files/debian.Dockerfile
|
|
|
|
target: full
|
2021-04-20 17:14:52 +03:00
|
|
|
platforms: ${{env.DOCKER_PLATFORMS}}
|
2021-05-14 15:47:41 +03:00
|
|
|
labels: ${{ steps.docker_meta.outputs.labels }}
|
2021-04-20 17:14:52 +03:00
|
|
|
cache-from: type=local,src=/tmp/.buildx-cache
|
|
|
|
cache-to: type=local,dest=/tmp/.buildx-cache,mode=max
|