-
Notifications
You must be signed in to change notification settings - Fork 0
157 lines (150 loc) · 4.78 KB
/
release.yml
File metadata and controls
157 lines (150 loc) · 4.78 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
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
name: Release
on:
push:
tags:
- "[0-9]+.[0-9]+.[0-9]+"
permissions:
contents: write
packages: write
env:
CARGO_TERM_COLOR: always
jobs:
build:
name: build (${{ matrix.target }})
runs-on: ${{ matrix.runner }}
strategy:
fail-fast: false
matrix:
include:
- target: x86_64-unknown-linux-gnu
runner: ubuntu-latest
- target: x86_64-unknown-linux-musl
runner: ubuntu-latest
install: |
sudo apt-get update
sudo apt-get install -y --no-install-recommends musl-tools
- target: aarch64-unknown-linux-gnu
runner: ubuntu-24.04-arm
- target: aarch64-unknown-linux-musl
runner: ubuntu-24.04-arm
install: |
sudo apt-get update
sudo apt-get install -y --no-install-recommends musl-tools
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
with:
targets: ${{ matrix.target }}
- uses: arduino/setup-protoc@v3
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}
- name: install build deps
if: matrix.install
run: ${{ matrix.install }}
- uses: Swatinem/rust-cache@v2
with:
key: release-${{ matrix.target }}
- name: build
run: cargo build --release --target ${{ matrix.target }}
- name: package
run: |
set -eu
tag="${GITHUB_REF_NAME}"
out="pfp-${tag}-${{ matrix.target }}"
mkdir -p dist
cp "target/${{ matrix.target }}/release/pfp" "dist/${out}"
cd dist
tar czf "${out}.tar.gz" "${out}"
sha256sum "${out}.tar.gz" > "${out}.tar.gz.sha256"
- uses: actions/upload-artifact@v4
with:
name: pfp-${{ matrix.target }}
path: dist/*
release:
name: publish github release
needs: build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/download-artifact@v4
with:
path: artifacts
merge-multiple: true
- name: list artifacts
run: ls -la artifacts/
- name: create or update release
uses: softprops/action-gh-release@v2
with:
tag_name: ${{ github.ref_name }}
files: artifacts/*
generate_release_notes: true
fail_on_unmatched_files: true
# Build the distroless image natively on each arch (no QEMU compile), push by
# digest, then stitch a multi-arch manifest. See docs.docker.com multi-platform.
docker:
name: docker (${{ matrix.platform }})
runs-on: ${{ matrix.runner }}
strategy:
fail-fast: false
matrix:
include:
- platform: linux/amd64
runner: ubuntu-latest
arch: amd64
- platform: linux/arm64
runner: ubuntu-24.04-arm
arch: arm64
steps:
- uses: actions/checkout@v4
- uses: docker/setup-buildx-action@v3
- uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: build and push by digest
id: build
uses: docker/build-push-action@v6
with:
context: .
platforms: ${{ matrix.platform }}
cache-from: type=gha,scope=docker-${{ matrix.arch }}
cache-to: type=gha,mode=max,scope=docker-${{ matrix.arch }}
outputs: type=image,name=ghcr.io/${{ github.repository }},push-by-digest=true,name-canonical=true,push=true
- name: export digest
run: |
mkdir -p /tmp/digests
digest="${{ steps.build.outputs.digest }}"
touch "/tmp/digests/${digest#sha256:}"
- uses: actions/upload-artifact@v4
with:
name: digest-${{ matrix.arch }}
path: /tmp/digests/*
if-no-files-found: error
retention-days: 1
docker-manifest:
name: docker manifest
needs: docker
runs-on: ubuntu-latest
steps:
- uses: actions/download-artifact@v4
with:
path: /tmp/digests
pattern: digest-*
merge-multiple: true
- uses: docker/setup-buildx-action@v3
- uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: create manifest list and push
working-directory: /tmp/digests
run: |
img=ghcr.io/${{ github.repository }}
docker buildx imagetools create \
-t "${img}:${{ github.ref_name }}" \
-t "${img}:latest" \
$(printf "${img}@sha256:%s " *)
- name: inspect
run: docker buildx imagetools inspect ghcr.io/${{ github.repository }}:${{ github.ref_name }}