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,7 +4,9 @@ trigger:
tags:
include: ["*"]
jobs:
stages:
- stage: Checks
jobs:
# Check formatting
- template: ci/rustfmt.yml
parameters:
@ -23,15 +25,12 @@ jobs:
name: cargo_check
displayName: Cargo check
##############
# Test stage #
##############
- stage: Test
dependsOn: Checks
jobs:
# Test stable
- template: ci/test.yml
parameters:
dependsOn:
- cargo_check
name: cargo_test_stable
displayName: Cargo test
cross: true # Test on Windows and macOS
@ -50,22 +49,17 @@ jobs:
name: test_docker
displayName: Docker test
################
# Release stage #
################
# Release binary
- 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
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
@ -81,3 +75,9 @@ jobs:
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::*;