This repository was archived by the owner on Sep 20, 2022. It is now read-only.
forked from debionetwork/debio-node
-
Notifications
You must be signed in to change notification settings - Fork 0
158 lines (152 loc) · 5.63 KB
/
Copy pathbuilder.yml
File metadata and controls
158 lines (152 loc) · 5.63 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
158
name: Builder
on:
push:
branches:
- main
tags:
- '[0-9]+.[0-9]+.[0-9]+*'
concurrency:
group: builder
jobs:
compute-build-info:
runs-on: ubuntu-20.04
outputs:
sha_short: ${{ steps.build-info.outputs.sha_short }}
revision_tag: ${{ steps.build-info.outputs.revision_tag }}
latest_tag: ${{ steps.build-info.outputs.latest_tag }}
pre_release: ${{ steps.build-info.outputs.pre_release }}
steps:
- name: Checkout code
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Compute build info
id: build-info
shell: bash
run: |
SHA_SHORT=$(git rev-parse --short HEAD)
REVISION_TAG=$SHA_SHORT
LATEST_TAG=latest-pre-alpha
PRE_RELEASE=true
if [[ $GITHUB_REF =~ refs/tags/ ]] ;
then
TAG=${GITHUB_REF#refs/tags/}
VERSION=${TAG%.*}.$((${TAG##*.}))
REVISION_TAG=$TAG
if [[ $TAG =~ [0-9]+.[0-9]+.[0-9]+$ ]] ;
then
LATEST_TAG=latest
PRE_RELEASE=false
else
SUFFIX=$(tmp=${TAG#$VERSION-} ; echo $tmp | sed -r 's/[0-9]//g' )
LATEST_TAG=latest-$SUFFIX
fi
fi
echo "::set-output name=sha_short::$SHA_SHORT"
echo "::set-output name=revision_tag::$REVISION_TAG"
echo "::set-output name=latest_tag::$LATEST_TAG"
echo "::set-output name=pre_release::$PRE_RELEASE"
build:
runs-on: ubuntu-20.04
needs:
- compute-build-info
steps:
- name: Checkout code
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Install toolchain
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: nightly-2021-11-01
components: clippy, rustfmt
target: wasm32-unknown-unknown
override: true
default: true
- name: Rust cache
uses: Swatinem/rust-cache@v1.3.0
- name: Cargo build
run: cargo build --release --locked
# build-and-publish-docker-image
- name: Set up QEMU
uses: docker/setup-qemu-action@v1
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
- name: Cache Docker layers
if: "!startsWith(github.ref, 'refs/tags/')"
uses: actions/cache@v2
with:
path: /tmp/.buildx-cache
key: ${{ runner.os }}-buildx-${{ hashFiles('**/Cargo.lock') }}
restore-keys: |
${{ runner.os }}-buildx-
- name: Login to DockerHub
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Copy binnary file
run: cp target/release/debio .
- name: Build and push
if: "!startsWith(github.ref, 'refs/tags/')"
uses: docker/build-push-action@v2
with:
context: .
push: true
file: .maintain/docker/injected-binnary.Dockerfile
tags: |
${{ github.repository }}:${{ needs.compute-build-info.outputs.revision_tag }}
${{ github.repository }}:${{ needs.compute-build-info.outputs.latest_tag }}
cache-from: type=local,src=/tmp/.buildx-cache
cache-to: type=local,dest=/tmp/.buildx-cache-new,mode=max
- name: Docker image re-tag
if: "startsWith(github.ref, 'refs/tags/')"
uses: akhilerm/tag-push-action@v2.0.0
with:
src: ${{ github.repository }}:${{ needs.compute-build-info.outputs.sha_short }}
dst: |
${{ github.repository }}:${{ needs.compute-build-info.outputs.revision_tag }}
${{ github.repository }}:${{ needs.compute-build-info.outputs.latest_tag }}
# Temp fix
# https://github.com/docker/build-push-action/issues/252
# https://github.com/moby/buildkit/issues/1896
- name: Move cache
if: "!startsWith(github.ref, 'refs/tags/')"
run: |
rm -rf /tmp/.buildx-cache
mv /tmp/.buildx-cache-new /tmp/.buildx-cache
- name: Send WASM to Discord
if: ${{ !startsWith(github.ref, 'refs/tags/') }}
uses: tsickert/discord-webhook@v4.0.0
with:
webhook-url: ${{ secrets.DISCORD_WEBHOOK }}
username: "DevOps Bot"
avatar-url: ${{ secrets.LOGO_URL }}
embed-title: New build wasm
content: "<@839002855896907787> <@813609814650388491> <@739126196469497989>"
embed-description: "Build success on commit sha `${{ needs.compute-build-info.outputs.sha_short }}`"
filename: "./target/release/wbuild/debio-runtime/debio_runtime.compact.compressed.wasm"
embed-color: 3878306
embed-footer-text: "DeBio DevOps"
embed-footer-icon-url: ${{ secrets.LOGO_URL }}
embed-image-url: ${{ secrets.BANNER_URL }}
# publish-draft-release
- name: Build changelog
if: "startsWith(github.ref, 'refs/tags/')"
id: build_changelog
uses: mikepenz/release-changelog-builder-action@v2
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
configuration: '.github/workflows/rcb_config.json'
- name: Create draft release
if: "startsWith(github.ref, 'refs/tags/')"
uses: softprops/action-gh-release@v1
with:
body: ${{ steps.build_changelog.outputs.changelog }}
draft: true
prerelease: ${{ needs.compute-build-info.outputs.pre_release }}
files: |
./target/release/wbuild/debio-runtime/debio_runtime.compact.compressed.wasm
./target/release/debio