mirror of
https://github.com/Llewellynvdm/starship.git
synced 2024-11-24 13:47:38 +00:00
ci: rewrite project GH Actions (#1450)
This commit is contained in:
parent
7ce62cd9d4
commit
0f52b7b12e
145
.github/workflows/deploy.yml
vendored
Normal file
145
.github/workflows/deploy.yml
vendored
Normal file
@ -0,0 +1,145 @@
|
||||
name: Deploy
|
||||
on:
|
||||
push:
|
||||
tags:
|
||||
- "v*"
|
||||
|
||||
jobs:
|
||||
# Publish starship to Crates.io
|
||||
cargo_publish:
|
||||
name: Publish Cargo Package
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Setup | Checkout
|
||||
uses: actions/checkout@v2
|
||||
|
||||
- name: Setup | Rust
|
||||
uses: ATiltedTree/setup-rust@v1
|
||||
with:
|
||||
rust-version: stable
|
||||
|
||||
- name: Build | Publish
|
||||
run: cargo publish --token ${{ secrets.CRATES_IO_TOKEN }}
|
||||
|
||||
update_brew_formula:
|
||||
name: Update Brew Formula
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: mislav/bump-homebrew-formula-action@v1.6
|
||||
with:
|
||||
formula-name: starship
|
||||
env:
|
||||
COMMITTER_TOKEN: ${{ secrets.HOMEBREW_GITHUB_API_TOKEN }}
|
||||
|
||||
# Build sources for every OS
|
||||
github_build:
|
||||
name: Build release binaries
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
target:
|
||||
- x86_64-unknown-linux-gnu
|
||||
- x86_64-unknown-linux-musl
|
||||
- x86_64-apple-darwin
|
||||
- x86_64-pc-windows-msvc
|
||||
include:
|
||||
- target: x86_64-unknown-linux-gnu
|
||||
os: ubuntu-latest
|
||||
name: starship-x86_64-unknown-linux-gnu.tar.gz
|
||||
- target: x86_64-unknown-linux-musl
|
||||
os: ubuntu-latest
|
||||
name: starship-x86_64-unknown-linux-musl.tar.gz
|
||||
- target: x86_64-apple-darwin
|
||||
os: macOS-latest
|
||||
name: starship-x86_64-apple-darwin.tar.gz
|
||||
- target: x86_64-pc-windows-msvc
|
||||
os: windows-latest
|
||||
name: starship-x86_64-pc-windows-msvc.zip
|
||||
runs-on: ${{ matrix.os }}
|
||||
steps:
|
||||
- name: Setup | Checkout
|
||||
uses: actions/checkout@v2
|
||||
|
||||
# Cache files between builds
|
||||
- name: Setup | Cache Cargo
|
||||
uses: actions/cache@v2
|
||||
with:
|
||||
path: |
|
||||
~/.cargo/registry
|
||||
~/.cargo/git
|
||||
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
|
||||
|
||||
- name: Setup | Rust
|
||||
uses: ATiltedTree/setup-rust@v1
|
||||
with:
|
||||
rust-version: stable
|
||||
targets: ${{ matrix.target }}
|
||||
|
||||
- name: Setup | musl tools
|
||||
if: matrix.target == 'x86_64-unknown-linux-musl'
|
||||
run: sudo apt install -y musl-tools
|
||||
|
||||
- name: Build | Build
|
||||
if: matrix.target != 'x86_64-unknown-linux-musl'
|
||||
run: cargo build --release --target ${{ matrix.target }}
|
||||
|
||||
- name: Build | Build (musl)
|
||||
if: matrix.target == 'x86_64-unknown-linux-musl'
|
||||
run: cargo build --release --features tls-vendored --target ${{ matrix.target }}
|
||||
|
||||
- name: Post Setup | Prepare artifacts [Windows]
|
||||
if: matrix.os == 'windows-latest'
|
||||
run: |
|
||||
cd target/${{ matrix.target }}/release
|
||||
strip starship.exe
|
||||
7z a ../../../${{ matrix.name }} starship.exe
|
||||
cd -
|
||||
|
||||
- name: Post Setup | Prepare artifacts [-nix]
|
||||
if: matrix.os != 'windows-latest'
|
||||
run: |
|
||||
cd target/${{ matrix.target }}/release
|
||||
strip starship
|
||||
tar czvf ../../../${{ matrix.name }} starship
|
||||
cd -
|
||||
|
||||
- name: Post Setup | Upload artifacts
|
||||
uses: actions/upload-artifact@v2
|
||||
with:
|
||||
name: ${{ matrix.name }}
|
||||
path: ${{ matrix.name }}
|
||||
|
||||
# Create GitHub release with Rust build targets and release notes
|
||||
github_release:
|
||||
name: Create GitHub Release
|
||||
needs: github_build
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Setup | Checkout
|
||||
uses: actions/checkout@v2
|
||||
with:
|
||||
fetch-depth: 0
|
||||
|
||||
- name: Setup | Go
|
||||
uses: actions/setup-go@v2
|
||||
with:
|
||||
go-version: "^1.13.1"
|
||||
|
||||
- name: Setup | Artifacts
|
||||
uses: actions/download-artifact@v2
|
||||
|
||||
- name: Setup | Checksums
|
||||
run: for file in starship-*/starship-*; do openssl dgst -sha256 -r "$file" | awk '{print $1}' > "${file}.sha256"; done
|
||||
|
||||
- name: Setup | Release notes
|
||||
run: |
|
||||
go get -u github.com/git-chglog/git-chglog/cmd/git-chglog
|
||||
git-chglog -c .github/chglog/release.yml $(git describe --tags) > RELEASE.md
|
||||
|
||||
- name: Build | Publish
|
||||
uses: softprops/action-gh-release@v1
|
||||
with:
|
||||
files: starship-*/starship-*
|
||||
body_path: RELEASE.md
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
324
.github/workflows/workflow.yml
vendored
324
.github/workflows/workflow.yml
vendored
@ -1,4 +1,3 @@
|
||||
---
|
||||
name: Main workflow
|
||||
on:
|
||||
push:
|
||||
@ -16,311 +15,118 @@ jobs:
|
||||
name: Rustfmt [Formatter]
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- uses: actions-rs/toolchain@v1
|
||||
- name: Setup | Checkout
|
||||
uses: actions/checkout@v2
|
||||
|
||||
- name: Setup | Rust
|
||||
uses: ATiltedTree/setup-rust@v1
|
||||
with:
|
||||
profile: minimal
|
||||
toolchain: stable
|
||||
rust-version: stable
|
||||
components: rustfmt
|
||||
override: true
|
||||
- uses: actions-rs/cargo@v1
|
||||
with:
|
||||
command: fmt
|
||||
args: --all -- --check
|
||||
|
||||
- name: Build | Format
|
||||
run: cargo fmt --all -- --check
|
||||
|
||||
# Run the `clippy` linting tool
|
||||
clippy:
|
||||
name: Clippy [Linter]
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- uses: actions-rs/toolchain@v1
|
||||
- name: Setup | Checkout
|
||||
uses: actions/checkout@v2
|
||||
|
||||
# Cache files between builds
|
||||
- name: Setup | Cache Cargo
|
||||
uses: actions/cache@v2
|
||||
with:
|
||||
profile: minimal
|
||||
toolchain: stable
|
||||
path: |
|
||||
~/.cargo/registry
|
||||
~/.cargo/git
|
||||
target
|
||||
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
|
||||
|
||||
- name: Setup | Rust
|
||||
uses: ATiltedTree/setup-rust@v1
|
||||
with:
|
||||
rust-version: stable
|
||||
components: clippy
|
||||
override: true
|
||||
- uses: actions-rs/clippy-check@v1
|
||||
with:
|
||||
token: ${{ secrets.GITHUB_TOKEN }}
|
||||
args: --all-targets --all-features -- -D clippy::all
|
||||
|
||||
- name: Build | Lint
|
||||
run: cargo clippy --all-targets --all-features -- -D clippy::all
|
||||
|
||||
# Ensure that the project could be successfully compiled
|
||||
cargo_check:
|
||||
name: Compile
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- name: Setup | Checkout
|
||||
uses: actions/checkout@v2
|
||||
|
||||
- name: Cache cargo registry
|
||||
uses: actions/cache@v1
|
||||
# Cache files between builds
|
||||
- name: Setup | Cache Cargo
|
||||
uses: actions/cache@v2
|
||||
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') }}
|
||||
path: |
|
||||
~/.cargo/registry
|
||||
~/.cargo/git
|
||||
target
|
||||
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
|
||||
|
||||
- uses: actions-rs/toolchain@v1
|
||||
- name: Setup | Rust
|
||||
uses: ATiltedTree/setup-rust@v1
|
||||
with:
|
||||
profile: minimal
|
||||
toolchain: stable
|
||||
override: true
|
||||
- uses: actions-rs/cargo@v1
|
||||
with:
|
||||
command: check
|
||||
args: --all
|
||||
rust-version: stable
|
||||
|
||||
- name: Build | Check
|
||||
run: cargo check --all
|
||||
|
||||
# Run tests on Linux, macOS, and Windows
|
||||
# On both Rust stable and Rust nightly
|
||||
test:
|
||||
name: Test Suite
|
||||
runs-on: ${{ matrix.os }}
|
||||
needs: cargo_check # First check then run expansive tests
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
os: [ubuntu-latest, macOS-latest, windows-latest]
|
||||
rust: [stable, nightly]
|
||||
steps:
|
||||
# Checkout the branch being tested
|
||||
- uses: actions/checkout@v2
|
||||
- name: Setup | Checkout
|
||||
uses: actions/checkout@v2
|
||||
|
||||
# Cache files between builds
|
||||
- name: Cache cargo registry
|
||||
uses: actions/cache@v1
|
||||
- name: Setup | Cache Cargo
|
||||
uses: actions/cache@v2
|
||||
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') }}
|
||||
path: |
|
||||
~/.cargo/registry
|
||||
~/.cargo/git
|
||||
target
|
||||
key: ${{ runner.os }}-${{ matrix.rust }}-cargo-${{ hashFiles('**/Cargo.lock') }}
|
||||
|
||||
# Install all the required dependencies for testing
|
||||
- uses: actions-rs/toolchain@v1
|
||||
- name: Setup | Rust
|
||||
uses: ATiltedTree/setup-rust@v1
|
||||
with:
|
||||
profile: minimal
|
||||
toolchain: stable
|
||||
override: true
|
||||
rust-version: ${{ matrix.rust }}
|
||||
|
||||
# Install dotnet at a fixed version
|
||||
- uses: actions/setup-dotnet@v1
|
||||
- name: Setup | DotNet
|
||||
uses: actions/setup-dotnet@v1
|
||||
with:
|
||||
dotnet-version: "2.2.402"
|
||||
|
||||
# Install Mercurial (pre-installed on Linux and windows)
|
||||
- name: Install Mercurial (macos)
|
||||
- name: Setup | Mercurial (macos)
|
||||
if: matrix.os == 'macOS-latest'
|
||||
env:
|
||||
HGPYTHON3: 1
|
||||
run: pip install mercurial
|
||||
run: pip3 install mercurial
|
||||
|
||||
# Install Terraform at a fixed version
|
||||
- uses: volcano-coffee-company/setup-terraform@v1
|
||||
- name: Setup | Terraform
|
||||
uses: volcano-coffee-company/setup-terraform@v1
|
||||
with:
|
||||
version: "0.12.14"
|
||||
|
||||
# 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
|
||||
|
||||
# Publish starship to Crates.io
|
||||
cargo_publish:
|
||||
if: startsWith(github.ref, 'refs/tags/v')
|
||||
name: Publish Cargo Package
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- uses: actions-rs/toolchain@v1
|
||||
with:
|
||||
profile: minimal
|
||||
toolchain: stable
|
||||
override: true
|
||||
- run: cargo login $CRATES_IO_TOKEN
|
||||
- run: cargo publish
|
||||
env:
|
||||
CRATES_IO_TOKEN: ${{ secrets.CRATES_IO_TOKEN }}
|
||||
|
||||
update_brew_formula:
|
||||
if: startsWith(github.ref, 'refs/tags/v')
|
||||
name: Update Brew Formula
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: mislav/bump-homebrew-formula-action@v1
|
||||
with:
|
||||
formula-name: starship
|
||||
env:
|
||||
COMMITTER_TOKEN: ${{ secrets.HOMEBREW_GITHUB_API_TOKEN }}
|
||||
|
||||
# Build sources for every OS
|
||||
github_build:
|
||||
if: startsWith(github.ref, 'refs/tags/v')
|
||||
name: Build release binaries
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
target:
|
||||
- x86_64-unknown-linux-gnu
|
||||
- x86_64-unknown-linux-musl
|
||||
- x86_64-apple-darwin
|
||||
- x86_64-pc-windows-msvc
|
||||
include:
|
||||
- target: x86_64-unknown-linux-gnu
|
||||
os: ubuntu-latest
|
||||
name: starship-x86_64-unknown-linux-gnu.tar.gz
|
||||
- target: x86_64-unknown-linux-musl
|
||||
os: ubuntu-latest
|
||||
name: starship-x86_64-unknown-linux-musl.tar.gz
|
||||
- target: x86_64-apple-darwin
|
||||
os: macOS-latest
|
||||
name: starship-x86_64-apple-darwin.tar.gz
|
||||
- target: x86_64-pc-windows-msvc
|
||||
os: windows-latest
|
||||
name: starship-x86_64-pc-windows-msvc.zip
|
||||
runs-on: ${{ matrix.os }}
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
|
||||
- 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: Install Rust toolchain
|
||||
uses: actions-rs/toolchain@v1
|
||||
with:
|
||||
profile: minimal
|
||||
toolchain: stable
|
||||
override: true
|
||||
target: ${{ matrix.target }}
|
||||
|
||||
- name: Install musl tools
|
||||
if: matrix.target == 'x86_64-unknown-linux-musl'
|
||||
run: sudo apt-get install -y musl-tools
|
||||
|
||||
- name: Build target
|
||||
if: matrix.target != 'x86_64-unknown-linux-musl'
|
||||
uses: actions-rs/cargo@v1
|
||||
with:
|
||||
command: build
|
||||
args: --release --target ${{ matrix.target }}
|
||||
|
||||
- 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 }}
|
||||
|
||||
- name: Prepare build artifacts [Windows]
|
||||
if: matrix.os == 'windows-latest'
|
||||
run: |
|
||||
cd target/${{ matrix.target }}/release
|
||||
strip starship.exe
|
||||
7z a ../../../${{ matrix.name }} starship.exe
|
||||
cd -
|
||||
|
||||
- name: Prepare build artifacts [-nix]
|
||||
if: matrix.os != 'windows-latest'
|
||||
run: |
|
||||
cd target/${{ matrix.target }}/release
|
||||
strip starship
|
||||
tar czvf ../../../${{ matrix.name }} starship
|
||||
cd -
|
||||
|
||||
- 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:
|
||||
- uses: actions/checkout@v2
|
||||
|
||||
# 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: .
|
||||
|
||||
- name: Generate checksums
|
||||
run: for file in starship-*; do openssl dgst -sha256 -r "$file" | awk '{print $1}' > "${file}.sha256"; done
|
||||
|
||||
- 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
|
||||
git-chglog -c .github/chglog/release.yml $(git describe --tags) > RELEASE.md
|
||||
|
||||
- name: Create GitHub release ${{ matrix.target }}
|
||||
uses: softprops/action-gh-release@v1
|
||||
with:
|
||||
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
|
||||
body_path: RELEASE.md
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
- name: Build | Test
|
||||
run: cargo test -- -Z unstable-options --include-ignored
|
||||
|
Loading…
Reference in New Issue
Block a user