forked from sopel-irc/docker-sopel
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use docker/metadata-action to generate tags and labels Add second docker/login-action to support GHCR Use docker/setup-qemu-action for multi-arch build Update docker/serup-buildx-action to v3 Fix nightly to only be built for 3.12 and fix image tags
- Loading branch information
1 parent
138e111
commit 8d63832
Showing
1 changed file
with
71 additions
and
25 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 |
---|---|---|
|
@@ -31,14 +31,16 @@ jobs: | |
# Steps represent a sequence of tasks that will be executed as part of the job | ||
steps: | ||
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it | ||
- uses: actions/checkout@v4 | ||
- | ||
uses: actions/checkout@v4 | ||
|
||
- | ||
- | ||
name: Set up QEMU | ||
uses: docker/setup-qemu-action@v3 | ||
|
||
- | ||
name: Set up Docker Buildx | ||
id: buildx | ||
uses: docker/setup-buildx-action@v3 | ||
with: | ||
install: true | ||
|
||
- | ||
name: Inspect builder | ||
|
@@ -49,28 +51,60 @@ jobs: | |
echo "Flags: ${{ steps.buildx.outputs.flags }}" | ||
echo "Platforms: ${{ steps.buildx.outputs.platforms }}" | ||
- name: Generate versions | ||
- | ||
name: Get sopel version | ||
uses: HardNorth/[email protected] | ||
with: | ||
version-source: file | ||
version-file: Dockerfile | ||
version-file-extraction-pattern: '(?<=SOPEL_BRANCH=v).+' | ||
|
||
- name: Inspect Version | ||
id: tags | ||
env: | ||
PYTHON_TAG: ${{ matrix.python_images }} | ||
IMAGE: ${{ secrets.DOCKER_SOPEL_IMAGE_NAME }} | ||
version: ${{ env.RELEASE_VERSION }} | ||
run: | | ||
if [ "${{ github.event_name }}" == "pull_request" ]; then IMAGE="sopel"; fi | ||
TAGS="${IMAGE}:${version}-py${PYTHON_TAG},${IMAGE}:${version%.*}-py${PYTHON_TAG},${IMAGE}:${version%.*.*}-py${PYTHON_TAG}" | ||
if [[ "x${{ matrix.python_images }}" == "x${{ env.default_python }}" ]] && [[ "${{ github.event_name }}" == "push" || "${{ github.event_name }}" == "workflow_dispatch" ]]; then | ||
TAGS="${TAGS},${IMAGE}:${version},${IMAGE}:${version%.*},${IMAGE}:${version%.*.*},${IMAGE}:latest" | ||
elif [[ "${{ github.event_name }}" == "schedule" ]]; then | ||
TAGS="${IMAGE}:nightly" | ||
fi | ||
echo ::set-output name=tags::${TAGS} | ||
- | ||
name: Docker meta | ||
id: meta-default | ||
uses: docker/metadata-action@v5 | ||
if: matrix.python_images == env.default_python | ||
with: | ||
images: | | ||
${{ vars.DOCKER_HUB_IMAGE_NAME }} | ||
ghcr.io/${{ github.repository_owner }}/sopel | ||
flavor: | | ||
latest=true | ||
tags: | | ||
# Python full version | ||
type=semver,pattern={{version}},value=v${{ env.RELEASE_VERSION }},suffix=-py${{ matrix.python_images }} | ||
type=semver,pattern={{major}}.{{minor}},value=v${{ env.RELEASE_VERSION }},suffix=-py${{ matrix.python_images }} | ||
type=semver,pattern={{major}},value=v${{ env.RELEASE_VERSION }},suffix=-py${{ matrix.python_images }} | ||
# Python 3 | ||
type=semver,pattern={{major}},value=v${{ env.RELEASE_VERSION }},suffix=-py3 | ||
type=semver,pattern={{major}}.{{minor}},value=v${{ env.RELEASE_VERSION }},suffix=-py3 | ||
type=semver,pattern={{version}},value=v${{ env.RELEASE_VERSION }},suffix=-py3 | ||
# Version only | ||
type=semver,pattern={{major}},value=v${{ env.RELEASE_VERSION }} | ||
type=semver,pattern={{major}}.{{minor}},value=v${{ env.RELEASE_VERSION }} | ||
type=semver,pattern={{version}},value=v${{ env.RELEASE_VERSION }} | ||
type=ref,event=branch | ||
- | ||
name: Docker meta | ||
id: meta-alt-python | ||
uses: docker/metadata-action@v5 | ||
if: matrix.python_images != env.default_python | ||
with: | ||
images: | | ||
${{ vars.DOCKER_HUB_IMAGE_NAME }} | ||
ghcr.io/${{ github.repository_owner }}/sopel | ||
flavor: | | ||
latest=false | ||
suffix=-py${{ matrix.python_images }} | ||
tags: | | ||
# Python full version | ||
type=semver,pattern={{version}},value=v${{ env.RELEASE_VERSION }} | ||
type=semver,pattern={{major}}.{{minor}},value=v${{ env.RELEASE_VERSION }} | ||
type=semver,pattern={{major}},value=v${{ env.RELEASE_VERSION }} | ||
- | ||
name: Login to Docker Hub | ||
|
@@ -79,27 +113,39 @@ jobs: | |
with: | ||
username: ${{ secrets.DOCKER_HUB_USERNAME }} | ||
password: ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }} | ||
- | ||
name: Login to GitHub Container Registry | ||
uses: docker/login-action@v3 | ||
if: github.event_name != 'pull_request' | ||
with: | ||
registry: ghcr.io | ||
username: ${{ github.actor }} | ||
password: ${{ secrets.GITHUB_TOKEN }} | ||
|
||
- | ||
name: Build SOPEL for ${{ matrix.python_images }} | ||
uses: docker/build-push-action@v5 | ||
if: github.event_name != 'schedule' | ||
with: | ||
builder: ${{ steps.buildx.outputs.name }} | ||
context: . | ||
file: ./Dockerfile | ||
build-args: PYTHON_TAG=${{ matrix.python_images }}-alpine | ||
platforms: linux/amd64,linux/arm64,linux/arm/v7,linux/arm/v6,linux/s390x | ||
push: ${{ github.event_name != 'pull_request' }} | ||
tags: ${{ steps.tags.outputs.tags }} | ||
tags: ${{ steps.meta-default.outputs.tags }}${{ steps.meta-alt-python.outputs.tags }} | ||
labels: ${{ steps.meta-default.outputs.labels }}${{ steps.meta-alt-python.outputs.labels }} | ||
|
||
- | ||
name: Build Nightly SOPEL for ${{ matrix.python_images }} | ||
uses: docker/build-push-action@v5 | ||
if: github.event_name == 'schedule' && matrix.python_images == env.default_python | ||
with: | ||
builder: ${{ steps.buildx.outputs.name }} | ||
context: . | ||
file: ./Dockerfile | ||
build-args: | | ||
PYTHON_TAG=${{ matrix.python_images }}-alpine | ||
SOPEL_BRANCH=master | ||
platforms: linux/amd64,linux/arm64,linux/arm/v7,linux/arm/v6,linux/s390x | ||
push: ${{ github.event_name != 'pull_request' }} | ||
tags: ${{ steps.tags.outputs.tags }} | ||
tags: ${{ vars.DOCKER_HUB_IMAGE_NAME }}:nightly,ghcr.io/${{ github.repository_owner }}/sopel:nightly | ||
labels: ${{ steps.meta-default.outputs.labels }}${{ steps.meta-alt-python.outputs.labels }} |