-
Notifications
You must be signed in to change notification settings - Fork 3
120 lines (103 loc) · 3.65 KB
/
docker.yml
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
name: Docker
on:
workflow_dispatch: {}
push:
branches:
- "main"
- "refactor/monorepo"
paths:
- ".github/images/hcp/Dockerfile"
- ".github/workflows/docker.yml"
- "crates/**"
jobs:
build:
continue-on-error: true
strategy:
matrix:
include:
- release_for: Linux-x86_64
build_on: ubuntu-latest
target: x86_64-unknown-linux-gnu
args: "--locked --release"
runs-on: ${{ matrix.build_on }}
steps:
- name: checkout repository
uses: actions/checkout@v4
- uses: Swatinem/rust-cache@v2
with:
shared-key: "release"
- name: Install stable toolchain
uses: actions-rs/toolchain@v1
with:
toolchain: stable
- name: Run cargo build
uses: actions-rs/cargo@v1
with:
command: build
args: --target ${{ matrix.target }} ${{ matrix.args }}
- name: rename binaries
run: |
mv target/${{ matrix.target }}/release/operator operator-${{ matrix.release_for }}
mv target/${{ matrix.target }}/release/rpc rpc-${{ matrix.release_for }}
mv target/${{ matrix.target }}/release/metrics-exporter metrics-exporter-${{ matrix.release_for }}
mv target/${{ matrix.target }}/release/open-head open-head-${{ matrix.release_for }}
- name: upload artifacts
uses: actions/upload-artifact@v4
with:
name: binaries-${{ matrix.release_for }}
path: |
operator-${{ matrix.release_for }}
rpc-${{ matrix.release_for }}
metrics-exporter-${{ matrix.release_for }}
open-head-${{ matrix.release_for }}
docker:
runs-on: ubuntu-latest
needs: [build]
permissions:
contents: read
packages: write
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@v5
with:
images: ghcr.io/cardano-scaling/hydra-control-plane
tags: |
type=raw,value=latest,enable={{is_default_branch}}
type=semver,pattern=v{{major}}
type=semver,pattern=v{{major}}.{{minor}}
type=semver,pattern=v{{version}}
type=sha
- name: Login to DockerHub
uses: docker/login-action@v3
with:
registry: ghcr.io/cardano-scaling
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Download artifacts
uses: actions/download-artifact@v4
with:
pattern: binaries-*
merge-multiple: true
path: .github/images/hcp/bin
# we need to rename the artifact so that the name matches
# the value that Docker uses for TARGET_ARCH to keep the
# Dockerfile simple
- name: Rename artifacts
run: |+
mv .github/images/hcp/bin/operator-Linux-x86_64 .github/images/hcp/bin/operator-Linux-amd64
mv .github/images/hcp/bin/rpc-Linux-x86_64 .github/images/hcp/bin/rpc-Linux-amd64
mv .github/images/hcp/bin/metrics-exporter-Linux-x86_64 .github/images/hcp/bin/metrics-exporter-Linux-amd64
mv .github/images/hcp/bin/open-head-Linux-x86_64 .github/images/hcp/bin/open-head-Linux-amd64
- name: Build and push
uses: docker/build-push-action@v5
with:
context: .github/images/hcp
platforms: linux/amd64
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}