This repository has been archived by the owner on Mar 23, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 33
117 lines (102 loc) · 4.12 KB
/
release-cnd.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
name: "Release cnd"
on:
release:
types: [created]
env:
CARGO_TARGET_ARMV7_UNKNOWN_LINUX_GNUEABIHF_LINKER: arm-linux-gnueabihf-gcc
jobs:
release:
if: startsWith(github.event.release.tag_name, 'cnd-') # only trigger this if we released cnd
name: Release cnd
strategy:
matrix:
target: [ x86_64-unknown-linux-gnu, armv7-unknown-linux-gnueabihf, x86_64-apple-darwin, x86_64-pc-windows-gnu ]
include:
- target: x86_64-unknown-linux-gnu
os: ubuntu-latest
docker: true
- target: armv7-unknown-linux-gnueabihf
os: ubuntu-latest
- target: x86_64-apple-darwin
os: macos-latest
- target: x86_64-pc-windows-gnu
os: windows-latest
runs-on: ${{ matrix.os }}
steps:
- name: Checkout tagged commit
uses: actions/checkout@v2
with:
ref: ${{ github.event.release.target_commitish }}
token: ${{ secrets.BOTTY_GITHUB_TOKEN }}
- name: Install Rust
uses: actions-rs/toolchain@v1
with:
profile: minimal
override: true
target: ${{ matrix.target }}
- name: Install compiler for armhf arch
if: matrix.target == 'armv7-unknown-linux-gnueabihf'
run: |
sudo apt-get update
sudo apt-get install gcc-arm-linux-gnueabihf
- name: Build ${{ matrix.target }} release binary
id: build
run: cargo build --target=${{ matrix.target }} --release --package cnd
- name: Extract version from tag name
id: extract-version
uses: ./.github/actions/trim-front
with:
string: ${{ github.event.release.tag_name }}
prefix: cnd-
# Remove once python 3 is the default
- uses: actions/setup-python@v1
with:
python-version: '3.x'
- name: Create release archive
id: create-archive
uses: ./.github/actions/create-release-archive
with:
binary: cnd
version: ${{ steps.extract-version.outputs.trimmed }}
target: ${{ matrix.target }}
- name: Upload ${{ matrix.os }} release binary
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.BOTTY_GITHUB_TOKEN }}
with:
upload_url: ${{ github.event.release.upload_url }}
asset_path: ./${{ steps.create-archive.outputs.archive }}
asset_name: ${{ steps.create-archive.outputs.archive }}
asset_content_type: application/gzip
- name: Check if publication to docker should be done
id: check-docker
env:
DOCKER_USERNAME: ${{ secrets.DOCKER_REGISTRY_USERNAME }}
run: |
echo "::set-output name=process::${{ env.DOCKER_USERNAME != '' && matrix.docker }}"
- name: Login to docker
if: steps.check-docker.outputs.process == true
uses: azure/docker-login@v1
with:
username: ${{ secrets.DOCKER_REGISTRY_USERNAME }}
password: ${{ secrets.DOCKER_REGISTRY_PASSWORD }}
- name: Build cnd docker image as ${{ steps.extract-version.outputs.trimmed }} and latest
if: steps.check-docker.outputs.process == true
run: |
VERSION="${{ steps.extract-version.outputs.trimmed }}"
docker build . -t comitnetwork/cnd:$VERSION -t comitnetwork/cnd:latest
- name: Test docker image by starting it and curling the cnd API
if: steps.check-docker.outputs.process == true
run: |
VERSION="${{ steps.extract-version.outputs.trimmed }}"
echo "::starting docker-container comitnetwork/cnd:$VERSION"
docker run --publish 8000:8000 --detach --name cnd_container comitnetwork/cnd:$VERSION
curl --fail localhost:8000/
echo "::cnd API curled successfully"
docker stop cnd_container
- name: Publish docker image as ${{ steps.extract-version.outputs.trimmed }} and latest
if: steps.check-docker.outputs.process == true
run: |
VERSION="${{ steps.extract-version.outputs.trimmed }}"
docker push comitnetwork/cnd:$VERSION
docker push comitnetwork/cnd:latest