Skip to content
🎉 GoReleaser v2.18 is out! with release summaries, preflight checks, OpenTelemetry traces, and more!

Azure Pipelines

GoReleaser can be used within the official GoReleaser Extensions for Azure DevOps through the Visual Studio Marketplace.

Task definition

- task: goreleaser@0
  inputs:
    version: "latest"
    distribution: "goreleaser"
    args: ""
    workdir: "$(Build.SourcesDirectory)"

Task inputs

The following inputs can be used:

NameTypeDefaultDescription
distributionStringgoreleaserGoReleaser distribution, either goreleaser or goreleaser-pro
version1StringlatestGoReleaser version
argsStringArguments to pass to GoReleaser
workdirString$(Build.SourcesDirectory)Working directory (below repository root)
installOnlyBoolfalseJust install GoReleaser

Task environment variables

Define the variable in the pipeline:

variables:
  - name: GORELEASER_KEY
    value: xxx

Or, in short form:

variables:
  GORELEASER_KEY: xxx

The following environment variables can be used:

NameDescription
GITHUB_TOKENGITHUB_TOKEN for e.g. brew
GORELEASER_KEYYour GoReleaser Pro License Key, in case you are using the goreleaser-pro distribution

Example pipeline

Generally there are two ways to define an Azure Pipeline: Classic pipelines defined in the UI or YAML pipelines.

Here is how to do it with YAML:

# customize trigger to your needs
trigger:
  branches:
    include:
      - main
      - refs/tags/*

variables:
  GO_VERSION: "1.27"

pool:
  vmImage: ubuntu-latest

jobs:
  - job: Test
    steps:
      - task: GoTool@0
        inputs:
          version: "$(GO_VERSION)"
        displayName: Install Go

      - bash: go test ./...
        displayName: Run Go Tests

  - job: Release
    # only runs if Test was successful
    dependsOn: Test
    # only runs if pipeline was triggered from a branch.
    condition: and(succeeded(), startsWith(variables['Build.SourceBranch'], 'refs/tags'))
    steps:
      - task: GoTool@0
        inputs:
          version: "$(GO_VERSION)"
        displayName: Install Go

      - task: goreleaser@0
        inputs:
          version: "latest"
          distribution: "goreleaser"
          args: ""
          workdir: "$(Build.SourcesDirectory)"

In this example a Test job is used to run go test ./... to first make sure that there are no failing tests. Only if that job succeeds and the pipeline was triggered from a tag (because of the defined condition) GoReleaser will be run.


  1. Can be a fixed version like v1.10.0 or a max satisfying semver one like ~> v1.10. In this case this will return the latest patch release of v1.10. For the pro version, add -pro to the string ↩︎

Last updated on