|
3 | 3 | branches:
|
4 | 4 | only:
|
5 | 5 | - master
|
| 6 | + - release |
6 | 7 |
|
7 | 8 | language: rust
|
8 | 9 |
|
9 | 10 | rust:
|
10 | 11 | # build nightly only for the time beeing
|
11 | 12 | - nightly
|
12 | 13 |
|
13 |
| -matrix: |
14 |
| - fast_finish: true |
| 14 | +# increase build speed by caching installed cargo dependencies |
| 15 | +cache: cargo |
| 16 | + |
| 17 | +# define the stages and their order |
| 18 | +stages: |
| 19 | + - compile |
| 20 | + - test |
| 21 | + - publish_dry |
| 22 | + - name: prepare_release |
| 23 | + if: branch = master AND type != pull_request |
| 24 | + - name: deploy |
| 25 | + if: branch = release AND type != pull_request |
| 26 | + - name: publish |
| 27 | + if: branch = release AND type != pull_request |
| 28 | + |
| 29 | +jobs: |
15 | 30 | include:
|
16 |
| - - name: "build 64Bit" |
| 31 | + - stage: compile |
| 32 | + name: "Compile The Crate" |
17 | 33 | install:
|
18 |
| - - sudo apt-get install gcc-aarch64-linux-gnu |
| 34 | + - sudo apt-get install -y gcc-aarch64-linux-gnu |
19 | 35 | - cargo install cargo-xbuild
|
20 | 36 | - cargo install cargo-make
|
21 |
| - - rustup target add aarch64-unknown-linux-gnu |
| 37 | + - rustup target add aarch64-unknown-none |
22 | 38 | - rustup component add rust-src
|
23 | 39 | - rustup component add llvm-tools-preview
|
24 | 40 | # if we not build a PR we remove the patch of the dependencies to their github repo's
|
25 | 41 | - 'if [ "$TRAVIS_PULL_REQUEST" == "false" ]; then sed -i "/{^\[patch\.crates-io\] /{:a;N;/\Z}/!ba};/^ruspiro-.*\(git\|path\).*/d" Cargo.toml; fi'
|
26 |
| - script: cargo make --profile a64-travis pi3 |
| 42 | + script: cargo make --profile travis pi3 |
27 | 43 |
|
28 |
| - - name: "build 32Bit" |
| 44 | + - stage: test |
| 45 | + name: "Run Doc Tests" |
29 | 46 | install:
|
30 |
| - - sudo apt-get install -y gcc-arm-none-eabi |
31 |
| - - cargo install cargo-xbuild |
32 | 47 | - cargo install cargo-make
|
33 |
| - - rustup target add armv7-unknown-linux-gnueabihf |
34 |
| - - rustup component add rust-src |
35 |
| - - rustup component add llvm-tools-preview |
36 | 48 | # if we not build a PR we remove the patch of the dependencies to their github repo's
|
37 | 49 | - 'if [ "$TRAVIS_PULL_REQUEST" == "false" ]; then sed -i "/{^\[patch\.crates-io\] /{:a;N;/\Z}/!ba};/^ruspiro-.*\(git\|path\).*/d" Cargo.toml; fi'
|
38 |
| - script: cargo make --profile a32 pi3 |
39 |
| - |
40 |
| - - name: "unit tests" |
| 50 | + script: cargo make doctest --profile dummy |
| 51 | + - stage: test |
| 52 | + name: "Run Unit Tests" |
41 | 53 | install:
|
| 54 | + - cargo install cargo-make |
42 | 55 | # if we not build a PR we remove the patch of the dependencies to their github repo's
|
43 | 56 | - 'if [ "$TRAVIS_PULL_REQUEST" == "false" ]; then sed -i "/{^\[patch\.crates-io\] /{:a;N;/\Z}/!ba};/^ruspiro-.*\(git\|path\).*/d" Cargo.toml; fi'
|
44 |
| - script: cargo test --tests --features ruspiro_pi3 |
| 57 | + script: cargo make unittest --profile dummy |
45 | 58 |
|
46 |
| - - name: "doc tests" |
| 59 | + - stage: publish_dry |
| 60 | + name: "Run Cargo Publish Dry-Run" |
47 | 61 | install:
|
48 |
| - # if we not build a PR we remove the patch of the dependencies to their github repo's |
49 |
| - - 'if [ "$TRAVIS_PULL_REQUEST" == "false" ]; then sed -i "/{^\[patch\.crates-io\] /{:a;N;/\Z}/!ba};/^ruspiro-.*\(git\|path\).*/d" Cargo.toml; fi' |
50 |
| - - cat Cargo.toml |
51 |
| - script: cargo test --doc --features ruspiro_pi3 |
| 62 | + - sudo apt-get install -y gcc-aarch64-linux-gnu |
| 63 | + - cargo install cargo-xbuild |
| 64 | + - cargo install cargo-make |
| 65 | + - rustup target add aarch64-unknown-none |
| 66 | + - rustup component add rust-src |
| 67 | + - rustup component add llvm-tools-preview |
| 68 | + script: cargo make publish_dry --profile travis |
| 69 | + |
| 70 | + - stage: prepare_release |
| 71 | + name: "Create PR against the release branch" |
| 72 | + script: |
| 73 | + - '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' |
| 74 | + |
| 75 | + - stage: deploy |
| 76 | + name: "Create GitHub release" |
| 77 | + |
| 78 | + before_deploy: |
| 79 | + # extract current crate version from argo.toml |
| 80 | + - export CRATE_VERSION=v`sed -En 's/^version.*=.*\"(.*)\".*$/\1/p' < Cargo.toml` |
| 81 | + # retrieve last release version from github |
| 82 | + - export LAST_VERSION="$(curl --silent "https://api.github.com/repos/$TRAVIS_REPO_SLUG/releases/latest" | grep '"tag_name":' | sed -E 's/.*"([^"]+)".*/\1/')" |
| 83 | + # use default version if none yet published (required for proper release note extraction) |
| 84 | + - export LAST_VERSION=${LAST_VERSION:-v0.0.0} |
| 85 | + - echo $CRATE_VERSION |
| 86 | + - echo $LAST_VERSION |
| 87 | + - git config --local user.name "2ndTaleStudio" |
| 88 | + - git config --local user.email "[email protected]" |
| 89 | + # create the TAG required for the release |
| 90 | + - git tag $CRATE_VERSION -m "$CRATE_VERSION" |
| 91 | + # extract the release notes of the current release from the changelog |
| 92 | + - sed -En '/##.*:.*:.*'"$LAST_VERSION"'/q;p' CHANGELOG.md > RELEASENOTES.md |
| 93 | + - sed -i -e 's/^# Changelog/# Release Notes/g' RELEASENOTES.md |
| 94 | + deploy: |
| 95 | + provider: releases |
| 96 | + # use dpl v2 version for deployments to support the release_notes_file option |
| 97 | + edge: true |
| 98 | + api_key: "$GIT_API_TOKEN" |
| 99 | + name: "$CRATE_VERSION" |
| 100 | + release_notes_file: "RELEASENOTES.md" |
| 101 | + file: "RELEASENOTES.md" |
| 102 | + skip_cleanup: true |
| 103 | + on: |
| 104 | + branch: release |
| 105 | + |
| 106 | + - stage: publish |
| 107 | + name: "Run Cargo Publish" |
| 108 | + install: |
| 109 | + - sudo apt-get install -y gcc-aarch64-linux-gnu |
| 110 | + - cargo install cargo-xbuild |
| 111 | + - cargo install cargo-make |
| 112 | + - rustup target add aarch64-unknown-none |
| 113 | + - rustup component add rust-src |
| 114 | + - rustup component add llvm-tools-preview |
| 115 | + # extract current crate version from argo.toml |
| 116 | + - export CRATE_VERSION=`sed -En 's/^version.*=.*\"(.*)\".*$/\1/p' < Cargo.toml` |
| 117 | + # before actually publishing replace the final version for doc and repository in the Crago.toml |
| 118 | + - sed -i -e 's/||VERSION||/'$CRATE_VERSION'/g' Cargo.toml |
| 119 | + # also update the version in the lib.rs doc root url |
| 120 | + - sed -i -e 's/||VERSION||/'$CRATE_VERSION'/g' src/lib.rs |
| 121 | + # and the README.md |
| 122 | + - sed -i -e 's/||VERSION||/'$CRATE_VERSION'/g' README.md |
| 123 | + # publish with token and dirty flag as we just updated some files and won't commit them back to the branch |
| 124 | + script: cargo make publish --env CRATES_TOKEN="$CRATES_TOKEN" > /dev/null |
0 commit comments