-
Notifications
You must be signed in to change notification settings - Fork 18
97 lines (80 loc) · 2.77 KB
/
docker.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
name: CD - Build Docker Image
on:
release:
types: [published]
workflow_dispatch:
inputs:
rebuild:
description: "Rebuild tag?"
required: true
default: "no"
type: choice
options:
- "no"
- "yes"
concurrency:
group: docker-${{ github.event.workflow_run.head_branch || github.ref }}
cancel-in-progress: true
permissions:
packages: write
env:
DEFAULT_PYTHON: "3.12"
jobs:
docker:
name: Build Docker Image
runs-on: ubuntu-latest
environment:
name: release
steps:
- name: Check repo
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "${{ env.DEFAULT_PYTHON }}"
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt -r dev-requirements.txt
pip install -e ".[dev]"
- name: Get current version (rebuild)
if: ${{ inputs.rebuild == 'yes' }}
run: |
UIPROTECT_VERSION=$(git describe --tags --abbrev=0)
echo "UIPROTECT_VERSION=$(git describe --tags --abbrev=0)" >> $GITHUB_ENV
echo "DOCKER_TAGS=ghcr.io/uilibs/uiprotect:dev,ghcr.io/uilibs/uiprotect:$UIPROTECT_VERSION" >> $GITHUB_ENV
- name: Get current version (no rebuild)
if: ${{ inputs.rebuild != 'yes' }}
run: |
UIPROTECT_VERSION=v$(python -c 'from importlib.metadata import version; print(version("uiprotect"))')
echo "UIPROTECT_VERSION=$UIPROTECT_VERSION" >> $GITHUB_ENV
echo "DOCKER_TAGS=ghcr.io/uilibs/uiprotect:dev,ghcr.io/uilibs/uiprotect:$(echo $UIPROTECT_VERSION | tr "+" -)" >> $GITHUB_ENV
- name: Add Latest Docker Tag
run: |
if [[ ! "$UIPROTECT_VERSION" == *"dev"* ]]; then
echo "DOCKER_TAGS=ghcr.io/uilibs/uiprotect:latest,$DOCKER_TAGS" >> $GITHUB_ENV
fi
- name: Set up QEMU
uses: docker/setup-qemu-action@v2
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Login to GitHub Container Registry
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and Push
uses: docker/build-push-action@v3
with:
context: .
platforms: linux/amd64,linux/arm64
target: prod
push: true
build-args: |
UIPROTECT_VERSION=${{ env.UIPROTECT_VERSION }}
cache-from: ghcr.io/uilibs/uiprotect:buildcache
cache-to: type=registry,ref=ghcr.io/uilibs/uiprotect:buildcache,mode=max
tags: ${{ env.DOCKER_TAGS }}