11name : docker
22
33on :
4- push :
5- tags :
6- - " v*"
74 workflow_dispatch :
85 inputs :
96 tag :
@@ -16,67 +13,70 @@ jobs:
1613 runs-on : ubuntu-latest
1714 permissions :
1815 contents : read
16+ packages : write
1917 env :
20- IMAGE : ${{ github.repository_owner }}/diff-coverage
21- ALPINE_VERSION : " 3.20"
18+ IMAGE : ${{ github.repository_owner }}/diff-coverage-internal
19+ GHCR_IMAGE : ghcr.io/${{ github.repository_owner }}/diff-coverage-internal
20+ strategy :
21+ matrix :
22+ include :
23+ - variant : alpine
24+ base_image : alpine:3.20
25+ rust_target_suffix : musl
26+ tag_suffix : alpine-3.20
27+ - variant : debian
28+ base_image : debian:trixie
29+ rust_target_suffix : gnu
30+ tag_suffix : debian-trixie
2231 steps :
2332 - uses : actions/checkout@v4
24- - name : Set version
33+ with :
34+ fetch-depth : 0
35+ - name : Set version (manual)
36+ if : github.event_name == 'workflow_dispatch'
2537 run : |
2638 TAG="${{ inputs.tag }}"
27- if [ -z "$TAG" ]; then TAG="$GITHUB_REF_NAME"; fi
39+ if [ -z "$TAG" ]; then
40+ echo "Release tag input is required" >&2
41+ exit 1
42+ fi
2843 VERSION="${TAG#v}"
2944 echo "TAG=$TAG" >> "$GITHUB_ENV"
3045 echo "VERSION=$VERSION" >> "$GITHUB_ENV"
31- - name : Wait for release binaries
32- env :
33- GH_TOKEN : ${{ github.token }}
34- run : |
35- set -euo pipefail
36- for i in {1..60}; do
37- assets="$(gh release view "$TAG" --json assets --jq '.assets[].name' || true)"
38- if echo "$assets" | grep -q "diff-coverage-$TAG-x86_64-unknown-linux-musl" \
39- && echo "$assets" | grep -q "diff-coverage-$TAG-aarch64-unknown-linux-musl"; then
40- exit 0
41- fi
42- echo "Waiting for release assets for $TAG..."
43- sleep 10
44- done
45- echo "Release assets not found for $TAG"
46- exit 1
4746 - name : Download release binaries
4847 env :
4948 GH_TOKEN : ${{ github.token }}
5049 run : |
5150 mkdir -p dist
52- gh release download "$TAG" --pattern "diff-coverage-$TAG-x86_64-unknown-linux-musl" --dir dist
53- gh release download "$TAG" --pattern "diff-coverage-$TAG-aarch64-unknown-linux-musl" --dir dist
54- mv "dist/diff-coverage-$TAG-x86_64-unknown-linux-musl" "dist/diff-coverage-x86_64-unknown-linux-musl"
55- mv "dist/diff-coverage-$TAG-aarch64-unknown-linux-musl" "dist/diff-coverage-aarch64-unknown-linux-musl"
56- chmod +x dist/diff-coverage-x86_64-unknown-linux-musl dist/diff-coverage-aarch64-unknown-linux-musl
51+ gh release download "$TAG" --pattern "diff-coverage-$TAG-x86_64-unknown-linux-${{ matrix.rust_target_suffix }}.tar.gz" --dir dist
52+ gh release download "$TAG" --pattern "diff-coverage-$TAG-aarch64-unknown-linux-${{ matrix.rust_target_suffix }}.tar.gz" --dir dist
53+ tar -xzf "dist/diff-coverage-$TAG-x86_64-unknown-linux-${{ matrix.rust_target_suffix }}.tar.gz" -C dist
54+ mv "dist/diff-coverage" "dist/diff-coverage-x86_64-unknown-linux-${{ matrix.rust_target_suffix }}"
55+ tar -xzf "dist/diff-coverage-$TAG-aarch64-unknown-linux-${{ matrix.rust_target_suffix }}.tar.gz" -C dist
56+ mv "dist/diff-coverage" "dist/diff-coverage-aarch64-unknown-linux-${{ matrix.rust_target_suffix }}"
57+ rm -f dist/*.tar.gz
58+ chmod +x dist/diff-coverage-x86_64-unknown-linux-${{ matrix.rust_target_suffix }} dist/diff-coverage-aarch64-unknown-linux-${{ matrix.rust_target_suffix }}
5759 - uses : docker/setup-buildx-action@v3
5860 - uses : docker/login-action@v3
5961 with :
6062 username : ${{ github.repository_owner }}
6163 password : ${{ secrets.DOCKERHUB_TOKEN }}
64+ - uses : docker/login-action@v3
65+ with :
66+ registry : ghcr.io
67+ username : ${{ github.actor }}
68+ password : ${{ secrets.GITHUB_TOKEN }}
6269 - name : Docker meta
6370 id : meta
6471 uses : docker/metadata-action@v5
6572 with :
66- images : ${{ env.IMAGE }}
73+ images : |
74+ ${{ env.IMAGE }}
75+ ${{ env.GHCR_IMAGE }}
6776 tags : |
68- type=raw,value=latest
69- type=semver,pattern={{version}},value=${{ env.VERSION }}
70- type=semver,pattern={{major}},value=${{ env.VERSION }}
71- type=semver,pattern={{major}}.{{minor}},value=${{ env.VERSION }}
72- type=raw,value=alpine
73- type=raw,value=alpine-${{ env.ALPINE_VERSION }}
74- type=semver,pattern={{version}},value=${{ env.VERSION }},suffix=-alpine
75- type=semver,pattern={{major}},value=${{ env.VERSION }},suffix=-alpine
76- type=semver,pattern={{major}}.{{minor}},value=${{ env.VERSION }},suffix=-alpine
77- type=semver,pattern={{version}},value=${{ env.VERSION }},suffix=-alpine-${{ env.ALPINE_VERSION }}
78- type=semver,pattern={{major}},value=${{ env.VERSION }},suffix=-alpine-${{ env.ALPINE_VERSION }}
79- type=semver,pattern={{major}}.{{minor}},value=${{ env.VERSION }},suffix=-alpine-${{ env.ALPINE_VERSION }}
77+ type=semver,pattern={{version}},value=${{ env.VERSION }},suffix=-${{ matrix.tag_suffix }}
78+ type=semver,pattern={{major}},value=${{ env.VERSION }},suffix=-${{ matrix.tag_suffix }}
79+ type=semver,pattern={{major}}.{{minor}},value=${{ env.VERSION }},suffix=-${{ matrix.tag_suffix }}
8080 - name : Build and push (linux)
8181 uses : docker/build-push-action@v5
8282 with :
8585 platforms : linux/amd64,linux/arm64
8686 push : true
8787 build-args : |
88- ALPINE_VERSION=${{ env.ALPINE_VERSION }}
88+ BASE_IMAGE=${{ matrix.base_image }}
89+ RUST_TARGET_SUFFIX=${{ matrix.rust_target_suffix }}
8990 tags : ${{ steps.meta.outputs.tags }}
90- labels : ${{ steps.meta.outputs.labels }}
91+ labels : ${{ steps.meta.outputs.labels }}
0 commit comments