-
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathazure-pipelines.yml
133 lines (120 loc) · 3.92 KB
/
azure-pipelines.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
# TODO:
# 1. Cross compilation targeting different architectures using `cross`
# see https://nbsoftsolutions.com/blog/azure-pipelines-for-rust-projects
variables:
rustup_toolchain: stable
architecture: x86_64
strategy:
matrix:
linux:
target: $(architecture)-unknown-linux-gnu
imageName: ubuntu-16.04
alpine:
target: $(architecture)-unknown-linux-musl
imageName: ubuntu-16.04
mac:
target: $(architecture)-apple-darwin
imageName: macos-10.13
windows:
target: $(architecture)-pc-windows-msvc
imageName: windows-2019
# TODO: enable this when https://github.com/rust-lang/rust/issues/53454 resolved
# mingw:
# target: $(architecture)-pc-windows-gnu
# imageName: windows-2019
pool:
vmImage: $(imageName)
pr:
branches:
include:
- master
paths:
include:
- packages/*
trigger:
tags:
include: ['*.*.*']
steps:
- bash: |
TAG="$(Build.SourceBranch)"
TAG=${TAG#refs/tags/}
echo $TAG
echo "##vso[task.setvariable variable=build.tag]$TAG"
displayName: "Create tag variable"
- script: |
curl -sSf -o rustup-init.exe https://win.rustup.rs
rustup-init.exe -y --default-toolchain %RUSTUP_TOOLCHAIN%
echo "##vso[task.setvariable variable=PATH;]%PATH%;%USERPROFILE%\.cargo\bin"
displayName: Windows install rust
condition: eq( variables['Agent.OS'], 'Windows_NT' )
- script: |
curl https://sh.rustup.rs -sSf | sh -s -- -y --default-toolchain $RUSTUP_TOOLCHAIN
echo "##vso[task.setvariable variable=PATH;]$PATH:$HOME/.cargo/bin"
displayName: Install rust
condition: ne( variables['Agent.OS'], 'Windows_NT' )
- script: rustup target add $(TARGET)
displayName: Install target toolchain
# TODO: Remove this when backtrace-sys don't cause trouble or this project can be compiled on stable channel
- script: sudo apt-get install musl-tools
displayName: Install musl-gcc
condition: contains( variables['target'], 'musl' )
- script: cargo build --release --target $(TARGET)
displayName: Build release
- task: CopyFiles@2
inputs:
sourceFolder: $(Build.SourcesDirectory)/target/$(TARGET)/release
contents: |
scrap
scrap.bash
scrap.fish
scrap.elv
_scrap
_scrap.ps1
scrap.exe
targetFolder: $(Build.BinariesDirectory)
- task: ArchiveFiles@2
inputs:
rootFolderOrFile: $(Build.BinariesDirectory)
archiveType: tar
tarCompression: gz
archiveFile: $(Build.ArtifactStagingDirectory)/cli/scrap-$(TARGET).tar.gz
- task: PublishBuildArtifacts@1
inputs:
pathtoPublish: '$(Build.ArtifactStagingDirectory)/cli'
artifactName: cli
- template: docker/azure-pipelines.yml
- task: GitHubRelease@0
condition: and(succeeded(), startsWith(variables['Build.SourceBranch'], 'refs/tags/'))
inputs:
gitHubConnection: drsensor
title: $(Build.SourceVersionMessage)
repositoryName: $(Build.Repository.Name)
action: edit
tag: $(build.tag)
assets: $(Build.ArtifactStagingDirectory)/cli/scrap-$(TARGET).tar.gz
assetUploadMode: replace
isDraft: true
addChangeLog: false
- bash: |
./scripts/package.sh
displayName: Package crates
- task: CopyFiles@2
inputs:
sourceFolder: $(Build.SourcesDirectory)/target/package
contents: '**.crate'
targetFolder: $(Build.ArtifactStagingDirectory)/crate
- task: PublishBuildArtifacts@1
inputs:
pathtoPublish: '$(Build.ArtifactStagingDirectory)/crate'
artifactName: crates
# TODO: Split this as a separate job after GitHubRelease@0 done
# But it has a caveat, it need to install rust again :sad: (no build needed)
- bash: |
cargo login $DRSENSOR
for cargo_toml in packages/{core,transpiler/*,cli}/Cargo.toml; do
cargo publish --manifest-path $cargo_toml --no-verify
done
displayName: Publish to crates.io
condition: and(and(succeeded(), startsWith(variables['Build.SourceBranch'], 'refs/tags/')), eq( variables['Agent.OS'], 'Windows_NT' ))
env:
DRSENSOR: $(crateioConnection)