2020-05-25 00:45:47 +00:00
|
|
|
---
|
2019-10-05 09:29:13 +00:00
|
|
|
name: Main workflow
|
2019-10-10 07:12:45 +00:00
|
|
|
on:
|
|
|
|
push:
|
|
|
|
paths-ignore:
|
|
|
|
- "docs/**"
|
2019-10-14 15:34:26 +00:00
|
|
|
- "**.md"
|
2019-10-15 15:32:41 +00:00
|
|
|
pull_request:
|
|
|
|
paths-ignore:
|
|
|
|
- "docs/**"
|
|
|
|
- "**.md"
|
2019-10-10 07:12:45 +00:00
|
|
|
|
2019-10-04 06:12:48 +00:00
|
|
|
jobs:
|
|
|
|
# Run the `rustfmt` code formatter
|
|
|
|
rustfmt:
|
|
|
|
name: Rustfmt [Formatter]
|
|
|
|
runs-on: ubuntu-latest
|
|
|
|
steps:
|
2019-12-28 14:32:17 +00:00
|
|
|
- uses: actions/checkout@v2
|
2019-10-04 06:12:48 +00:00
|
|
|
- uses: actions-rs/toolchain@v1
|
|
|
|
with:
|
2019-10-20 14:19:40 +00:00
|
|
|
profile: minimal
|
2019-10-04 06:12:48 +00:00
|
|
|
toolchain: stable
|
2019-10-20 14:19:40 +00:00
|
|
|
components: rustfmt
|
2019-10-04 06:12:48 +00:00
|
|
|
override: true
|
|
|
|
- uses: actions-rs/cargo@v1
|
|
|
|
with:
|
|
|
|
command: fmt
|
|
|
|
args: --all -- --check
|
|
|
|
|
|
|
|
# Run the `clippy` linting tool
|
|
|
|
clippy:
|
|
|
|
name: Clippy [Linter]
|
|
|
|
runs-on: ubuntu-latest
|
|
|
|
steps:
|
2019-12-28 14:32:17 +00:00
|
|
|
- uses: actions/checkout@v2
|
2019-10-04 06:12:48 +00:00
|
|
|
- uses: actions-rs/toolchain@v1
|
|
|
|
with:
|
2019-10-20 14:19:40 +00:00
|
|
|
profile: minimal
|
2019-10-04 06:12:48 +00:00
|
|
|
toolchain: stable
|
2019-10-20 14:19:40 +00:00
|
|
|
components: clippy
|
2019-10-04 06:12:48 +00:00
|
|
|
override: true
|
|
|
|
- uses: actions-rs/clippy-check@v1
|
|
|
|
with:
|
|
|
|
token: ${{ secrets.GITHUB_TOKEN }}
|
|
|
|
args: --all-targets --all-features -- -D clippy::all
|
|
|
|
|
|
|
|
# Ensure that the project could be successfully compiled
|
|
|
|
cargo_check:
|
|
|
|
name: Compile
|
|
|
|
runs-on: ubuntu-latest
|
|
|
|
steps:
|
2019-12-28 14:32:17 +00:00
|
|
|
- uses: actions/checkout@v2
|
2020-05-25 00:45:47 +00:00
|
|
|
|
|
|
|
- name: Cache cargo registry
|
|
|
|
uses: actions/cache@v1
|
|
|
|
with:
|
|
|
|
path: ~/.cargo/registry
|
|
|
|
key: ${{ runner.os }}-cargo-registry-${{ hashFiles('**/Cargo.lock') }}
|
|
|
|
restore-keys: |
|
|
|
|
${{ runner.os }}-cargo-registry-
|
|
|
|
- name: Cache cargo index
|
|
|
|
uses: actions/cache@v1
|
|
|
|
with:
|
|
|
|
path: ~/.cargo/git
|
|
|
|
key: ${{ runner.os }}-cargo-index-${{ hashFiles('**/Cargo.lock') }}
|
|
|
|
restore-keys: |
|
|
|
|
${{ runner.os }}-cargo-index-
|
|
|
|
- name: Cache cargo build
|
|
|
|
uses: actions/cache@v1
|
|
|
|
with:
|
|
|
|
path: target
|
|
|
|
key: ${{ runner.os }}-cargo-build-target-${{ hashFiles('**/Cargo.lock') }}
|
|
|
|
|
2019-10-04 06:12:48 +00:00
|
|
|
- uses: actions-rs/toolchain@v1
|
|
|
|
with:
|
2019-10-20 14:19:40 +00:00
|
|
|
profile: minimal
|
2019-10-04 06:12:48 +00:00
|
|
|
toolchain: stable
|
|
|
|
override: true
|
|
|
|
- uses: actions-rs/cargo@v1
|
|
|
|
with:
|
|
|
|
command: check
|
|
|
|
args: --all
|
|
|
|
|
2019-10-15 15:10:16 +00:00
|
|
|
# Run tests on Linux, macOS, and Windows
|
2019-10-04 06:12:48 +00:00
|
|
|
# On both Rust stable and Rust nightly
|
|
|
|
test:
|
|
|
|
name: Test Suite
|
|
|
|
runs-on: ${{ matrix.os }}
|
|
|
|
strategy:
|
|
|
|
fail-fast: false
|
|
|
|
matrix:
|
2019-10-15 15:10:16 +00:00
|
|
|
os: [ubuntu-latest, macOS-latest, windows-latest]
|
2019-10-04 06:12:48 +00:00
|
|
|
rust: [stable, nightly]
|
|
|
|
steps:
|
|
|
|
# Checkout the branch being tested
|
2019-12-28 14:32:17 +00:00
|
|
|
- uses: actions/checkout@v2
|
2019-10-04 06:12:48 +00:00
|
|
|
|
2020-01-18 01:43:29 +00:00
|
|
|
# Cache files between builds
|
|
|
|
- name: Cache cargo registry
|
|
|
|
uses: actions/cache@v1
|
|
|
|
with:
|
|
|
|
path: ~/.cargo/registry
|
|
|
|
key: ${{ runner.os }}-cargo-registry-${{ hashFiles('**/Cargo.lock') }}
|
2020-05-25 00:45:47 +00:00
|
|
|
restore-keys: |
|
|
|
|
${{ runner.os }}-cargo-registry-
|
2020-01-18 01:43:29 +00:00
|
|
|
- name: Cache cargo index
|
|
|
|
uses: actions/cache@v1
|
|
|
|
with:
|
|
|
|
path: ~/.cargo/git
|
|
|
|
key: ${{ runner.os }}-cargo-index-${{ hashFiles('**/Cargo.lock') }}
|
2020-05-25 00:45:47 +00:00
|
|
|
restore-keys: |
|
|
|
|
${{ runner.os }}-cargo-index-
|
2020-01-18 01:43:29 +00:00
|
|
|
- name: Cache cargo build
|
|
|
|
uses: actions/cache@v1
|
|
|
|
with:
|
|
|
|
path: target
|
|
|
|
key: ${{ runner.os }}-cargo-build-target-${{ hashFiles('**/Cargo.lock') }}
|
|
|
|
|
2019-10-04 06:12:48 +00:00
|
|
|
# Install all the required dependencies for testing
|
|
|
|
- uses: actions-rs/toolchain@v1
|
|
|
|
with:
|
2019-10-20 14:19:40 +00:00
|
|
|
profile: minimal
|
2019-10-04 06:12:48 +00:00
|
|
|
toolchain: stable
|
|
|
|
override: true
|
|
|
|
|
|
|
|
# Install dotnet at a fixed version
|
2019-10-25 11:44:20 +00:00
|
|
|
- uses: actions/setup-dotnet@v1
|
2019-10-04 06:12:48 +00:00
|
|
|
with:
|
|
|
|
dotnet-version: "2.2.402"
|
|
|
|
|
2020-01-18 01:43:29 +00:00
|
|
|
# Install Mercurial (pre-installed on Linux and windows)
|
2019-12-02 22:37:18 +00:00
|
|
|
- name: Install Mercurial (macos)
|
|
|
|
if: matrix.os == 'macOS-latest'
|
|
|
|
env:
|
|
|
|
HGPYTHON3: 1
|
|
|
|
run: pip install mercurial
|
2019-12-13 19:22:38 +00:00
|
|
|
|
2019-12-09 01:42:51 +00:00
|
|
|
# Install Terraform at a fixed version
|
|
|
|
- uses: volcano-coffee-company/setup-terraform@v1
|
|
|
|
with:
|
|
|
|
version: "0.12.14"
|
2019-12-02 22:37:18 +00:00
|
|
|
|
2019-10-04 06:12:48 +00:00
|
|
|
# Run the ignored tests that expect the above setup
|
|
|
|
- name: Run all tests
|
|
|
|
uses: actions-rs/cargo@v1
|
|
|
|
with:
|
|
|
|
command: test
|
|
|
|
args: -- -Z unstable-options --include-ignored
|
|
|
|
|
2019-10-04 15:17:29 +00:00
|
|
|
# Publish starship to Crates.io
|
2019-10-04 06:12:48 +00:00
|
|
|
cargo_publish:
|
|
|
|
if: startsWith(github.ref, 'refs/tags/v')
|
2019-10-04 14:22:14 +00:00
|
|
|
name: Publish Cargo Package
|
2019-10-04 06:12:48 +00:00
|
|
|
runs-on: ubuntu-latest
|
|
|
|
steps:
|
2019-12-28 14:32:17 +00:00
|
|
|
- uses: actions/checkout@v2
|
2019-10-04 06:12:48 +00:00
|
|
|
- uses: actions-rs/toolchain@v1
|
|
|
|
with:
|
2019-10-20 14:19:40 +00:00
|
|
|
profile: minimal
|
2019-10-04 06:12:48 +00:00
|
|
|
toolchain: stable
|
|
|
|
override: true
|
2019-10-04 14:22:14 +00:00
|
|
|
- run: cargo login $CRATES_IO_TOKEN
|
|
|
|
- run: cargo publish
|
2019-10-04 14:54:21 +00:00
|
|
|
env:
|
|
|
|
CRATES_IO_TOKEN: ${{ secrets.CRATES_IO_TOKEN }}
|
2019-10-04 06:12:48 +00:00
|
|
|
|
2019-12-13 19:22:38 +00:00
|
|
|
update_brew_formula:
|
|
|
|
if: startsWith(github.ref, 'refs/tags/v')
|
|
|
|
name: Update Brew Formula
|
2020-06-26 15:28:34 +00:00
|
|
|
runs-on: ubuntu-latest
|
2019-12-13 19:22:38 +00:00
|
|
|
steps:
|
2020-06-26 15:28:34 +00:00
|
|
|
- uses: mislav/bump-homebrew-formula-action@v1
|
|
|
|
with:
|
|
|
|
formula-name: starship
|
2019-12-13 19:22:38 +00:00
|
|
|
env:
|
2020-06-26 15:28:34 +00:00
|
|
|
COMMITTER_TOKEN: ${{ secrets.HOMEBREW_GITHUB_API_TOKEN }}
|
2019-12-13 19:22:38 +00:00
|
|
|
|
2019-11-25 16:01:01 +00:00
|
|
|
# Build sources for every OS
|
|
|
|
github_build:
|
2019-10-04 06:12:48 +00:00
|
|
|
if: startsWith(github.ref, 'refs/tags/v')
|
2019-11-25 16:01:01 +00:00
|
|
|
name: Build release binaries
|
2019-10-04 06:12:48 +00:00
|
|
|
strategy:
|
|
|
|
fail-fast: false
|
|
|
|
matrix:
|
2019-10-04 12:47:09 +00:00
|
|
|
target:
|
|
|
|
- x86_64-unknown-linux-gnu
|
|
|
|
- x86_64-unknown-linux-musl
|
|
|
|
- x86_64-apple-darwin
|
2019-11-12 05:30:35 +00:00
|
|
|
- x86_64-pc-windows-msvc
|
2019-10-04 06:12:48 +00:00
|
|
|
include:
|
2019-10-04 12:47:09 +00:00
|
|
|
- target: x86_64-unknown-linux-gnu
|
|
|
|
os: ubuntu-latest
|
2019-10-04 06:12:48 +00:00
|
|
|
name: starship-x86_64-unknown-linux-gnu.tar.gz
|
2019-10-04 12:47:09 +00:00
|
|
|
- target: x86_64-unknown-linux-musl
|
|
|
|
os: ubuntu-latest
|
2019-10-04 06:12:48 +00:00
|
|
|
name: starship-x86_64-unknown-linux-musl.tar.gz
|
2019-10-04 12:47:09 +00:00
|
|
|
- target: x86_64-apple-darwin
|
|
|
|
os: macOS-latest
|
2019-10-04 06:12:48 +00:00
|
|
|
name: starship-x86_64-apple-darwin.tar.gz
|
2019-11-12 05:30:35 +00:00
|
|
|
- target: x86_64-pc-windows-msvc
|
2019-10-15 15:10:16 +00:00
|
|
|
os: windows-latest
|
2019-11-12 05:30:35 +00:00
|
|
|
name: starship-x86_64-pc-windows-msvc.zip
|
2019-10-04 06:12:48 +00:00
|
|
|
runs-on: ${{ matrix.os }}
|
|
|
|
steps:
|
2019-12-28 14:32:17 +00:00
|
|
|
- uses: actions/checkout@v2
|
2019-10-04 06:12:48 +00:00
|
|
|
|
2020-05-25 00:45:47 +00:00
|
|
|
- name: Cache cargo registry
|
|
|
|
uses: actions/cache@v1
|
|
|
|
with:
|
|
|
|
path: ~/.cargo/registry
|
|
|
|
key: ${{ runner.os }}-cargo-registry-${{ hashFiles('**/Cargo.lock') }}
|
|
|
|
restore-keys: |
|
|
|
|
${{ runner.os }}-cargo-registry-
|
|
|
|
- name: Cache cargo index
|
|
|
|
uses: actions/cache@v1
|
|
|
|
with:
|
|
|
|
path: ~/.cargo/git
|
|
|
|
key: ${{ runner.os }}-cargo-index-${{ hashFiles('**/Cargo.lock') }}
|
|
|
|
restore-keys: |
|
|
|
|
${{ runner.os }}-cargo-index-
|
|
|
|
|
2019-10-04 06:12:48 +00:00
|
|
|
- name: Install Rust toolchain
|
|
|
|
uses: actions-rs/toolchain@v1
|
|
|
|
with:
|
2019-10-20 14:19:40 +00:00
|
|
|
profile: minimal
|
2019-10-04 06:12:48 +00:00
|
|
|
toolchain: stable
|
|
|
|
override: true
|
|
|
|
target: ${{ matrix.target }}
|
|
|
|
|
|
|
|
- name: Install musl tools
|
|
|
|
if: matrix.target == 'x86_64-unknown-linux-musl'
|
2019-12-20 20:42:21 +00:00
|
|
|
run: sudo apt-get install -y musl-tools
|
2019-10-04 06:12:48 +00:00
|
|
|
|
|
|
|
- name: Build target
|
2020-03-15 01:07:34 +00:00
|
|
|
if: matrix.target != 'x86_64-unknown-linux-musl'
|
2019-10-04 06:12:48 +00:00
|
|
|
uses: actions-rs/cargo@v1
|
|
|
|
with:
|
|
|
|
command: build
|
|
|
|
args: --release --target ${{ matrix.target }}
|
2020-05-25 00:45:47 +00:00
|
|
|
|
2020-03-15 01:07:34 +00:00
|
|
|
- name: Build target (musl)
|
|
|
|
if: matrix.target == 'x86_64-unknown-linux-musl'
|
|
|
|
uses: actions-rs/cargo@v1
|
|
|
|
with:
|
|
|
|
command: build
|
|
|
|
args: --release --features tls-vendored --target ${{ matrix.target }}
|
2019-10-04 06:12:48 +00:00
|
|
|
|
2019-10-20 14:19:40 +00:00
|
|
|
- name: Prepare build artifacts [Windows]
|
|
|
|
if: matrix.os == 'windows-latest'
|
2019-10-04 06:12:48 +00:00
|
|
|
run: |
|
2019-11-13 01:50:57 +00:00
|
|
|
cd target/${{ matrix.target }}/release
|
|
|
|
strip starship.exe
|
|
|
|
7z a ../../../${{ matrix.name }} starship.exe
|
|
|
|
cd -
|
2019-10-20 14:19:40 +00:00
|
|
|
|
|
|
|
- name: Prepare build artifacts [-nix]
|
|
|
|
if: matrix.os != 'windows-latest'
|
|
|
|
run: |
|
2019-11-13 01:50:57 +00:00
|
|
|
cd target/${{ matrix.target }}/release
|
|
|
|
strip starship
|
|
|
|
tar czvf ../../../${{ matrix.name }} starship
|
|
|
|
cd -
|
2019-10-04 06:12:48 +00:00
|
|
|
|
2019-11-25 16:01:01 +00:00
|
|
|
- name: Upload build artifact
|
|
|
|
uses: actions/upload-artifact@v1
|
|
|
|
with:
|
|
|
|
name: ${{ matrix.name }}
|
|
|
|
path: ${{ matrix.name }}
|
|
|
|
|
|
|
|
# Create GitHub release with Rust build targets and release notes
|
|
|
|
github_release:
|
|
|
|
if: startsWith(github.ref, 'refs/tags/v')
|
|
|
|
name: Create GitHub Release
|
|
|
|
needs: github_build
|
|
|
|
runs-on: ubuntu-latest
|
|
|
|
steps:
|
2019-12-28 14:32:17 +00:00
|
|
|
- uses: actions/checkout@v2
|
2019-11-25 16:01:01 +00:00
|
|
|
|
2020-05-15 15:09:07 +00:00
|
|
|
# These can be squashed when https://github.com/actions/download-artifact/issues/6 is closed
|
|
|
|
- name: Download releases from github_build
|
|
|
|
uses: actions/download-artifact@v1
|
|
|
|
with:
|
|
|
|
name: starship-x86_64-unknown-linux-gnu.tar.gz
|
|
|
|
path: .
|
|
|
|
- name: Download releases from github_build
|
|
|
|
uses: actions/download-artifact@v1
|
|
|
|
with:
|
|
|
|
name: starship-x86_64-unknown-linux-musl.tar.gz
|
|
|
|
path: .
|
|
|
|
- name: Download releases from github_build
|
|
|
|
uses: actions/download-artifact@v1
|
|
|
|
with:
|
|
|
|
name: starship-x86_64-apple-darwin.tar.gz
|
|
|
|
path: .
|
|
|
|
- name: Download releases from github_build
|
|
|
|
uses: actions/download-artifact@v1
|
|
|
|
with:
|
|
|
|
name: starship-x86_64-pc-windows-msvc.zip
|
|
|
|
path: .
|
2019-11-25 16:01:01 +00:00
|
|
|
|
|
|
|
- name: Generate checksums
|
|
|
|
run: for file in starship-*; do openssl dgst -sha256 -r "$file" | awk '{print $1}' > "${file}.sha256"; done
|
|
|
|
|
2019-10-04 06:12:48 +00:00
|
|
|
- name: Generate release notes
|
|
|
|
run: |
|
|
|
|
# Temporary fix for https://github.com/actions/setup-go/issues/14
|
|
|
|
export PATH=$PATH:$(go env GOPATH)/bin
|
|
|
|
go get -u github.com/git-chglog/git-chglog/cmd/git-chglog
|
2019-10-04 14:54:21 +00:00
|
|
|
git-chglog -c .github/chglog/release.yml $(git describe --tags) > RELEASE.md
|
2019-10-04 06:12:48 +00:00
|
|
|
|
|
|
|
- name: Create GitHub release ${{ matrix.target }}
|
|
|
|
uses: softprops/action-gh-release@v1
|
|
|
|
with:
|
2019-11-25 16:01:01 +00:00
|
|
|
files: |
|
|
|
|
starship-x86_64-unknown-linux-gnu.tar.gz
|
|
|
|
starship-x86_64-unknown-linux-gnu.tar.gz.sha256
|
|
|
|
starship-x86_64-unknown-linux-musl.tar.gz
|
|
|
|
starship-x86_64-unknown-linux-musl.tar.gz.sha256
|
|
|
|
starship-x86_64-apple-darwin.tar.gz
|
|
|
|
starship-x86_64-apple-darwin.tar.gz.sha256
|
|
|
|
starship-x86_64-pc-windows-msvc.zip
|
|
|
|
starship-x86_64-pc-windows-msvc.zip.sha256
|
2019-10-04 14:54:21 +00:00
|
|
|
body_path: RELEASE.md
|
2019-10-04 06:12:48 +00:00
|
|
|
env:
|
|
|
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|