summaryrefslogtreecommitdiffstats
path: root/.travis.yml
blob: c898876e0a7e36d29a5c19b002696fdf1239caf4 (plain)
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
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
language: rust
notifications:
  email:
    on_success: never

matrix:
  include:
    # Standard x86-64 stuff, stable and beta, on tier-1 environments
    - os: linux
      env: TARGET=x86_64-unknown-linux-gnu
      arch: amd64
      rust: stable
    - os: linux
      env: TARGET=x86_64-unknown-linux-gnu
      arch: amd64
      rust: beta
    - os: osx
      env: TARGET=x86_64-apple-darwin
      arch: amd64
      rust: stable
    - os: osx
      env: TARGET=x86_64-apple-darwin
      arch: amd64
      rust: beta
    - os: windows
      env: TARGET=x86_64-pc-windows-msvc
      arch: amd64
      rust: stable
    - os: windows
      env: TARGET=x86_64-pc-windows-msvc
      arch: amd64
      rust: beta

    # musl
    - os: linux
      env: TARGET=x86_64-unknown-linux-musl
      arch: amd64
      rust: stable

    # Windows GNU
    - os: windows
      env: TARGET=x86_64-pc-windows-gnu
      arch: amd64
      rust: stable

    # PowerPC 64 LE
    - os: linux
      env: TARGET=powerpc64le-unknown-linux-gnu
      arch: ppc64le
      rust: stable

    # ARM stuff (skip beta for now, see https://github.com/rust-lang/rust/issues/62896)
    - os: linux
      env: TARGET=aarch64-unknown-linux-gnu
      arch: arm64
      rust: stable
    - os: linux
      env: TARGET=armv7-unknown-linux-gnueabihf
      arch: amd64
      rust: stable
      addons:
        apt:
          packages: &armhf
            - gcc-arm-linux-gnueabihf
            - libc6-armhf-cross
            - libc6-dev-armhf-cross

  fast_finish: true
  exclude:
    - if: tag IS present
      rust: beta

branches:
  only:
    - master
    - /^\d+\.\d+(\.\d+)?(-\S*)?$/

cache: cargo

before_install:
  - export RUST_BACKTRACE=1
  - |
    if [[ $TRAVIS_OS_NAME == "windows" && -n $TRAVIS_TAG ]]; then
      echo "Pre-installing deploy dependencies for Windows...";
      powershell Install-WindowsFeature Net-Framework-Core;
      choco install -y wixtoolset;
      export PATH=$PATH:"/c/Program Files (x86)/WiX Toolset v3.11/bin";
      choco install zip;
      rustup target add i686-pc-windows-msvc;
    fi

before_script:
  - rustup target add $TARGET
  - rustup update
  - |
    # Only check clippy if stable...
    if [[ $TRAVIS_RUST_VERSION == "stable" ]]; then
      rustup component add clippy
    fi

script:
  - |
    # Only check clippy if stable...
    if [[ $TRAVIS_RUST_VERSION == "stable" ]]; then
      cargo clippy -- -D clippy::all
    fi
  - |
    if [[ $TARGET == "armv7-unknown-linux-gnueabihf" ]]; then
      cargo build --verbose --target $TARGET
    else
      cargo test --verbose --target $TARGET  
    fi

before_deploy:
  - |
    echo "Test whether installing works.  This is mostly just a sanity check.";
    cargo install --path . --target $TARGET --locked --force;
  - |
    echo "Building release..."
    if [[ $TRAVIS_OS_NAME == "windows" ]]; then
      echo "Building Windows 64-bit, target: $TARGET...";
      cargo build --release --target $TARGET;
      local target_dir=$(ls target/release/build/bottom-*/out/btm.bash | head -n1 | xargs dirname)
      cp -r $target_dir completions
      mv "./target/$TARGET/release/btm" "btm.exe";
      strip "btm.exe"
      zip -r bottom_$TARGET.zip "btm.exe" "completions";
      rm "btm.exe"
      rm -r "completions"

      if [[ $TARGET == "x86_64-pc-windows-msvc" ]]; then
        echo "Building further results for x86_64-pc-windows-msvc target..."
        echo "Building Windows 32-bit...";
        cargo clean;
        cargo build --release --target i686-pc-windows-msvc;
        local target_dir=$(ls target/release/build/bottom-*/out/btm.bash | head -n1 | xargs dirname)
        cp -r $target_dir completions
        mv "./target/i686-pc-windows-msvc/release/btm" "btm.exe";
        strip "btm.exe"
        zip -r bottom_i686-pc-windows-msvc.zip "btm.exe" "completions";
        rm "btm.exe"
        rm -r "completions"

        echo "Building choco template...";
        python "./deployment/windows/choco/choco_packager.py" "bottom_i686-pc-windows-msvc.zip" "bottom_x86_64-pc-windows-msvc.zip" $TRAVIS_TAG "./deployment/windows/choco/bottom.nuspec.template" "./deployment/windows/choco/chocolateyinstall.ps1.template" "./deployment/windows/choco/bottom.nuspec" "./deployment/windows/choco/tools/chocolateyinstall.ps1" "./deployment/windows/choco/tools/";
        cd "./deployment/windows/choco/"
        zip -r choco.zip "bottom.nuspec" "tools/";
        cd "../../../";
        mv "./deployment/windows/choco/choco.zip" "./choco.zip"

        echo "Building msi file...";
        cargo install cargo-wix;
        cargo wix init;
        cargo wix;

        echo "Building winget template...";
        python "./deployment/packager.py" $TRAVIS_TAG "./deployment/windows/winget/winget.yaml.template" "$TRAVIS_TAG.yaml" "SHA256" "./bottom_x86_64_installer.msi";
      fi

      echo "Done Windows pre-deploy!";
    else
        echo "Building release for macOS/Linux, target: $TARGET";
        cargo build --release;
        cp ./target/release/btm btm;
        strip btm;
        local target_dir=$(ls target/release/build/bottom-*/out/btm.bash | head -n1 | xargs dirname)
        cp -r $target_dir completions
        echo "Tar-ing macOS/Linux binary and completions..."
        tar -czvf bottom_$TARGET.tar.gz btm completions;

        if [[ $TRAVIS_OS_NAME == "linux" && $TARGET == "x86_64-unknown-linux-gnu" ]]; then
          echo "Building further results for x86_64-unknown-linux-gnu..."
          echo "Generating AUR template...";
          python "./deployment/packager.py" $TRAVIS_TAG "./deployment/linux/arch/PKGBUILD_BIN.template" "./PKGBUILD_BIN" "SHA512" "./bottom_x86_64-unknown-linux-gnu.tar.gz";
          curl -LO "https://github.com/ClementTsang/bottom/archive/$TRAVIS_TAG.tar.gz";
          
          echo "Generating AUR binary template...";
          python "./deployment/packager.py" $TRAVIS_TAG "./deployment/linux/arch/PKGBUILD.template" "./PKGBUILD" "SHA512" "./$TRAVIS_TAG.tar.gz";
          rm "$TRAVIS_TAG.tar.gz";

          echo "Tar-ing AUR PKGBUILDs...";
          tar -czvf arch.tar.gz PKGBUILD_BIN PKGBUILD;
          
          # Note this requires the completions directory in the current directory.
          echo "Generating Debian install file...";
          cargo install cargo-deb;
          cargo deb;
          cp ./target/debian/bottom_*.deb .;
        fi

        echo "Done macOS/Linux pre-deploy!";
    fi

deploy:
  provider: releases
  overwrite: true
  api_key:
    secure: ppBn0DnqZ+Rzb84doZQxYdUBQ0rVrZNIiH6ZSFEiCVJd0ttqXfOjK/qXbIf/zabwO0Olqz18jwd9piHjNigWRrHwX9N+YH0DZTM3f4WS2/2acvOP3AjSw6oERjYTwS5yKe/XP1sU11uL6O0oAxYFeiAkn7QOM7flVUE2BmmLAs2lLtQ+9ylmUeBGatrkTfQ0Z2i1o7p5mtI2fKUozpImtHq8TClQEsF4oQS5nvkHtpLuPQ0UrJ8vKZijDBeMuLbDkR121ujRnjoBt8+eXBRbwzAvVotwRozyol8noAN3i4VvYueId6oX7Y2DSEp26wnCuRXGurUnyya5JE55AKoevK+SUHRe5+29/2lPbC5d/etZt2tSX1AIJk9fHeIfRPSTzanIIyDpUzSGoMKjl1ARKGrgHYehRxMKpW0cC2xHSlQ+NrA5apLpXKr2IzpkGsxpAxLqRASbX2VJYCEL70WoJfXinZrxeDxXsaWBLGaj9ySyk059GZBMz9GBdYNtwF3G/3aSIt0nkEGgKipgYXHi5keKKGmyfeZyYkRJRbc369JRZiHuOWct+1ZsOdrKKdbyAdcDGj5kbKuYwA6E+wgI62IWvUTm+vtKDuIbLpu/48aOUuEslGHkYAszLTapX/Le9c9XTu3L+PMgkPq2LSyaeGrfnM+DE/Hwe3Jvurccp94=
  file_glob: true
  file:
    - bottom_*.tar.gz
    - bottom_*.zip
    - bottom_*.deb
    - arch.tar.gz
    - bottom.rb
    - choco.zip
    - bottom_x86_64_installer.msi
    - $TRAVIS_TAG.yaml
  skip_cleanup: true
  on:
    tags: true
    condition: "$TRAVIS_RUST_VERSION = stable"
    repo: ClementTsang/bottom
  draft: true