-
Notifications
You must be signed in to change notification settings - Fork 121
99 lines (85 loc) · 2.56 KB
/
publish_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
name: docker
on:
workflow_dispatch:
inputs:
tag:
description: tag (ex. v4.0.0) to publish on docker
required: true
jobs:
##
# Build the Rust package
##
build-package:
name: Build package
runs-on: ubuntu-20.04
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Install dependencies
run: |
sudo apt update -y
sudo apt install --no-install-recommends -y \
git curl ca-certificates \
gcc g++ cmake clang
env:
DEBIAN_FRONTEND: "noninteractive"
TZ: "Asia/Shanghai"
- name: Install Rust toolchain
uses: actions-rs/toolchain@v1
with:
toolchain: nightly-2021-11-07
target: wasm32-unknown-unknown
default: true
- name: Cache target
uses: actions/cache@v2
with:
path: target
key: ${{ runner.os }}-target
- name: Build chainx
run: |
COMMIT=`git rev-parse HEAD` && \
echo using $COMMIT && \
cargo build --release
- name: Collect shared
run: |
mkdir shared
mv target/release/chainx shared/
- name: Upload shared
uses: actions/upload-artifact@v2.2.4
with:
name: chainx-artifact
path: shared
build-docker:
name: Build docker
runs-on: ubuntu-latest
needs: [build-package]
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Download shared
uses: actions/download-artifact@v2
with:
name: chainx-artifact
path: shared
- name: Login to DockerHub
if: github.event_name != 'pull_request'
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- run: |
DOCKER_IMAGE=chainxorg/chainx
VERSION="${{ github.event.inputs.tag }}"
COMMIT=`git rev-parse HEAD`
BUILD_AT=`date --iso-8601=seconds`
echo building "${DOCKER_IMAGE}:${VERSION} at ${BUILD_AT} on ${COMMIT}"
chmod +x shared/chainx # REQUIRED, see above
echo building "${DOCKER_IMAGE}:${VERSION}"
docker build \
--build-arg CI_BUILD_AT=${BUILD_AT} \
--build-arg CI_GIT_TAG=${VERSION} \
--build-arg CI_GIT_SHA=commit-${COMMIT} \
-f Dockerfile \
-t "${DOCKER_IMAGE}:${VERSION}" \
.
docker push "${DOCKER_IMAGE}:${VERSION}"