-
Notifications
You must be signed in to change notification settings - Fork 0
113 lines (110 loc) · 4.14 KB
/
docker.yml
File metadata and controls
113 lines (110 loc) · 4.14 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
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 }}