forked from KomodoPlatform/komodo-defi-framework
-
Notifications
You must be signed in to change notification settings - Fork 0
/
azure-pipelines-release-stage-job.yml
141 lines (139 loc) · 6.95 KB
/
azure-pipelines-release-stage-job.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
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
# Job template for MM2 Release stage build
parameters:
name: '' # defaults for any parameters that aren't specified
os: ''
bob_passphrase: ''
bob_userpass: ''
alice_passphrase: ''
alice_userpass: ''
jobs:
- job: ${{ parameters.name }}
timeoutInMinutes: 0 # 0 means infinite for self-hosted agent
pool:
name: Default
demands: agent.os -equals ${{ parameters.os }}
steps:
# https://docs.microsoft.com/en-us/azure/devops/pipelines/process/variables?view=azure-devops&tabs=yaml%2Cbatch#set-a-job-scoped-variable-from-a-script
- bash: |
export SHORT_HASH="$(git rev-parse --short=9 HEAD)"
echo "##vso[task.setvariable variable=COMMIT_HASH]${SHORT_HASH}"
export TAG="$(git tag -l --points-at HEAD)"
echo "##vso[task.setvariable variable=COMMIT_TAG]${TAG}"
if [ -z $TAG ]; then
echo "Commit tag is empty"
export RELEASE_TAG=beta-2.1.$(Build.BuildId)
else
export DEBUG_UPLOADED="$(curl -s https://api.github.com/repos/KomodoPlatform/atomicDEX-API/releases/tags/$TAG | grep $(Agent.OS)-Debug)"
export RELEASE_UPLOADED="$(curl -s https://api.github.com/repos/KomodoPlatform/atomicDEX-API/releases/tags/$TAG | grep $(Agent.OS)-Release)"
export RELEASE_TAG=$TAG
fi
echo DEBUG_UPLOADED:$DEBUG_UPLOADED
echo RELEASE_UPLOADED:$RELEASE_UPLOADED
echo RELEASE_TAG:$RELEASE_TAG
echo "##vso[task.setvariable variable=DEBUG_UPLOADED]${DEBUG_UPLOADED}"
echo "##vso[task.setvariable variable=RELEASE_UPLOADED]${RELEASE_UPLOADED}"
echo "##vso[task.setvariable variable=RELEASE_TAG]${RELEASE_TAG}"
displayName: Setup ENV
- bash: |
rm -rf upload
mkdir upload
displayName: 'Recreate upload dir'
- bash: |
VERSION=$(Build.BuildId)_$(Build.SourceBranchName)_$(COMMIT_HASH)_$(Agent.OS)_Debug
if ! grep -q $VERSION MM_VERSION; then
echo $VERSION > MM_VERSION
fi
cat MM_VERSION
if [ $AGENT_OS = "Linux" ]
then
docker build -f Dockerfile.ubuntu.ci -t mm2_builder .
export UID=$(id -u)
export GID=$(id -g)
docker run \
--user $UID:$GID \
-v /home/azureagent/docker-cargo-cache/git:/root/.cargo/git \
-v /home/azureagent/docker-cargo-cache/registry:/root/.cargo/registry \
-v $PWD:$PWD \
-w $PWD \
-e HOME=/root \
mm2_builder \
/bin/bash -c "source /root/.cargo/env && cargo build -vv --target-dir target-xenial"
else
cargo build -vv
fi
displayName: 'Build MM2 Debug'
condition: eq( variables['DEBUG_UPLOADED'], '' )
env:
MANUAL_MM_VERSION: true
JEMALLOC_SYS_WITH_MALLOC_CONF: "background_thread:true,narenas:1,tcache:false,dirty_decay_ms:0,muzzy_decay_ms:0,metadata_thp:auto"
- bash: |
zip upload/mm2-$(COMMIT_HASH)-$(Agent.OS)-Debug target-xenial/debug/mm2 target-xenial/debug/libmm2.a -j
displayName: 'Prepare debug build upload Linux'
condition: and( eq( variables['Agent.OS'], 'Linux' ), eq( variables['DEBUG_UPLOADED'], '' ) )
- bash: |
cd target/debug
zip ../../upload/mm2-$(COMMIT_HASH)-$(Agent.OS)-Debug mm2.dSYM mm2 libmm2.a -r
displayName: 'Prepare debug build upload MacOS'
condition: and( eq( variables['Agent.OS'], 'Darwin' ), eq( variables['DEBUG_UPLOADED'], '' ) )
- powershell: |
7z a .\upload\mm2-$(COMMIT_HASH)-$(Agent.OS)-Debug.zip .\target\debug\mm2.exe .\target\debug\mm2.lib .\target\debug\*.dll "$Env:windir\system32\msvcr100.dll" "$Env:windir\system32\msvcp140.dll" "$Env:windir\system32\vcruntime140.dll"
displayName: 'Prepare debug build upload Windows'
condition: and( eq( variables['Agent.OS'], 'Windows_NT' ), eq( variables['DEBUG_UPLOADED'], '' ) )
- bash: |
rm -f MM_VERSION
VERSION=$(Build.BuildId)_$(Build.SourceBranchName)_$(COMMIT_HASH)_$(Agent.OS)_Release
if ! grep -q $VERSION MM_VERSION; then
echo $VERSION > MM_VERSION
fi
cat MM_VERSION
touch mm2src/common/build.rs
if [ $AGENT_OS = "Linux" ]
then
docker build -f Dockerfile.ubuntu.ci -t mm2_builder .
export UID=$(id -u)
export GID=$(id -g)
docker run \
--user $UID:$GID \
-v /home/azureagent/docker-cargo-cache/git:/root/.cargo/git \
-v /home/azureagent/docker-cargo-cache/registry:/root/.cargo/registry \
-v $PWD:$PWD \
-w $PWD \
-e HOME=/root \
mm2_builder \
/bin/bash -c "source /root/.cargo/env && cargo build --release -vv --target-dir target-xenial"
else
cargo build --release -vv
fi
displayName: 'Build MM2 Release'
condition: eq( variables['RELEASE_UPLOADED'], '' )
env:
MANUAL_MM_VERSION: true
- bash: |
objcopy --only-keep-debug target-xenial/release/mm2 target-xenial/release/mm2.debug
objcopy --only-keep-debug target-xenial/release/libmm2.a target-xenial/release/libmm2.debug.a
strip -g target-xenial/release/mm2
strip -g target-xenial/release/libmm2.a
zip upload/mm2-$(COMMIT_HASH)-$(Agent.OS)-Release target-xenial/release/mm2 target-xenial/release/libmm2.a -j
zip upload/mm2-$(COMMIT_HASH)-$(Agent.OS)-Release-debuginfo.zip target-xenial/release/mm2.debug target-xenial/release/libmm2.debug.a -j
displayName: 'Prepare release build upload Linux'
condition: and( eq( variables['Agent.OS'], 'Linux' ), eq( variables['RELEASE_UPLOADED'], '' ) )
- bash: |
cd target/release
zip ../../upload/mm2-$(COMMIT_HASH)-$(Agent.OS)-Release.zip mm2 libmm2.a
zip ../../upload/mm2-$(COMMIT_HASH)-$(Agent.OS)-Release.dSYM.zip mm2.dSYM -r
displayName: 'Prepare release build upload MacOS'
condition: and( eq( variables['Agent.OS'], 'Darwin' ), eq( variables['RELEASE_UPLOADED'], '' ) )
- task: Docker@2
displayName: Build and Push Docker Release image
condition: and( eq( variables['Agent.OS'], 'Linux' ), eq( variables['RELEASE_UPLOADED'], '' ) )
inputs:
containerRegistry: dockerhub
repository: komodoofficial/atomicdexapi
command: buildAndPush
tags: |
$(RELEASE_TAG)
Dockerfile: Dockerfile.release
- powershell: |
7z a .\upload\mm2-$(COMMIT_HASH)-$(Agent.OS)-Release.zip .\target\release\mm2.exe .\target\release\mm2.lib .\target\release\*.dll "$Env:windir\system32\msvcr100.dll" "$Env:windir\system32\msvcp140.dll" "$Env:windir\system32\vcruntime140.dll"
displayName: 'Prepare release build upload Windows'
condition: and( eq( variables['Agent.OS'], 'Windows_NT' ), eq( variables['RELEASE_UPLOADED'], '' ) )