ci: Publish crate to Crates.io with CI

This commit is contained in:
Matan Kushner 2019-07-31 19:27:35 -04:00
parent 9a2af45835
commit 616b50b4e3
5 changed files with 88 additions and 79 deletions

View File

@ -4,80 +4,80 @@ trigger:
tags:
include: ["*"]
jobs:
# Check formatting
- template: ci/rustfmt.yml
parameters:
name: rustfmt
displayName: Check formatting
stages:
- stage: Checks
jobs:
# Check formatting
- template: ci/rustfmt.yml
parameters:
name: rustfmt
displayName: Check formatting
# Run linter
- template: ci/cargo-clippy.yml
parameters:
name: cargo_clippy
displayName: Run linter
# Run linter
- template: ci/cargo-clippy.yml
parameters:
name: cargo_clippy
displayName: Run linter
# Cargo check
- template: ci/cargo-check.yml
parameters:
name: cargo_check
displayName: Cargo check
# Cargo check
- template: ci/cargo-check.yml
parameters:
name: cargo_check
displayName: Cargo check
- stage: Test
dependsOn: Checks
jobs:
# Test stable
- template: ci/test.yml
parameters:
name: cargo_test_stable
displayName: Cargo test
cross: true # Test on Windows and macOS
##############
# Test stage #
##############
# Test nightly
- template: ci/test.yml
parameters:
name: cargo_test_nightly
displayName: Cargo test
rust_version: nightly
# Test stable
- template: ci/test.yml
parameters:
dependsOn:
- cargo_check
name: cargo_test_stable
displayName: Cargo test
cross: true # Test on Windows and macOS
# Test docker
# Runs integration tests as a starship developer would run them locally
- template: ci/test-docker.yml
parameters:
name: test_docker
displayName: Docker test
# Test nightly
- template: ci/test.yml
parameters:
name: cargo_test_nightly
displayName: Cargo test
rust_version: nightly
- stage: Release
dependsOn:
- Checks
- Test
condition: and(succeeded(), startsWith(variables['Build.SourceBranch'], 'refs/tags/v'))
jobs:
# Release binary on GitHub
- template: ci/github-release.yml
parameters:
name: github_release
rust_version: stable
contents: |
*
!*.rlib
!*.d
!.*
targets:
- x86_64-unknown-linux-gnu
# Windows support temporarily disabled
# - x86_64-pc-windows-gnu
# - x86_64-pc-windows-msvc
- x86_64-apple-darwin
github:
gitHubConnection: StarshipRelease
repositoryName: starship/starship
isPreRelease: false
# Test docker
# Runs integration tests as a starship developer would run them locally
- template: ci/test-docker.yml
parameters:
name: test_docker
displayName: Docker test
################
# Release stage #
################
# Release binary
- template: ci/github-release.yml
parameters:
name: github_release
dependsOn:
- rustfmt
- cargo_check
- cargo_clippy
- cargo_test_stable
- test_docker
rust_version: stable
condition: and(succeeded(), startsWith(variables['Build.SourceBranch'], 'refs/tags/v'))
contents: |
*
!*.rlib
!*.d
!.*
targets:
- x86_64-unknown-linux-gnu
# Windows support temporarily disabled
# - x86_64-pc-windows-gnu
# - x86_64-pc-windows-msvc
- x86_64-apple-darwin
github:
gitHubConnection: StarshipRelease
repositoryName: starship/starship
isPreRelease: false
# Publish package to Crates.io
- template: ci/cargo-publish.yml
parameters:
name: cargo_publish
displayName: Publish to Crates.io

View File

@ -9,5 +9,5 @@ jobs:
steps:
- template: install-rust.yml
- script: cargo clippy --all
- script: cargo clippy -- -D warnings -D clippy::all -D clippy::nursery -D clippy::pedantic
displayName: Run clippy

15
ci/cargo-publish.yml Normal file
View File

@ -0,0 +1,15 @@
parameters:
rust_version: stable
jobs:
- job: ${{ parameters.name }}
displayName: ${{ parameters.displayName }}
pool:
vmImage: ubuntu-16.04
steps:
- template: install-rust.yml
- script: |
cargo login $(CARGO_TOKEN)
cargo publish
displayName: Publish package to Crates.io

View File

@ -3,15 +3,12 @@ parameters:
github:
isPreRelease: false
repositoryName: "$(Build.Repository.Name)"
dependsOn: []
displayName: "Release to GitHub"
archiveName: "$(Build.Repository.Name)"
jobs:
- job: ${{ parameters.name }}
condition: ${{ parameters.condition }}
displayName: ${{ parameters.displayName }}
dependsOn: ${{ parameters.dependsOn }}
pool:
vmImage: ubuntu-16.04
steps:
@ -63,9 +60,7 @@ jobs:
- ${{ each build_target in parameters.targets }}:
- ${{ if eq(build_target, 'x86_64-apple-darwin') }}:
- job: ${{ parameters.name }}_macOS
condition: ${{ parameters.condition }}
displayName: ${{ parameters.displayName }} (macOS)
dependsOn: ${{ parameters.dependsOn }}
pool:
vmImage: macOS-10.13
steps:
@ -114,9 +109,7 @@ jobs:
- ${{ if eq(build_target, 'x86_64-pc-windows-msvc') }}:
- job: ${{ parameters.name }}_msvc
condition: ${{ parameters.condition }}
displayName: ${{ parameters.displayName }} (Windows)
dependsOn: ${{ parameters.dependsOn }}
pool:
vmImage: vs2017-win2016
steps:

View File

@ -149,6 +149,7 @@ impl Config for Table {
}
}
mod tests {
use super::*;