forked from thumbor/thumbor
-
Notifications
You must be signed in to change notification settings - Fork 0
175 lines (153 loc) · 4.74 KB
/
release.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
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
---
name: release
on:
push:
tags:
- "[0-9]+.[0-9]+.[0-9]+"
pull_request:
branches:
- "master"
permissions:
contents: read
packages: write
env:
python-version: "3.10"
jobs:
# Heavily inspired on https://github.com/tornadoweb/tornado/blob/master/.github/workflows/build.yml
build_sdist:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Python
id: setup-python
uses: actions/setup-python@v4
with:
python-version: ${{ env.python-version }}
- name: Install dependencies
run: |
pip install -U pip
- name: Build package
run: python setup.py sdist
- uses: actions/upload-artifact@v3
with:
path: ./dist/thumbor-*.tar.gz
build_wheels:
name: Build wheels on ${{ matrix.os }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-20.04, macOS-11]
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v4
name: Install Python
with:
python-version: ${{ env.python-version }}
- name: Set up QEMU
if: runner.os == 'Linux'
uses: docker/setup-qemu-action@v1
with:
platforms: all
- name: Build wheels
uses: pypa/[email protected]
- uses: actions/upload-artifact@v3
with:
path: ./wheelhouse/*.whl
upload_pypi:
name: Upload to PyPI
needs: [build_wheels, build_sdist]
runs-on: ubuntu-latest
steps:
- uses: actions/download-artifact@v3
with:
name: artifact
path: dist
- run: ls -lah dist
- uses: pypa/[email protected]
if: github.event_name != 'pull_request'
with:
user: __token__
password: ${{ secrets.PYPI_API_TOKEN }}
skip_existing: true
docker:
needs: upload_pypi
runs-on: ubuntu-latest
strategy:
matrix:
python_version:
- "3.8"
- "3.9"
- "3.10"
- "3.11"
- "3.12"
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: "0"
- name: Set output on new tags
if: github.event_name != 'pull_request'
run: echo "THUMBOR_VERSION=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV
- name: Set output on PR
if: github.event_name == 'pull_request'
run: echo "THUMBOR_VERSION=$(git describe --tags --abbrev=0)" >> $GITHUB_ENV
- name: Enable docker cache push
if: github.event_name != 'pull_request'
run: echo "CACHE_TO=type=registry,ref=ghcr.io/thumbor/thumbor:buildcache-${{ matrix.python_version }},mode=max" >> $GITHUB_ENV
- name: Set up QEMU
uses: docker/setup-qemu-action@v2
- name: Set up Docker Buildx
id: buildx
uses: docker/setup-buildx-action@v3
- name: Login to GHCR
if: github.event_name != 'pull_request'
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Login to Quay.io
if: github.event_name != 'pull_request'
uses: docker/login-action@v2
with:
registry: quay.io
username: ${{ secrets.QUAY_IO_USERNAME }}
password: ${{ secrets.QUAY_IO_PASSWORD }}
- name: Login to Docker Hub
if: github.event_name != 'pull_request'
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_PASSWORD }}
- name: Docker meta
id: meta
uses: docker/metadata-action@v5
with:
flavor: |
suffix=-py-${{ matrix.python_version }}
images: |
ghcr.io/thumbor/thumbor
quay.io/thumbor/thumbor
thumbororg/thumbor
tags: |
type=schedule
type=ref,event=branch
type=ref,event=pr
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
type=semver,pattern={{major}}
type=sha
- name: Build and push
uses: docker/build-push-action@v3
with:
context: ./docker
platforms: linux/amd64,linux/arm64
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=registry,ref=ghcr.io/thumbor/thumbor:buildcache-${{ matrix.python_version }}
cache-to: ${{ env.CACHE_TO }}
build-args: |
THUMBOR_VERSION=${{ env.THUMBOR_VERSION }}
PYTHON_VERSION=${{ matrix.python_version }}