typos/azure-pipelines.yml
2021-07-01 19:32:36 -05:00

149 lines
4.8 KiB
YAML

trigger:
branches:
include: ['master']
tags:
include: ['v*']
pr:
branches:
include:
- master
paths:
exclude:
- "*.md"
- "docs/*"
- "LICENSE-*"
schedules:
- cron: "3 3 3 * *"
displayName: Monthly Build
branches:
include:
- master
variables:
windows_vm: windows-latest
mac_vm: macOS-latest
linux_vm: ubuntu-latest
stages:
- stage: style
displayName: Style checks
dependsOn: []
jobs:
- job: "Committed"
displayName: Linting commit history
pool:
vmImage: ${{ variables.linux_vm }}
steps:
- checkout: self
- template: v1/azdo-step.yml@gh-install
parameters:
git: crate-ci/committed
target: 'x86_64-unknown-linux-gnu'
to: $(Build.StagingDirectory)/tools
- script: |
echo "Linting commits:"
git log --graph --oneline HEAD~..HEAD^2
echo "Against 'committed.toml':"
$(Build.StagingDirectory)/tools/committed --dump-config -
echo ""
echo "If this fails, don't sweat it. We're trying to encourage clear communication and not hinder contributions."
echo "If it is a reasonable issue and you lack time or feel uncomfortable fixing it yourself,"
echo "let us know and we can mentor or fix it."
$(Build.StagingDirectory)/tools/committed HEAD~..HEAD^2 --no-merge-commit -vv
displayName: Lint commit history
condition: and(succeeded(), eq(variables['Build.Reason'], 'PullRequest'))
- stage: release
displayName: Release
dependsOn: []
condition: startsWith(variables['Build.SourceBranch'], 'refs/tags/')
jobs:
- job:
strategy:
matrix:
windows:
imageName: ${{ variables.windows_vm }}
target: 'x86_64-pc-windows-msvc'
crate_name: typos
mac:
imageName: ${{ variables.mac_vm }}
target: 'x86_64-apple-darwin'
crate_name: typos
linux:
imageName: ${{ variables.linux_vm }}
target: 'x86_64-unknown-linux-gnu'
crate_name: typos
pool:
vmImage: $(imageName)
steps:
- template: install-rust.yml@templates
parameters:
rust: stable
targets: ["$(TARGET)"]
- script: |
cargo build --target $(TARGET) --release --bin $(CRATE_NAME)
displayName: Build
- task: CopyFiles@2
displayName: Stage assets
condition: ne( variables['Agent.OS'], 'Windows_NT' )
inputs:
sourceFolder: '$(Build.SourcesDirectory)/target/$(TARGET)/release'
contents: $(crate_name)
targetFolder: '$(Build.BinariesDirectory)/'
- task: CopyFiles@2
displayName: Stage assets on Windows
condition: eq( variables['Agent.OS'], 'Windows_NT' )
inputs:
sourceFolder: '$(Build.SourcesDirectory)/target/$(TARGET)/release'
contents: $(crate_name).exe
targetFolder: '$(Build.BinariesDirectory)/'
- task: ArchiveFiles@2
displayName: Tarball assets
condition: ne( variables['Agent.OS'], 'Windows_NT' )
inputs:
rootFolderOrFile: '$(Build.BinariesDirectory)/$(crate_name)'
archiveType: 'tar'
tarCompression: 'gz'
archiveFile: '$(Build.ArtifactStagingDirectory)/$(crate_name)-$(Build.SourceBranchName)-$(TARGET).tar.gz'
- task: GithubRelease@0
condition: ne( variables['Agent.OS'], 'Windows_NT' )
inputs:
gitHubConnection: 'crate-ci-token'
repositoryName: 'crate-ci/typos'
action: 'edit'
target: '$(build.sourceVersion)'
tagSource: 'manual'
tag: '$(Build.SourceBranchName)'
assets: '$(Build.ArtifactStagingDirectory)/$(crate_name)-$(Build.SourceBranchName)-$(TARGET).tar.gz'
title: '$(Build.SourceBranchName)'
assetUploadMode: 'replace'
addChangeLog: true
- task: ArchiveFiles@2
displayName: Zip assets
condition: eq( variables['Agent.OS'], 'Windows_NT' )
inputs:
rootFolderOrFile: '$(Build.BinariesDirectory)/$(crate_name).exe'
archiveType: 'zip'
archiveFile: '$(Build.ArtifactStagingDirectory)/$(crate_name)-$(Build.SourceBranchName)-$(TARGET).zip'
- task: GithubRelease@0
condition: eq( variables['Agent.OS'], 'Windows_NT' )
inputs:
gitHubConnection: 'crate-ci-token'
repositoryName: 'crate-ci/typos'
action: 'edit'
target: '$(build.sourceVersion)'
tagSource: 'manual'
tag: '$(Build.SourceBranchName)'
assets: '$(Build.ArtifactStagingDirectory)/$(crate_name)-$(Build.SourceBranchName)-$(TARGET).zip'
title: '$(Build.SourceBranchName)'
assetUploadMode: 'replace'
addChangeLog: true
resources:
repositories:
- repository: templates
type: github
name: crate-ci/azure-pipelines
endpoint: crate-ci
- repository: gh-install
type: github
name: crate-ci/gh-install
endpoint: crate-ci