Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: support templates for scm urls #2465

Merged

Conversation

stevexuereb
Copy link
Contributor

@stevexuereb stevexuereb commented Sep 7, 2021

Thank you for this really well polished project and the hard work put into it 🙌

Background

When a git repository is hosted in multiple GitLab instances the
.goreleaser.yml needs to take in consideration both APIs endpoints. At
the moment it defaults to GitLab.com and you can override it with
gitlab_urls however this forces you to only support 1 GitLab instance.

We need this for
https://gitlab.com/gitlab-com/gl-infra/infrastructure/-/issues/14122
where we have a tool that is developed on GitLab.com but then mirrored
to an internal GitLab instance since we need it to operate GitLab.com
even when it's down.

Solution

Support templates like {{ .Env.CI_SERVER_URL }} for the
gitlab_urls, github_urls and gitea_urls so it can use environment
variables and the same .goreleaser file can be used in multiple SCM
instances.

@pull-request-size pull-request-size bot added the size/L Denotes a PR that changes 100-499 lines, ignoring generated files. label Sep 7, 2021
@vercel
Copy link

vercel bot commented Sep 7, 2021

@steveazz is attempting to deploy a commit to the goreleaser Team on Vercel.

A member of the Team first needs to authorize it.

@caarlos0
Copy link
Member

caarlos0 commented Sep 7, 2021

Hey!

Thanks for the kind word and for the PR.

Can you do the same for github and gitea? (just so we have feature parity)

Would also be neat to add a note the docs saying its templateable, but I can do that later if you like

Thanks!

@codecov
Copy link

codecov bot commented Sep 7, 2021

Codecov Report

Merging #2465 (5990348) into master (717051d) will increase coverage by 0.84%.
The diff coverage is 98.43%.

❗ Current head 5990348 differs from pull request most recent head 5ce6521. Consider uploading reports for the commit 5ce6521 to get more accurate results
Impacted file tree graph

@@            Coverage Diff             @@
##           master    #2465      +/-   ##
==========================================
+ Coverage   83.02%   83.87%   +0.84%     
==========================================
  Files          87       87              
  Lines        6275     6318      +43     
==========================================
+ Hits         5210     5299      +89     
+ Misses        915      866      -49     
- Partials      150      153       +3     
Impacted Files Coverage Δ
internal/client/gitlab.go 26.03% <93.33%> (+17.50%) ⬆️
internal/client/gitea.go 87.93% <100.00%> (+0.50%) ⬆️
internal/client/github.go 32.68% <100.00%> (+8.09%) ⬆️
internal/pipe/defaults/defaults.go 100.00% <100.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 717051d...5ce6521. Read the comment docs.

@stevexuereb stevexuereb marked this pull request as draft September 7, 2021 20:02
@pull-request-size pull-request-size bot added size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. and removed size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Sep 8, 2021
You can use GoReleaser with GitLab Enterprise by providing its URLs in
the `.goreleaser.yml` configuration file:
You can use GoReleaser with GitLab Enterprise by providing its URLs in the
`.goreleaser.yml` configuration file. This takes a normal string or a template value.

```yaml
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thought: Not sure if we want to give a commented example here that it can support templates as well like below

# .goreleaser.yml
gitlab_urls:
  # api: "{{ .ENV. CI_API_V4_URL }}
  api: https://gitlab.mycompany.com/api/v4/
  download: https://gitlab.company.com
  # set to true if you use a self-signed certificate
  skip_tls_verify: false

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no need IMHO, docs are clear enough 🙏

Background
---
When a git repository is hosted in multiple GitLab instances the
`.goreleaser.yml` needs to take in consideration both APIs endpoints. At
the moment it defaults to GitLab.com and you can override it with
`gitlab_urls` however this forces you to only support 1 GitLab instance.

We need this for
https://gitlab.com/gitlab-com/gl-infra/infrastructure/-/issues/14122
where we have a tool that is developed on GitLab.com but then mirrored
to an internal GitLab instance since we need it to operate GitLab.com
even when it's down.

Solution
---
Support templates like `{{ .Env.CI_SERVER_URL }}` for the
`gitlab_urls`, `github_urls`  and `gitea_urls` so it can use environment
variables and the same `.goreleaser` file can be used in multiple SCM
instances.
@stevexuereb stevexuereb changed the title feat: support templates for gitlab_urls config feat: support templates for scm urls Sep 8, 2021
@stevexuereb
Copy link
Contributor Author

@caarlos0 this should be ready for another round of review! Let me know what you think and I'm sorry it turned out to be a large PR 🙇

Copy link
Member

@caarlos0 caarlos0 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@caarlos0 caarlos0 marked this pull request as ready for review September 9, 2021 01:35
@caarlos0 caarlos0 enabled auto-merge (squash) September 9, 2021 01:38
@caarlos0 caarlos0 added this to In progress in Board via automation Sep 9, 2021
@caarlos0 caarlos0 merged commit 68ff8e9 into goreleaser:master Sep 9, 2021
Board automation moved this from In progress to Done Sep 9, 2021
@stevexuereb stevexuereb deleted the feat/templates-for-gitlab-urls branch September 9, 2021 12:30
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Sep 9, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
size/XL Denotes a PR that changes 500-999 lines, ignoring generated files.
Projects
No open projects
Board
Done
Development

Successfully merging this pull request may close these issues.

None yet

2 participants