Last active
February 20, 2022 17:37
-
-
Save dirien/8d3438ba88ce0004d66696bb37419d9c to your computer and use it in GitHub Desktop.
Azure DevOps and GoReleaser - III
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Starter pipeline | |
# Start with a minimal pipeline that you can customize to build and deploy your code. | |
# Add steps that build, run tests, deploy, and more: | |
# https://aka.ms/yaml | |
pr: | |
branches: | |
include: | |
- main | |
trigger: | |
tags: | |
include: | |
- '*' | |
branches: | |
include: | |
- '*' | |
jobs: | |
- job: build | |
pool: | |
vmImage: ubuntu-latest | |
steps: | |
- task: GoTool@0 | |
displayName: 'Install Go' | |
inputs: | |
version: '1.17' | |
- task: CmdLine@2 | |
displayName: 'Build and Test' | |
inputs: | |
script: | | |
go mod tidy | |
go build . | |
- job: release | |
dependsOn: build | |
displayName: Release via GoReleaser | |
condition: and(succeeded(), startsWith(variables['Build.SourceBranch'], 'refs/tags/')) | |
variables: | |
- group: cosign | |
pool: | |
vmImage: ubuntu-latest | |
steps: | |
- task: GoTool@0 | |
displayName: 'Install Go' | |
inputs: | |
version: '1.17' | |
- task: CmdLine@2 | |
displayName: 'Install Syft' | |
inputs: | |
script: | | |
curl -sSfL https://raw.githubusercontent.com/anchore/syft/main/install.sh | sh -s -- -b /usr/local/bin | |
- task: CmdLine@2 | |
displayName: 'Install cosign' | |
inputs: | |
script: | | |
curl -sLO https://github.com/sigstore/cosign/releases/download/v1.5.2/cosign-linux-amd64 | |
chmod +x cosign-linux-amd64 | |
mv cosign-linux-amd64 /usr/local/bin/cosign | |
- task: Docker@2 | |
inputs: | |
containerRegistry: 'dirien-docker-hub' | |
command: 'login' | |
addPipelineData: false | |
addBaseImageData: false | |
- task: goreleaser@0 | |
inputs: | |
version: 'latest' | |
distribution: 'goreleaser' | |
args: 'release --rm-dist' | |
- task: CopyFiles@2 | |
displayName: 'Copy GoReleaser dist folder to ArtifactStagingDirectory' | |
inputs: | |
Contents: | | |
dist/*.tar.gz | |
dist/*.zip | |
dist/*.txt | |
dist/*.sbom | |
dist/*.sig | |
cosign.pub | |
TargetFolder: '$(Build.ArtifactStagingDirectory)' | |
CleanTargetFolder: true | |
OverWrite: true | |
flattenFolders: true | |
- task: PublishBuildArtifacts@1 | |
displayName: 'Publish GoReleaser release artifacts' | |
inputs: | |
ArtifactName: 'GoReleaser release' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment