-
Notifications
You must be signed in to change notification settings - Fork 0
/
.travis.yml
137 lines (126 loc) · 5.83 KB
/
.travis.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
# build only master branch on commit's
# all other branches build on PullRequest creation
branches:
only:
- master
- release
language: rust
# use a newer Ubuntu release
dist: focal
rust:
# build nightly only for the time beeing
- nightly
# increase build speed by caching installed cargo dependencies
cache: cargo
# define the stages and their order
stages:
- compile
- test
- publish_dry
- name: prepare_release
if: branch = master AND type != pull_request
- name: deploy
if: branch = release AND type != pull_request
- name: publish
if: branch = release AND type != pull_request
jobs:
include:
- stage: compile
name: "Compile The Crate"
install:
- sudo apt-get install -y gcc-aarch64-linux-gnu
- cargo install cargo-xbuild
- cargo install cargo-make
- rustup target add aarch64-unknown-none
- rustup component add rust-src
- rustup component add llvm-tools-preview
# if we not build a PR we remove the patch of the dependencies to their github repo's
- 'if [ "$TRAVIS_PULL_REQUEST" == "false" ]; then sed -i "/\[patch\.crates-io\]/,$ s/ruspiro-\(.*\)/# ruspiro-\1/g" Cargo.toml; fi'
script: cargo make --profile travis pi3
- stage: test
name: "Run Unit Tests on QEMU"
install:
- sudo apt-get install ninja-build
- wget https://download.qemu.org/qemu-5.2.0-rc0.tar.xz
- tar xvJf qemu-5.2.0-rc0.tar.xz > /dev/null
- cd qemu-5.2.0-rc0
- ./configure --disable-kvm --prefix=$TRAVIS_BUILD_DIR/qemu --target-list="arm-softmmu aarch64-softmmu"
- travis_wait make
- make
- sudo make install
- cd ..
- sudo find ~/ -type f -name "qemu-system-*"
- sudo apt-get install -y gcc-aarch64-linux-gnu
- cargo install cargo-xbuild
- cargo install cargo-make
- rustup target add aarch64-unknown-none
- rustup component add rust-src
- rustup component add llvm-tools-preview
# if we not build a PR we remove the patch of the dependencies to their github repo's
- 'if [ "$TRAVIS_PULL_REQUEST" == "false" ]; then sed -i "/\[patch\.crates-io\]/,$ s/ruspiro-\(.*\)/# ruspiro-\1/g" Cargo.toml; fi'
# adjust the config.toml to call the test runner with the travis profile
- sed -i 's/\(cargo make qemu-test\)/\1 --profile travis/g' .cargo/config.toml
script: cargo make --profile travis unittest
- stage: publish_dry
name: "Run Cargo Publish Dry-Run"
install:
- sudo apt-get install -y gcc-aarch64-linux-gnu
- cargo install cargo-xbuild
- cargo install cargo-make
- rustup target add aarch64-unknown-none
- rustup component add rust-src
- rustup component add llvm-tools-preview
script: cargo make publish_dry --profile travis
- stage: prepare_release
name: "Create PR against the release branch"
script:
- 'curl -H ''Authorization: Token ''"$GIT_API_TOKEN"'''' -X POST -H ''Content-type: application/json'' --data ''{"title":"Prepare Release and crates.io publishing", "head":"master", "base":"release", "draft":false, "body":"Automatic PR to the release branch as preperation to publish the library"}'' https://api.github.com/repos/$TRAVIS_REPO_SLUG/pulls > /dev/null'
- stage: deploy
name: "Create GitHub release"
script: echo "creating github release"
before_deploy:
# extract current crate version from argo.toml
- export CRATE_VERSION=v`sed -En 's/^version.*=.*\"(.*)\".*$/\1/p' < Cargo.toml`
# retrieve last release version from github
- export LAST_VERSION="$(curl --silent "https://api.github.com/repos/$TRAVIS_REPO_SLUG/releases/latest" | grep '"tag_name":' | sed -E 's/.*"([^"]+)".*/\1/')"
# use default version if none yet published (required for proper release note extraction)
- export LAST_VERSION=${LAST_VERSION:-v0.0.0}
- echo $CRATE_VERSION
- echo $LAST_VERSION
- git config --local user.name "2ndTaleStudio"
- git config --local user.email "43264484+2ndTaleStudio@users.noreply.github.com"
# create the TAG required for the release
- git tag $CRATE_VERSION -m "$CRATE_VERSION"
# extract the release notes of the current release from the changelog
- sed -En '/##.*:.*:.*'"$LAST_VERSION"'/q;p' CHANGELOG.md > RELEASENOTES.md
- sed -i -e 's/^# Changelog/# Release Notes/g' RELEASENOTES.md
deploy:
provider: releases
# use dpl v2 version for deployments to support the release_notes_file option
edge: true
api_key: "$GIT_API_TOKEN"
name: "$CRATE_VERSION"
release_notes_file: "RELEASENOTES.md"
file: "RELEASENOTES.md"
skip_cleanup: true
on:
branch: release
- stage: publish
name: "Run Cargo Publish"
install:
- sudo apt-get install -y gcc-aarch64-linux-gnu
- cargo install cargo-xbuild
- cargo install cargo-make
- rustup target add aarch64-unknown-none
- rustup component add rust-src
- rustup component add llvm-tools-preview
# extract current crate version from argo.toml
- export CRATE_VERSION=`sed -En 's/^version.*=.*\"(.*)\".*$/\1/p' < Cargo.toml`
# before actually publishing replace the final version for doc and repository in the Crago.toml
- sed -i -e 's/||VERSION||/'$CRATE_VERSION'/g' Cargo.toml
# also update the version in the lib.rs doc root url
- sed -i -e 's/||VERSION||/'$CRATE_VERSION'/g' src/lib.rs
# and the README.md
- sed -i -e 's/||VERSION||/'$CRATE_VERSION'/g' README.md
# publish with token and dirty flag as we just updated some files and won't commit them back to the branch
script: cargo make publish --profile travis --env CRATES_TOKEN="$CRATES_TOKEN" > /dev/null