docker #12
Workflow file for this run
This file contains hidden or 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
| name: docker | |
| on: | |
| workflow_dispatch: | |
| inputs: | |
| tag: | |
| description: "Release tag (e.g. v1.2.3)" | |
| required: true | |
| type: string | |
| jobs: | |
| linux: | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: read | |
| packages: write | |
| env: | |
| IMAGE: ${{ github.repository_owner }}/diff-coverage | |
| GHCR_IMAGE: ghcr.io/${{ github.repository_owner }}/diff-coverage | |
| strategy: | |
| matrix: | |
| include: | |
| - variant: alpine | |
| base_image: alpine:3.20 | |
| rust_target_suffix: musl | |
| tag_suffix: alpine-3.20 | |
| - variant: scratch | |
| base_image: scratch | |
| rust_target_suffix: musl | |
| tag_suffix: scratch | |
| - variant: debian | |
| base_image: debian:trixie | |
| rust_target_suffix: gnu | |
| tag_suffix: debian-trixie | |
| steps: | |
| - uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| - name: Set version (manual) | |
| if: github.event_name == 'workflow_dispatch' | |
| run: | | |
| TAG="${{ inputs.tag }}" | |
| if [ -z "$TAG" ]; then | |
| echo "Release tag input is required" >&2 | |
| exit 1 | |
| fi | |
| VERSION="${TAG#v}" | |
| echo "TAG=$TAG" >> "$GITHUB_ENV" | |
| echo "VERSION=$VERSION" >> "$GITHUB_ENV" | |
| - name: Download release binaries | |
| env: | |
| GH_TOKEN: ${{ github.token }} | |
| run: | | |
| mkdir -p dist | |
| gh release download "$TAG" --pattern "diff-coverage-$TAG-x86_64-unknown-linux-${{ matrix.rust_target_suffix }}.tar.gz" --dir dist | |
| gh release download "$TAG" --pattern "diff-coverage-$TAG-aarch64-unknown-linux-${{ matrix.rust_target_suffix }}.tar.gz" --dir dist | |
| tar -xzf "dist/diff-coverage-$TAG-x86_64-unknown-linux-${{ matrix.rust_target_suffix }}.tar.gz" -C dist | |
| mv "dist/diff-coverage" "dist/diff-coverage-x86_64-unknown-linux-${{ matrix.rust_target_suffix }}" | |
| tar -xzf "dist/diff-coverage-$TAG-aarch64-unknown-linux-${{ matrix.rust_target_suffix }}.tar.gz" -C dist | |
| mv "dist/diff-coverage" "dist/diff-coverage-aarch64-unknown-linux-${{ matrix.rust_target_suffix }}" | |
| rm -f dist/*.tar.gz | |
| chmod +x dist/diff-coverage-x86_64-unknown-linux-${{ matrix.rust_target_suffix }} dist/diff-coverage-aarch64-unknown-linux-${{ matrix.rust_target_suffix }} | |
| - uses: docker/setup-buildx-action@v3 | |
| - uses: docker/login-action@v3 | |
| with: | |
| username: ${{ github.repository_owner }} | |
| password: ${{ secrets.DOCKERHUB_TOKEN }} | |
| - uses: docker/login-action@v3 | |
| with: | |
| registry: ghcr.io | |
| username: ${{ github.actor }} | |
| password: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Docker meta | |
| id: meta | |
| uses: docker/metadata-action@v5 | |
| with: | |
| images: | | |
| ${{ env.IMAGE }} | |
| ${{ env.GHCR_IMAGE }} | |
| tags: | | |
| type=semver,pattern={{version}},value=${{ env.VERSION }},suffix=-${{ matrix.tag_suffix }} | |
| type=semver,pattern={{major}},value=${{ env.VERSION }},suffix=-${{ matrix.tag_suffix }} | |
| type=semver,pattern={{major}}.{{minor}},value=${{ env.VERSION }},suffix=-${{ matrix.tag_suffix }} | |
| - name: Build and push (linux) | |
| uses: docker/build-push-action@v5 | |
| with: | |
| context: . | |
| file: Dockerfile.release | |
| platforms: linux/amd64,linux/arm64 | |
| push: true | |
| build-args: | | |
| BASE_IMAGE=${{ matrix.base_image }} | |
| RUST_TARGET_SUFFIX=${{ matrix.rust_target_suffix }} | |
| tags: ${{ steps.meta.outputs.tags }} | |
| labels: ${{ steps.meta.outputs.labels }} | |
| update-dockerhub-description: | |
| needs: linux | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: read | |
| env: | |
| IMAGE: ${{ github.repository_owner }}/diff-coverage | |
| steps: | |
| - uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| - name: Update Docker Hub description | |
| uses: peter-evans/dockerhub-description@v5 | |
| with: | |
| username: ${{ github.repository_owner }} | |
| password: ${{ secrets.DOCKERHUB_TOKEN }} | |
| short-description: ${{ github.event.repository.description }} |