-
Notifications
You must be signed in to change notification settings - Fork 2
97 lines (94 loc) · 2.95 KB
/
image-release.yaml
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
name: Release docker images
on:
push:
branches:
- master
jobs:
build:
name: Build for ${{ matrix.docker-platform }}
strategy:
fail-fast: false
matrix:
include:
-
docker-platform: linux/amd64
cross-target: x86_64-unknown-linux-gnu
-
docker-platform: linux/arm64/v8
cross-target: aarch64-unknown-linux-gnu
runs-on: ubuntu-latest
steps:
-
name: Checkout
uses: actions/checkout@master
-
name: Setup rust toolchain
uses: actions-rs/toolchain@v1
with:
toolchain: 1.68.2
target: ${{ matrix.cross-target }}
override: true
-
name: Build binary using cross
uses: actions-rs/cargo@v1
with:
use-cross: true
command: build
args: --manifest-path server/Cargo.toml --target ${{ matrix.cross-target }} --release
-
name: Upload artifact to collect in next job
uses: actions/upload-artifact@v3
with:
name: ${{ matrix.cross-target }}
path: server/target/${{ matrix.cross-target }}/release/entrypoint
release-all:
name: Push docker image for all platforms
runs-on: ubuntu-latest
needs: build
env:
image_name: seichi-portal-backend
steps:
-
name: Checkout
uses: actions/checkout@master
-
uses: actions/download-artifact@v3
with:
name: x86_64-unknown-linux-gnu
path: docker/artifacts/x86_64-unknown-linux-gnu
-
uses: actions/download-artifact@v3
with:
name: aarch64-unknown-linux-gnu
path: docker/artifacts/aarch64-unknown-linux-gnu
-
name: Set up QEMU
uses: docker/setup-qemu-action@v2
-
name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
-
name: Login to GitHub Container Registry
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
-
id: prepare_image_id
name: Prepare image id's components
run: |
image_id=ghcr.io/${{ github.repository_owner }}/${{ env.image_name }}
echo "lowercase_id=$(echo $image_id | tr '[A-Z]' '[a-z]')" >> $GITHUB_OUTPUT
echo "short-ref=$(git rev-parse --short "$GITHUB_SHA")" >> $GITHUB_OUTPUT
echo "branch=$(echo ${GITHUB_REF#refs/heads/} | tr / -)" >> $GITHUB_OUTPUT
-
name: Build and push
uses: docker/build-push-action@v4
with:
context: docker
platforms: linux/amd64,linux/arm64/v8
push: true
tags: |
${{ steps.prepare_image_id.outputs.lowercase_id }}:latest
${{ steps.prepare_image_id.outputs.lowercase_id }}:${{ steps.prepare_image_id.outputs.branch }}-${{ steps.prepare_image_id.outputs.short-ref }}