refactor: merge docker image publish back into release

This commit is contained in:
Stefanuk12 2025-04-19 22:02:10 +01:00
parent 267b4bd688
commit cb651d52e5
No known key found for this signature in database
GPG key ID: 7E19B1E4C83A2A35
2 changed files with 64 additions and 80 deletions

View file

@ -1,80 +0,0 @@
name: Release Registry
on:
workflow_dispatch:
jobs:
prepare:
name: Extract relevant information
runs-on: ubuntu-latest
permissions:
contents: read
steps:
- name: Checkout
uses: actions/checkout@master
- name: Read Cargo TOML
uses: SebRollen/toml-action@v1.0.2
id: read_toml
with:
file: "./registry/Cargo.toml"
field: "package.version"
- name: Lowercase repository owner
uses: ASzc/change-string-case-action@v6
id: repository_owner
with:
string: ${{ github.repository_owner }}
outputs:
version: ${{ steps.read_toml.outputs.value }}
registry_image: "ghcr.io/${{ steps.repository_owner.outputs.lowercase }}/registry"
publish-registry-image:
name: Build and publish Docker package
runs-on: ubuntu-latest
needs: [ prepare ]
permissions:
contents: read
packages: write
env:
VERSION: ${{ needs.prepare.outputs.version }}
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Log in to the Container registry
uses: docker/login-action@v3
with:
registry: https://ghcr.io
username: ${{ github.actor }}
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 }}:${{ needs.prepare.outputs.version }}"
if [[ "${{ needs.prepare.outputs.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
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Build and push Docker image
uses: docker/build-push-action@v6
with:
context: .
platforms: linux/amd64,linux/arm64
push: true
tags: ${{ steps.set_tags.outputs.tags }}

View file

@ -12,6 +12,8 @@ jobs:
runs-on: ubuntu-latest
outputs:
version: ${{ steps.extract_version.outputs.VERSION }}
version_registry: ${{ steps.extract_version_registry.outputs.value }}
registry_image: "ghcr.io/${{ steps.repository_owner.outputs.lowercase }}/registry"
found: ${{ steps.ensure_not_published.outputs.FOUND }}
steps:
- uses: actions/checkout@v4
@ -22,6 +24,19 @@ jobs:
VERSION=$(echo ${{ github.ref_name }} | cut -d'+' -f1 | cut -c 2-)
echo "VERSION=$VERSION" >> "$GITHUB_OUTPUT"
- name: Extract registry version
uses: SebRollen/toml-action@v1.0.2
id: extract_version_registry
with:
file: "./registry/Cargo.toml"
field: "package.version"
- name: Lowercase repository owner
uses: ASzc/change-string-case-action@v6
id: repository_owner
with:
string: ${{ github.repository_owner }}
- name: Ensure not published
id: ensure_not_published
shell: bash
@ -150,3 +165,52 @@ jobs:
draft: true
prerelease: ${{ startsWith(env.VERSION, '0') }}
files: artifacts/*
publish-registry-image:
name: Build and publish Docker package
runs-on: ubuntu-latest
needs: [ prepare ]
permissions:
contents: read
packages: write
env:
VERSION: ${{ needs.prepare.outputs.version }}
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Log in to the Container registry
uses: docker/login-action@v3
with:
registry: https://ghcr.io
username: ${{ github.actor }}
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 }}:${{ needs.prepare.outputs.version }}"
if [[ "${{ needs.prepare.outputs.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
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Build and push Docker image
uses: docker/build-push-action@v6
with:
context: .
platforms: linux/amd64,linux/arm64
push: true
tags: ${{ steps.set_tags.outputs.tags }}