github.com/goreleaser/goreleaser@v1.25.1/www/docs/ci/azurepipelines.md (about) 1 # Azure Pipelines 2 3 GoReleaser can also be used within our official [GoReleaser Extensions for Azure 4 DevOps][goreleaser-extension] through [Visual Studio marketplace][marketplace]. 5 6 ### Task definition 7 8 ````yaml 9 - task: goreleaser@0 10 inputs: 11 version: 'latest' 12 distribution: 'goreleaser' 13 args: '' 14 workdir: '$(Build.SourcesDirectory)' 15 ```` 16 17 ### Task inputs 18 19 Following inputs can be used: 20 21 <!-- to format the tables, use: https://tabletomarkdown.com/format-markdown-table/ --> 22 23 Name |Type |Default |Description 24 -------------------|------|---------------------------|---------------------------------------------------------------- 25 `distribution` |String|`goreleaser` |GoReleaser distribution, either `goreleaser` or `goreleaser-pro` 26 `version`[^version]|String|`latest` |GoReleaser version 27 `args` |String| |Arguments to pass to GoReleaser 28 `workdir` |String|`$(Build.SourcesDirectory)`|Working directory (below repository root) 29 `installOnly` |Bool |`false` |Just install GoReleaser 30 31 [^version]: Can be a fixed version like `v1.10.0` or a max satisfying semver one 32 like `~> v1.10`. In this case this will return the latest patch release of 33 `v1.10`. For the `pro` version, add `-pro` to the string 34 35 ### Task environment variables 36 37 ```yaml 38 ... 39 variables: 40 - name: GORELEASER_KEY 41 value: xxx 42 ... 43 44 or short: 45 46 ... 47 variables: 48 GORELEASER_KEY: xxx 49 ... 50 ``` 51 52 Following environment variables can be used, as environment variable. 53 54 Name |Description 55 ----------------|------------------------------------------------------------------------------------------------------------------------------------------ 56 `GITHUB_TOKEN` |[GITHUB_TOKEN](https://help.github.com/en/actions/configuring-and-managing-workflows/authenticating-with-the-github_token) for e.g. `brew` 57 `GORELEASER_KEY`|Your [GoReleaser Pro](https://goreleaser.com/pro) License Key, in case you are using the `goreleaser-pro` distribution 58 59 ### Example pipeline 60 61 Generally there are two ways to define an [Azure Pipeline](https://azure.microsoft.com/en-us/services/devops/pipelines/): 62 Classic pipelines defined in the UI or YAML pipelines. 63 64 Here is how to do it with YAML: 65 66 ```yaml 67 # customize trigger to your needs 68 trigger: 69 branches: 70 include: 71 - main 72 - refs/tags/* 73 74 variables: 75 GO_VERSION: "1.20" 76 77 pool: 78 vmImage: ubuntu-latest 79 80 jobs: 81 - job: Test 82 steps: 83 - task: GoTool@0 84 inputs: 85 version: "$(GO_VERSION)" 86 displayName: Install Go 87 88 - bash: go test ./... 89 displayName: Run Go Tests 90 91 - job: Release 92 # only runs if Test was successful 93 dependsOn: Test 94 # only runs if pipeline was triggered from a branch. 95 condition: and(succeeded(), startsWith(variables['Build.SourceBranch'], 'refs/tags')) 96 steps: 97 - task: GoTool@0 98 inputs: 99 version: "$(GO_VERSION)" 100 displayName: Install Go 101 102 - task: goreleaser@0 103 inputs: 104 version: 'latest' 105 distribution: 'goreleaser' 106 args: '' 107 workdir: '$(Build.SourcesDirectory)' 108 ``` 109 110 In this example a `Test` job is used to run `go test ./...` to first make sure that there're no failing tests. Only if 111 that job succeeds and the pipeline was triggered from a tag (because of the defined `condition`) GoReleaser will be run. 112 113 [goreleaser-extension]: https://marketplace.visualstudio.com/items?itemName=GoReleaser.goreleaser 114 [marketplace]: https://marketplace.visualstudio.com/azuredevops