-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
574 additions
and
570 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,102 +1,102 @@ | ||
name: Docker images | ||
|
||
on: | ||
# On release events (also when a published release is converted from/to prerelease), push all patterns | ||
release: | ||
types: [released, prereleased] | ||
# On each commit merged into main, push sha and branch patterns to prefect-dev | ||
push: | ||
branches: main | ||
# On workflow_dispatch, push sha and branch patterns to prefect-dev | ||
workflow_dispatch: | ||
# On release events (also when a published release is converted from/to prerelease), push all patterns | ||
release: | ||
types: [released, prereleased] | ||
# On each commit merged into main, push sha and branch patterns to prefect-dev | ||
push: | ||
branches: main | ||
# On workflow_dispatch, push sha and branch patterns to prefect-dev | ||
workflow_dispatch: | ||
|
||
jobs: | ||
publish-docker-images: | ||
name: Build and publish to DockerHub | ||
runs-on: ubuntu-latest | ||
environment: ${{ ( github.event_name == 'release' && 'prod' ) || 'dev' }} | ||
strategy: | ||
matrix: | ||
flavor: | ||
- "" | ||
- "-conda" | ||
- "-kubernetes" | ||
python-version: | ||
- "3.8" | ||
- "3.9" | ||
- "3.10" | ||
- "3.11" | ||
- "3.12" | ||
publish-docker-images: | ||
name: Build and publish to DockerHub | ||
runs-on: ubuntu-latest | ||
environment: ${{ ( github.event_name == 'release' && 'prod' ) || 'dev' }} | ||
strategy: | ||
matrix: | ||
flavor: | ||
- "" | ||
- "-conda" | ||
- "-kubernetes" | ||
python-version: | ||
- "3.8" | ||
- "3.9" | ||
- "3.10" | ||
- "3.11" | ||
- "3.12" | ||
|
||
steps: | ||
- name: Set up QEMU | ||
uses: docker/setup-qemu-action@v3 | ||
steps: | ||
- name: Set up QEMU | ||
uses: docker/setup-qemu-action@v3 | ||
|
||
- name: Set up Docker Buildx | ||
uses: docker/setup-buildx-action@v3 | ||
- name: Set up Docker Buildx | ||
uses: docker/setup-buildx-action@v3 | ||
|
||
- name: Login to DockerHub | ||
uses: docker/login-action@v3 | ||
with: | ||
username: ${{ secrets.DOCKERHUB_USERNAME }} | ||
password: ${{ secrets.DOCKERHUB_TOKEN }} | ||
- name: Login to DockerHub | ||
uses: docker/login-action@v3 | ||
with: | ||
username: ${{ secrets.DOCKERHUB_USERNAME }} | ||
password: ${{ secrets.DOCKERHUB_TOKEN }} | ||
|
||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
with: | ||
fetch-depth: 0 | ||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
with: | ||
fetch-depth: 0 | ||
|
||
- name: Generate tags for prefecthq/prefect-dev | ||
id: metadata-dev | ||
uses: docker/metadata-action@v5 | ||
# do not generate the development tags on release events | ||
if: ${{ github.event_name != 'release' }} | ||
with: | ||
images: prefecthq/prefect-dev | ||
tags: | | ||
type=raw,value=${{ github.ref_name }},suffix=-python${{ matrix.python-version }}${{ matrix.flavor }} | ||
type=sha,suffix=-python${{ matrix.python-version }}${{ matrix.flavor }} | ||
flavor: | | ||
latest=false | ||
- name: Generate tags for prefecthq/prefect-dev | ||
id: metadata-dev | ||
uses: docker/metadata-action@v5 | ||
# do not generate the development tags on release events | ||
if: ${{ github.event_name != 'release' }} | ||
with: | ||
images: prefecthq/prefect-dev | ||
tags: | | ||
type=raw,value=${{ github.ref_name }},suffix=-python${{ matrix.python-version }}${{ matrix.flavor }} | ||
type=sha,suffix=-python${{ matrix.python-version }}${{ matrix.flavor }} | ||
flavor: | | ||
latest=false | ||
- name: Determine latest tag | ||
# https://stackoverflow.com/a/75079768/5511061 | ||
run: | | ||
echo "LATEST_TAG=$(curl -qsSL \ | ||
-H "Accept: application/vnd.github+json" \ | ||
-H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" \ | ||
-H "X-GitHub-Api-Version: 2022-11-28" \ | ||
"${{ github.api_url }}/repos/${{ github.repository }}/releases/latest" \ | ||
| jq -r .tag_name)" >> $GITHUB_ENV | ||
- name: Determine latest tag | ||
# https://stackoverflow.com/a/75079768/5511061 | ||
run: | | ||
echo "LATEST_TAG=$(curl -qsSL \ | ||
-H "Accept: application/vnd.github+json" \ | ||
-H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" \ | ||
-H "X-GitHub-Api-Version: 2022-11-28" \ | ||
"${{ github.api_url }}/repos/${{ github.repository }}/releases/latest" \ | ||
| jq -r .tag_name)" >> $GITHUB_ENV | ||
- name: Generate tags for prefecthq/prefect | ||
id: metadata-prod | ||
uses: docker/metadata-action@v5 | ||
# only generate the production tags on release events | ||
if: ${{ github.event_name == 'release' }} | ||
with: | ||
images: prefecthq/prefect | ||
# push `latest`, `X.Y` and `X` tags only when the release is not marked as prerelease | ||
# push `latest` and `X` tags only when the release is marked as latest | ||
tags: | | ||
type=pep440,pattern={{version}},suffix=-python${{ matrix.python-version }}${{ matrix.flavor }} | ||
type=pep440,pattern={{major}}.{{minor}},suffix=-python${{ matrix.python-version }}${{ matrix.flavor }},enable=${{ github.event.release.prerelease == false }} | ||
type=pep440,pattern={{major}},suffix=-python${{ matrix.python-version }}${{ matrix.flavor }},enable=${{ github.event.release.prerelease == false && github.ref_name == env.LATEST_TAG }} | ||
type=raw,value=2-latest${{ matrix.flavor }},enable=${{ matrix.python-version == '3.10' && github.event.release.prerelease == false && github.ref_name == env.LATEST_TAG }} | ||
flavor: | | ||
latest=false | ||
- name: Generate tags for prefecthq/prefect | ||
id: metadata-prod | ||
uses: docker/metadata-action@v5 | ||
# only generate the production tags on release events | ||
if: ${{ github.event_name == 'release' }} | ||
with: | ||
images: prefecthq/prefect | ||
# push `latest`, `X.Y` and `X` tags only when the release is not marked as prerelease | ||
# push `latest` and `X` tags only when the release is marked as latest | ||
tags: | | ||
type=pep440,pattern={{version}},suffix=-python${{ matrix.python-version }}${{ matrix.flavor }} | ||
type=pep440,pattern={{major}}.{{minor}},suffix=-python${{ matrix.python-version }}${{ matrix.flavor }},enable=${{ github.event.release.prerelease == false }} | ||
type=pep440,pattern={{major}},suffix=-python${{ matrix.python-version }}${{ matrix.flavor }},enable=${{ github.event.release.prerelease == false && github.ref_name == env.LATEST_TAG }} | ||
type=raw,value=2-latest${{ matrix.flavor }},enable=${{ matrix.python-version == '3.10' && github.event.release.prerelease == false && github.ref_name == env.LATEST_TAG }} | ||
flavor: | | ||
latest=false | ||
- name: Build and push image | ||
uses: docker/build-push-action@v5 | ||
with: | ||
context: . | ||
platforms: linux/amd64,linux/arm64 | ||
build-args: | | ||
PYTHON_VERSION=${{ matrix.python-version }} | ||
${{ ( endsWith(matrix.flavor, 'conda') && 'BASE_IMAGE=prefect-conda' ) || '' }} | ||
${{ ( endsWith(matrix.flavor, 'kubernetes') && 'EXTRA_PIP_PACKAGES=prefect-kubernetes' ) || '' }} | ||
tags: ${{ join(steps.metadata-dev.outputs.tags) }},${{ join(steps.metadata-prod.outputs.tags) }} | ||
labels: ${{ steps.metadata-dev.outputs.labels }} | ||
push: true | ||
pull: true | ||
provenance: false | ||
- name: Build and push image | ||
uses: docker/build-push-action@v5 | ||
with: | ||
context: . | ||
platforms: linux/amd64,linux/arm64 | ||
build-args: | | ||
PYTHON_VERSION=${{ matrix.python-version }} | ||
${{ ( endsWith(matrix.flavor, 'conda') && 'BASE_IMAGE=prefect-conda' ) || '' }} | ||
${{ ( endsWith(matrix.flavor, 'kubernetes') && 'EXTRA_PIP_PACKAGES=prefect-kubernetes' ) || '' }} | ||
tags: ${{ join(steps.metadata-dev.outputs.tags) }},${{ join(steps.metadata-prod.outputs.tags) }} | ||
labels: ${{ steps.metadata-dev.outputs.labels }} | ||
push: true | ||
pull: true | ||
provenance: false |
Oops, something went wrong.