mirror of
https://github.com/pesde-pkg/pesde.git
synced 2025-05-04 10:33:47 +01:00
refactor: use matrix for build
This commit is contained in:
parent
5c454687a1
commit
55b9efc5f6
1 changed files with 104 additions and 24 deletions
128
.github/workflows/release.yaml
vendored
128
.github/workflows/release.yaml
vendored
|
@ -14,7 +14,7 @@ jobs:
|
||||||
version: ${{ steps.extract_version.outputs.value }}
|
version: ${{ steps.extract_version.outputs.value }}
|
||||||
registry_version: ${{ steps.extract_registry_version.outputs.value }}
|
registry_version: ${{ steps.extract_registry_version.outputs.value }}
|
||||||
registry_image: "ghcr.io/${{ steps.repository_owner.outputs.lowercase }}/registry"
|
registry_image: "ghcr.io/${{ steps.repository_owner.outputs.lowercase }}/registry"
|
||||||
registry_published: ${{ steps.registry_published.outputs.tag }}
|
registry_published: ${{ steps.registry_published.outputs.tag || 'not found' }}
|
||||||
found: ${{ steps.ensure_not_published.outputs.FOUND }}
|
found: ${{ steps.ensure_not_published.outputs.FOUND }}
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v4
|
||||||
|
@ -42,6 +42,7 @@ jobs:
|
||||||
- name: Get Docker image publish status
|
- name: Get Docker image publish status
|
||||||
uses: tyriis/docker-image-tag-exists@v2.1.0
|
uses: tyriis/docker-image-tag-exists@v2.1.0
|
||||||
id: registry_published
|
id: registry_published
|
||||||
|
continue-on-error: true
|
||||||
with:
|
with:
|
||||||
registry: ghcr.io
|
registry: ghcr.io
|
||||||
repository: "${{ steps.repository_owner.outputs.lowercase }}/registry"
|
repository: "${{ steps.repository_owner.outputs.lowercase }}/registry"
|
||||||
|
@ -180,18 +181,37 @@ jobs:
|
||||||
prerelease: ${{ steps.is_prerelease.outputs.value }}
|
prerelease: ${{ steps.is_prerelease.outputs.value }}
|
||||||
files: artifacts/*
|
files: artifacts/*
|
||||||
|
|
||||||
publish-registry-image:
|
build-registry-image:
|
||||||
name: Build and publish Docker image
|
name: Build Docker image
|
||||||
runs-on: ubuntu-latest
|
|
||||||
needs: [ prepare ]
|
needs: [ prepare ]
|
||||||
if: ${{ needs.prepare.outputs.registry_published == 'not found' }}
|
if: ${{ needs.prepare.outputs.registry_published == 'not found' }}
|
||||||
permissions:
|
permissions:
|
||||||
contents: read
|
contents: read
|
||||||
packages: write
|
packages: write
|
||||||
|
strategy:
|
||||||
|
fail-fast: false
|
||||||
|
matrix:
|
||||||
|
include:
|
||||||
|
- os: ubuntu-latest
|
||||||
|
platform: linux/amd64
|
||||||
|
- os: ubuntu-24.04-arm
|
||||||
|
platform: linux/arm64
|
||||||
|
runs-on: ${{ matrix.os }}
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout repository
|
- name: Checkout repository
|
||||||
uses: actions/checkout@v3
|
uses: actions/checkout@v3
|
||||||
|
|
||||||
|
- name: Prepare
|
||||||
|
run: |
|
||||||
|
platform=${{ matrix.platform }}
|
||||||
|
echo "PLATFORM_PAIR=${platform//\//-}" >> $GITHUB_ENV
|
||||||
|
|
||||||
|
- name: Docker meta
|
||||||
|
id: meta
|
||||||
|
uses: docker/metadata-action@v5
|
||||||
|
with:
|
||||||
|
images: ${{ needs.prepare.outputs.registry_image }}
|
||||||
|
|
||||||
- name: Log in to the Container registry
|
- name: Log in to the Container registry
|
||||||
uses: docker/login-action@v3
|
uses: docker/login-action@v3
|
||||||
with:
|
with:
|
||||||
|
@ -199,22 +219,6 @@ jobs:
|
||||||
username: ${{ github.actor }}
|
username: ${{ github.actor }}
|
||||||
password: ${{ secrets.GITHUB_TOKEN }}
|
password: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
|
||||||
- name: Set Tags
|
|
||||||
id: set_tags
|
|
||||||
shell: bash
|
|
||||||
run: |
|
|
||||||
TAGS=$({
|
|
||||||
echo "${{ needs.prepare.outputs.registry_image }}:${{ github.sha }}"
|
|
||||||
echo "${{ needs.prepare.outputs.registry_image }}:${${{ github.sha }}:0:7}"
|
|
||||||
echo "${{ needs.prepare.outputs.registry_image }}:${{ needs.prepare.outputs.registry_version }}"
|
|
||||||
if [[ "${{ needs.prepare.outputs.registry_version }}" != *"-"* ]]; then
|
|
||||||
echo "${{ needs.prepare.outputs.registry_image }}:latest"
|
|
||||||
fi
|
|
||||||
})
|
|
||||||
echo "tags<<EOF" >> $GITHUB_OUTPUT
|
|
||||||
echo "$TAGS" >> $GITHUB_OUTPUT
|
|
||||||
echo "EOF" >> $GITHUB_OUTPUT
|
|
||||||
|
|
||||||
- name: Set up QEMU
|
- name: Set up QEMU
|
||||||
uses: docker/setup-qemu-action@v3
|
uses: docker/setup-qemu-action@v3
|
||||||
|
|
||||||
|
@ -222,9 +226,85 @@ jobs:
|
||||||
uses: docker/setup-buildx-action@v3
|
uses: docker/setup-buildx-action@v3
|
||||||
|
|
||||||
- name: Build and push Docker image
|
- name: Build and push Docker image
|
||||||
|
id: build
|
||||||
uses: docker/build-push-action@v6
|
uses: docker/build-push-action@v6
|
||||||
with:
|
with:
|
||||||
context: .
|
platforms: ${{ matrix.platform }}
|
||||||
platforms: linux/amd64,linux/arm64
|
labels: ${{ steps.meta.outputs.labels }}
|
||||||
push: true
|
tags: ${{ needs.prepare.outputs.registry_image }}
|
||||||
tags: ${{ steps.set_tags.outputs.tags }}
|
outputs: type=image,push-by-digest=true,name-canonical=true,push=true
|
||||||
|
|
||||||
|
- name: Export digest
|
||||||
|
run: |
|
||||||
|
mkdir -p ${{ runner.temp }}/digests
|
||||||
|
digest="${{ steps.build.outputs.digest }}"
|
||||||
|
touch "${{ runner.temp }}/digests/${digest#sha256:}"
|
||||||
|
|
||||||
|
- name: Upload digest
|
||||||
|
uses: actions/upload-artifact@v4
|
||||||
|
with:
|
||||||
|
name: digests-${{ env.PLATFORM_PAIR }}
|
||||||
|
path: ${{ runner.temp }}/digests/*
|
||||||
|
if-no-files-found: error
|
||||||
|
retention-days: 1
|
||||||
|
|
||||||
|
publish-registry-image:
|
||||||
|
name: Publish Docker image
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
needs:
|
||||||
|
- prepare
|
||||||
|
- build-registry-image
|
||||||
|
steps:
|
||||||
|
- name: Download digests
|
||||||
|
uses: actions/download-artifact@v4
|
||||||
|
with:
|
||||||
|
path: ${{ runner.temp }}/digests
|
||||||
|
pattern: digests-*
|
||||||
|
merge-multiple: true
|
||||||
|
|
||||||
|
- name: Login to Docker Hub
|
||||||
|
uses: docker/login-action@v3
|
||||||
|
with:
|
||||||
|
registry: https://ghcr.io
|
||||||
|
username: ${{ github.actor }}
|
||||||
|
password: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
|
||||||
|
- name: Set up Docker Buildx
|
||||||
|
uses: docker/setup-buildx-action@v3
|
||||||
|
|
||||||
|
- name: Docker meta
|
||||||
|
id: meta
|
||||||
|
uses: docker/metadata-action@v5
|
||||||
|
with:
|
||||||
|
images: ${{ needs.prepare.outputs.registry_image }}
|
||||||
|
tags: |
|
||||||
|
type=ref,event=branch
|
||||||
|
type=ref,event=pr
|
||||||
|
type=semver,pattern={{version}}
|
||||||
|
type=semver,pattern={{major}}.{{minor}}
|
||||||
|
|
||||||
|
- name: Set Tags
|
||||||
|
id: set_tags
|
||||||
|
shell: bash
|
||||||
|
run: |
|
||||||
|
GITHUB_SHORT_SHA=${GITHUB_SHA:0:7}
|
||||||
|
TAGS=$({
|
||||||
|
echo "-t ${{ needs.prepare.outputs.registry_image }}:${{ github.sha }}";
|
||||||
|
echo "-t ${{ needs.prepare.outputs.registry_image }}:${GITHUB_SHORT_SHA}";
|
||||||
|
echo "-t ${{ needs.prepare.outputs.registry_image }}:${{ needs.prepare.outputs.version }}";
|
||||||
|
if [[ "${{ needs.prepare.outputs.version }}" != *"-"* ]]; then
|
||||||
|
echo "-t ${{ needs.prepare.outputs.registry_image }}:latest";
|
||||||
|
fi;
|
||||||
|
} | paste -sd " " -)
|
||||||
|
echo "tags=$TAGS" >> $GITHUB_OUTPUT
|
||||||
|
|
||||||
|
- name: Create manifest list and push
|
||||||
|
working-directory: ${{ runner.temp }}/digests
|
||||||
|
run: |
|
||||||
|
docker buildx imagetools create ${{ steps.set_tags.outputs.tags }} \
|
||||||
|
$(printf '${{ needs.prepare.outputs.registry_image }}@sha256:%s ' *)
|
||||||
|
|
||||||
|
- name: Inspect image
|
||||||
|
run: |
|
||||||
|
docker buildx imagetools inspect ${{ needs.prepare.outputs.registry_image }}:${{ needs.prepare.outputs.registry_version }}
|
||||||
|
|
Loading…
Add table
Reference in a new issue