From 71c32b2f60e5ebd4315f076d363a77d913a379c6 Mon Sep 17 00:00:00 2001
From: fewensa <37804932+fewensa@users.noreply.github.com>
Date: Wed, 4 Aug 2021 20:18:55 +0800
Subject: [PATCH] CI: build release and publish binary to github release page
and docker image (#225)
---
.github/workflows/release.yml | 34 ++++++++++++--
.maintain/docker/Dockerfile.aarch64-linux-gnu | 29 ++++++++++++
.../Dockerfile.publish-docker-image} | 0
.maintain/docker/Dockerfile.x86_64-linux-gnu | 28 +++++++++++
.maintain/setup-bridger.sh | 47 +++++++++++++++++++
CHANGELOG.md | 15 ++++++
Cross.toml | 28 +++++++++++
7 files changed, 176 insertions(+), 5 deletions(-)
create mode 100644 .maintain/docker/Dockerfile.aarch64-linux-gnu
rename .maintain/{Dockerfile => docker/Dockerfile.publish-docker-image} (100%)
create mode 100644 .maintain/docker/Dockerfile.x86_64-linux-gnu
create mode 100755 .maintain/setup-bridger.sh
create mode 100644 CHANGELOG.md
create mode 100644 Cross.toml
diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml
index a9962a48f..bbb082760 100644
--- a/.github/workflows/release.yml
+++ b/.github/workflows/release.yml
@@ -1,12 +1,36 @@
name: Release
-
on:
push:
- tags: ["*"]
- branches: ["feature/docker-image"]
+ tags:
+ - 'v*'
jobs:
- build-docker-image:
+ build-publish-github-release:
+ name: Build binary
+ runs-on: ubuntu-latest
+ steps:
+ - uses: actions/checkout@v2
+
+ - name: Build bridger
+ env:
+ RUST_TOOLCHAIN: nightly-2021-04-15
+ run: |
+ .maintain/setup-bridger.sh
+
+ - name: Publish github release
+ uses: docker://antonyurchenko/git-release:latest
+ if: startsWith(github.ref, 'refs/tags/v')
+ env:
+ GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
+ DRAFT_RELEASE: "false"
+ PRE_RELEASE: "false"
+ CHANGELOG_FILE: "CHANGELOG.md"
+ ALLOW_EMPTY_CHANGELOG: "false"
+ with:
+ args: |
+ deploy/bin/*
+
+ build-publish-docker-image:
name: Build Docker image
runs-on: ubuntu-latest
steps:
@@ -28,5 +52,5 @@ jobs:
- uses: ./.github/actions/docker-build-deploy
with:
docker_registry: quay.io
- docker_build_options: -f .maintain/Dockerfile
+ docker_build_options: -f .maintain/docker/Dockerfile.publish-docker-image
skip_deploy: true
diff --git a/.maintain/docker/Dockerfile.aarch64-linux-gnu b/.maintain/docker/Dockerfile.aarch64-linux-gnu
new file mode 100644
index 000000000..a56edfcd1
--- /dev/null
+++ b/.maintain/docker/Dockerfile.aarch64-linux-gnu
@@ -0,0 +1,29 @@
+# This file is part of Darwinia.
+#
+# Copyright (C) 2018-2021 Darwinia Network
+# SPDX-License-Identifier: GPL-3.0
+#
+# Darwinia is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# Darwinia is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with Darwinia. If not, see .
+
+FROM rustembedded/cross:aarch64-unknown-linux-gnu
+
+# only for aarch64
+
+# change mirrorlist
+RUN apt update && apt install -y \
+ # lib
+ libc6-dev-i386 \
+ # compiler
+ gcc-aarch64-linux-gnu gcc-5-aarch64-linux-gnu g++-aarch64-linux-gnu g++-5-aarch64-linux-gnu \
+ clang llvm libclang-dev
diff --git a/.maintain/Dockerfile b/.maintain/docker/Dockerfile.publish-docker-image
similarity index 100%
rename from .maintain/Dockerfile
rename to .maintain/docker/Dockerfile.publish-docker-image
diff --git a/.maintain/docker/Dockerfile.x86_64-linux-gnu b/.maintain/docker/Dockerfile.x86_64-linux-gnu
new file mode 100644
index 000000000..7b531d366
--- /dev/null
+++ b/.maintain/docker/Dockerfile.x86_64-linux-gnu
@@ -0,0 +1,28 @@
+# This file is part of Darwinia.
+#
+# Copyright (C) 2018-2021 Darwinia Network
+# SPDX-License-Identifier: GPL-3.0
+#
+# Darwinia is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# Darwinia is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with Darwinia. If not, see .
+
+FROM ubuntu:16.04
+
+# for gernal linux
+
+# change mirrorlist
+RUN apt update && apt install -y \
+ # tool
+ git make \
+ # compiler
+ gcc g++ clang-4.0
diff --git a/.maintain/setup-bridger.sh b/.maintain/setup-bridger.sh
new file mode 100755
index 000000000..443e9eeaa
--- /dev/null
+++ b/.maintain/setup-bridger.sh
@@ -0,0 +1,47 @@
+#!/bin/bash
+#
+
+set -xe
+
+BIN_PATH=$(dirname $(readlink -f $0))
+WORK_PATH=${BIN_PATH}/../
+
+echo -e '\e[1;32m📥 Installing Cross Compile Toolchain(s)\e[0m'
+curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | \
+ sh -s -- -y --profile minimal --default-toolchain ${RUST_TOOLCHAIN}
+source ~/.cargo/env
+
+echo -e '\e[1;32m🔧 Building Docker Image(s)\e[0m'
+docker build -f .maintain/docker/Dockerfile.x86_64-linux-gnu -t x86_64-linux-gnu .
+
+cargo install cross --git https://github.com/l2ust/cross
+
+rustup target add \
+ x86_64-unknown-linux-gnu \
+ aarch64-unknown-linux-gnu \
+ wasm32-unknown-unknown
+
+mkdir -p ${WORK_PATH}/deploy/bin
+
+cross build \
+ --release \
+ --target x86_64-unknown-linux-gnu
+
+
+cd ${WORK_PATH}/deploy/bin/
+
+cp ${WORK_PATH}/target/x86_64-unknown-linux-gnu/release/bridger ${WORK_PATH}/deploy/bin/
+chmod +x bridger
+tar cjSf bridger-x86_64-linux-gnu.tar.bz2 bridger
+mv ${WORK_PATH}/deploy/bin/bridger ${WORK_PATH}/deploy/
+
+
+echo -e '\e[1;32m🔑 Generating File(s) Hash\e[0m'
+
+md5sum * > ../md5sums.txt
+sha256sum * > ../sha256sums.txt
+
+mv ../md5sums.txt .
+mv ../sha256sums.txt .
+
+ls
diff --git a/CHANGELOG.md b/CHANGELOG.md
new file mode 100644
index 000000000..fd6799798
--- /dev/null
+++ b/CHANGELOG.md
@@ -0,0 +1,15 @@
+## [0.4.0] - 2021-08-04
+
+### Tasks
+
+| type | bridge | doc |
+| ------------------- | ----------------- | ---------------------------------------------------- |
+| substrate-ethereum | darwinia-ethereum | [Guide](https://github.com/darwinia-network/bridger/task/task-darwinia-ethereum/docs/Guide.md) |
+| substrate-substrate | pangolin-millau | [Guide](https://github.com/darwinia-network/bridger/task/task-pangolin-millau/docs/Guide.md) |
+
+### Migrate
+
+Migrate darwinia-ethereum 0.3.x to 0.4.x
+
+https://github.com/darwinia-network/bridger/blob/master/task/task-darwinia-ethereum/docs/Guide.md#migrate-03x-to-04x
+
diff --git a/Cross.toml b/Cross.toml
new file mode 100644
index 000000000..a67402216
--- /dev/null
+++ b/Cross.toml
@@ -0,0 +1,28 @@
+# This file is part of Darwinia.
+#
+# Copyright (C) 2018-2021 Darwinia Network
+# SPDX-License-Identifier: GPL-3.0
+#
+# Darwinia is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# Darwinia is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with Darwinia. If not, see .
+
+[target.x86_64-unknown-linux-gnu]
+image = "x86_64-linux-gnu"
+
+[target.aarch64-unknown-linux-gnu]
+image = "aarch64-linux-gnu"
+[target.aarch64-unknown-linux-gnu.env]
+passthrough = [
+ "RUSTFLAGS",
+ "SKIP_WASM_BUILD",
+]