-
Notifications
You must be signed in to change notification settings - Fork 2
72 lines (62 loc) · 2.11 KB
/
Copy pathdocker.yml
File metadata and controls
72 lines (62 loc) · 2.11 KB
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
name: Build and publish Docker image
# Builds the self-host image (deploy/Dockerfile) and pushes it to the GitHub
# Container Registry (ghcr.io/michael-borck/slide-stream). Runs automatically
# when a release lands on main (the version is read from pyproject.toml and
# the build waits for PyPI to serve it), or manually via workflow_dispatch.
on:
workflow_dispatch:
inputs:
version:
description: "slide-stream version to bake in (blank = read pyproject.toml)"
required: false
default: ""
push:
branches: [main]
paths:
- 'pyproject.toml'
- 'deploy/Dockerfile'
- '.github/workflows/docker.yml'
permissions:
contents: read
packages: write
env:
IMAGE: ghcr.io/${{ github.repository }}
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Resolve version
id: ver
run: |
V="${{ inputs.version }}"
if [ -z "$V" ]; then
V=$(grep -m1 '^version = ' pyproject.toml | cut -d'"' -f2)
fi
echo "version=$V" >> "$GITHUB_OUTPUT"
echo "Building slide-stream $V"
- name: Wait for the version on PyPI
run: |
V="${{ steps.ver.outputs.version }}"
for i in $(seq 1 18); do
if curl -fsS "https://pypi.org/pypi/slide-stream/$V/json" > /dev/null; then
echo "PyPI has $V"; exit 0
fi
echo "PyPI does not have $V yet (attempt $i/18); waiting 10s..."
sleep 10
done
echo "::error::slide-stream $V never appeared on PyPI — publish first (twine), then re-run."
exit 1
- uses: docker/setup-buildx-action@v3
- uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- uses: docker/build-push-action@v6
with:
context: deploy
push: true
tags: ${{ env.IMAGE }}:latest,${{ env.IMAGE }}:${{ steps.ver.outputs.version }}
build-args: |
SLIDE_STREAM_VERSION=${{ steps.ver.outputs.version }}