From cb651d52e50f90413d786d3a9e385601832c8fea Mon Sep 17 00:00:00 2001 From: Stefanuk12 <42220813+Stefanuk12@users.noreply.github.com> Date: Sat, 19 Apr 2025 22:02:10 +0100 Subject: [PATCH] refactor: merge docker image publish back into release --- .github/workflows/registry.yaml | 80 --------------------------------- .github/workflows/release.yaml | 64 ++++++++++++++++++++++++++ 2 files changed, 64 insertions(+), 80 deletions(-) delete mode 100644 .github/workflows/registry.yaml diff --git a/.github/workflows/registry.yaml b/.github/workflows/registry.yaml deleted file mode 100644 index 1d08290..0000000 --- a/.github/workflows/registry.yaml +++ /dev/null @@ -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<> $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 }} \ No newline at end of file diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index 96a4457..d76a7c7 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -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<> $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 }} \ No newline at end of file