1
0
mirror of https://github.com/goreleaser/goreleaser.git synced 2025-03-11 14:39:28 +02:00

docs: improve docs (#5006)

closes https://github.com/orgs/goreleaser/discussions/5004

---------

Signed-off-by: Carlos Alexandro Becker <caarlos0@users.noreply.github.com>
This commit is contained in:
Carlos Alexandro Becker 2024-07-17 10:56:36 -03:00 committed by GitHub
parent 1c3f3a1aa2
commit 6b645926a8
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
64 changed files with 162 additions and 102 deletions

View File

@ -10,7 +10,7 @@ pip install -U mkdocs-material mkdocs-redirects mkdocs-minify-plugin mkdocs-incl
# prepare
version="$(cat ./www/docs/static/latest)"
sed -s'' -i "s/__VERSION__/$version/g" www/docs/install.md
sed -s'' -i "s/__VERSION__/$version/g" www/docs/install.md www/docs/customization/index.md
# build
mkdocs build -f www/mkdocs.yml

View File

@ -5,7 +5,7 @@ private monorepo, but publish its binaries to a public repository.
This cookbook gives some suggestions on how to handle that.
{% include-markdown "../includes/pro.md" comments=false %}
<!-- md:pro -->
Usually, you'll rely on tag prefixes for each sub-project within your monorepo.
GoReleaser can handle that within its [monorepo configuration][Monorepo]:

View File

@ -26,4 +26,4 @@ announce:
username: "my-project.bsky.social"
```
{% include-markdown "../../includes/templates.md" comments=false %}
<!-- md:templates -->

View File

@ -38,4 +38,4 @@ announce:
icon_url: ""
```
{% include-markdown "../../includes/templates.md" comments=false %}
<!-- md:templates -->

View File

@ -23,4 +23,4 @@ announce:
message_template: "Awesome project {{.Tag}} is out!"
```
{% include-markdown "../../includes/templates.md" comments=false %}
<!-- md:templates -->

View File

@ -28,4 +28,4 @@ announce:
server: https://mastodon.social
```
{% include-markdown "../../includes/templates.md" comments=false %}
<!-- md:templates -->

View File

@ -43,4 +43,4 @@ announce:
icon_url: ""
```
{% include-markdown "../../includes/templates.md" comments=false %}
<!-- md:templates -->

View File

@ -30,4 +30,4 @@ announce:
message_template: "Awesome project {{.Tag}} is out!"
```
{% include-markdown "../../includes/templates.md" comments=false %}
<!-- md:templates -->

View File

@ -34,4 +34,4 @@ announce:
title_template: ''GoReleaser {{ .Tag }} was just released!''
```
{% include-markdown "../../includes/templates.md" comments=false %}
<!-- md:templates -->

View File

@ -50,4 +50,4 @@ announce:
attachments: []
```
{% include-markdown "../../includes/templates.md" comments=false %}
<!-- md:templates -->

View File

@ -49,4 +49,4 @@ announce:
subject_template: "GoReleaser {{ .Tag }} was just released!"
```
{% include-markdown "../../includes/templates.md" comments=false %}
<!-- md:templates -->

View File

@ -38,4 +38,4 @@ announce:
icon_url: ""
```
{% include-markdown "../../includes/templates.md" comments=false %}
<!-- md:templates -->

View File

@ -40,4 +40,4 @@ announce:
You can format your message using `MarkdownV2`, for reference, see the
[Telegram Bot API](https://core.telegram.org/bots/api#markdownv2-style).
{% include-markdown "../../includes/templates.md" comments=false %}
<!-- md:templates -->

View File

@ -30,4 +30,4 @@ announce:
message_template: "Awesome project {{.Tag}} is out!"
```
{% include-markdown "../../includes/templates.md" comments=false %}
<!-- md:templates -->

View File

@ -42,4 +42,4 @@ announce:
User-Agent: "goreleaser"
```
{% include-markdown "../../includes/templates.md" comments=false %}
<!-- md:templates -->

View File

@ -188,9 +188,9 @@ archives:
allow_different_binary_count: true
```
{% include-markdown "../includes/pro.md" comments=false %}
<!-- md:pro -->
{% include-markdown "../includes/templates.md" comments=false %}
<!-- md:templates -->
!!! tip

View File

@ -237,9 +237,9 @@ artifactories:
extra_files_only: true
```
{% include-markdown "../includes/pro.md" comments=false %}
<!-- md:pro -->
These settings should allow you to push your artifacts into multiple
**Artifactory** instances.
{% include-markdown "../includes/templates.md" comments=false %}
<!-- md:templates -->

View File

@ -166,7 +166,7 @@ aurs:
directory: "."
```
{% include-markdown "../includes/templates.md" comments=false %}
<!-- md:templates -->
!!! tip

View File

@ -1,8 +1,8 @@
# Before Publish Hooks
> Since v2.1 (Pro).
<!-- md:version v2.1 -->
{% include-markdown "../includes/pro.md" comments=false %}
<!-- md:pro -->
You can use the `before_publish` hooks to run command against artifacts before
the publishing step kicks in.
@ -64,4 +64,4 @@ before_publish:
- "FILE_TO_TOUCH=something-{{ .ProjectName }}" # specify hook level environment variables
```
{% include-markdown "../includes/templates.md" comments=false %}
<!-- md:templates -->

View File

@ -129,7 +129,7 @@ blobs:
extra_files_only: true
```
{% include-markdown "../includes/templates.md" comments=false %}
<!-- md:templates -->
## Authentication

View File

@ -255,7 +255,7 @@ builds:
You usually will need to specify the `goamd64` version beign used, e.g., in
`overrides`, and other places too.
{% include-markdown "../includes/templates.md" comments=false %}
<!-- md:templates -->
!!! info
@ -438,7 +438,7 @@ GoReleaser:
## Import pre-built binaries
{% include-markdown "../includes/pro.md" comments=false %}
<!-- md:pro -->
It is also possible to import pre-built binaries into the GoReleaser lifecycle.

View File

@ -72,4 +72,4 @@ checksum:
dst: LICENSE.txt
```
{% include-markdown "../includes/templates.md" comments=false %}
<!-- md:templates -->

View File

@ -134,7 +134,7 @@ chocolateys:
goamd64: v1
```
{% include-markdown "../includes/templates.md" comments=false %}
<!-- md:templates -->
!!! note

View File

@ -1,8 +1,8 @@
# Cloudsmith - apt, rpm, and alpine repositories
> Since v2.1 (Pro).
<!-- md:version v2.1 -->
{% include-markdown "../includes/pro.md" comments=false %}
<!-- md:pro -->
You can easily create `deb`, `alpine`, and `yum` repositories on
[Cloudsmith][cloudsmith] using GoReleaser.
@ -17,7 +17,7 @@ as an environment variable named `CLOUDSMITH_TOKEN`:
```yaml
# .goreleaser.yaml
furies:
cloudsmiths:
- organization: myorg
repository: myrepo
distributions:
@ -83,4 +83,4 @@ cloudsmiths:
[cloudsmith]: https://cloudsmith.io/
{% include-markdown "../includes/templates.md" comments=false %}
<!-- md:templates -->

View File

@ -1,6 +1,6 @@
# DMG
{% include-markdown "../includes/pro.md" comments=false %}
<!-- md:pro -->
GoReleaser can create DMG images for macOS using `mkisofs` or `hdiutil`.
@ -56,4 +56,4 @@ dmg:
link inside the image might not work if the image was built on Windows.
1. If running outside macOS, make sure to have `mkisofs` installed.
{% include-markdown "../includes/templates.md" comments=false %}
<!-- md:templates -->

View File

@ -19,7 +19,7 @@ dockers:
- user/repo
```
{% include-markdown "../includes/templates.md" comments=false %}
<!-- md:templates -->
You also need to create a `Dockerfile` in your project's root directory:
@ -196,7 +196,7 @@ dockers:
Note that you will have to manually login into the Docker registries you
want to push to — GoReleaser does not login by itself.
{% include-markdown "../includes/templates.md" comments=false %}
<!-- md:templates -->
!!! tip
@ -224,7 +224,7 @@ This will build and publish the following images:
- `myuser/foo`
{% include-markdown "../includes/templates.md" comments=false %}
<!-- md:templates -->
## Keeping docker images updated for current major
@ -252,7 +252,7 @@ This will build and publish the following images:
With these settings you can hopefully push several Docker images
with multiple tags.
{% include-markdown "../includes/templates.md" comments=false %}
<!-- md:templates -->
## Publishing to multiple docker registries
@ -305,7 +305,7 @@ docker build -t myuser/myimage . \
--label=org.opencontainers.image.version=1.6.4
```
{% include-markdown "../includes/templates.md" comments=false %}
<!-- md:templates -->
## Use a specific builder with Docker buildx
@ -330,7 +330,7 @@ dockers:
## Using Podman
{% include-markdown "../includes/pro.md" comments=false %}
<!-- md:pro -->
You can use [`podman`](https://podman.io) instead of `docker` by setting `use` to `podman` on your config:

View File

@ -74,7 +74,7 @@ docker_manifests:
use: docker
```
{% include-markdown "../includes/templates.md" comments=false %}
<!-- md:templates -->
## How it works
@ -145,7 +145,7 @@ and push everything to Docker Hub.
## Using Podman
{% include-markdown "../includes/pro.md" comments=false %}
<!-- md:pro -->
You can use [`podman`](https://podman.io) instead of `docker` by setting `use`
to `podman` on your configuration:

View File

@ -1,6 +1,6 @@
# DockerHub
{% include-markdown "../includes/pro.md" comments=false %}
<!-- md:pro -->
DockerHub allows you to set an image description and a full description.
However, this is not possible via `docker push`.
@ -66,4 +66,4 @@ dockerhub:
path: ./README.md
```
{% include-markdown "../includes/templates.md" comments=false %}
<!-- md:templates -->

View File

@ -22,4 +22,4 @@ underlying builds (using `go build`) will have `FOO` set to `on`.
The root `env` section also accepts templates.
{% include-markdown "../includes/templates.md" comments=false %}
<!-- md:templates -->

View File

@ -1,6 +1,6 @@
# Fury - apt and rpm repositories
{% include-markdown "../includes/pro.md" comments=false %}
<!-- md:pro -->
You can easily create `deb` and `yum` repositories on [Fury][fury] using GoReleaser.
@ -60,4 +60,4 @@ furies:
[fury]: https://gemfury.com
{% include-markdown "../includes/templates.md" comments=false %}
<!-- md:templates -->

View File

@ -49,4 +49,4 @@ to oldest, so the latest tag is returned.
This has the effect of sorting non-pre-release tags before pre-release ones,
which is different from what other git sorting options might give you.
{% include-markdown "../includes/pro.md" comments=false %}
<!-- md:pro -->

View File

@ -191,10 +191,10 @@ brews:
etc.install "app-config.conf"
# ...
{% include-markdown "../includes/repository.md" comments=false %}
{% include-markdown "../includes/repository.md" comments=false start='---\n\n' %}
```
{% include-markdown "../includes/templates.md" comments=false %}
<!-- md:templates -->
By defining the `brew` section, GoReleaser will take care of publishing the
Homebrew tap.
@ -262,7 +262,7 @@ Our suggestion is to create a `my-app-head.rb` file on your tap following
## Versioned formulas
{% include-markdown "../includes/pro.md" comments=false %}
<!-- md:pro -->
GoReleaser can also create a versioned formula.
For instance, you might want to make keep previous minor versions available to
@ -296,4 +296,4 @@ You can check the [resource not accessible by integration](https://goreleaser.co
- Only one `GOARM` build is allowed;
{% include-markdown "../includes/prs.md" comments=false %}
{% include-markdown "../includes/prs.md" comments=false start='---\n\n' %}

View File

@ -25,7 +25,7 @@ GoReleaser allows this with the global hooks feature.
=== "Pro"
{% include-markdown "../includes/pro.md" comments=false %}
<!-- md:pro -->
The `before` section allows for global hooks that will be executed
**before** the release is started. Likewise, the `after` section allows for
@ -74,4 +74,4 @@ If you need to do anything more complex, it is recommended to create a shell
script and call it instead. You can also go crazy with `sh -c "my commands"`,
but it gets ugly really fast.
{% include-markdown "../includes/templates.md" comments=false %}
<!-- md:templates -->

View File

@ -1,6 +1,6 @@
# Includes
{% include-markdown "../includes/pro.md" comments=false %}
<!-- md:pro -->
GoReleaser allows you to reuse configuration files by including them from either
a URL or a file path.

View File

@ -1,4 +1,4 @@
# Customization
# Introduction
GoReleaser can be customized by tweaking a `.goreleaser.yaml` file.
@ -44,18 +44,18 @@ You can also generate it for your specific version using the
### Pin the schema version
You can pin the version by getting the schema from the GitHub tag, for example,
for v1.12.0:
for `__VERSION__` (latest):
=== "OSS"
```sh
https://raw.githubusercontent.com/goreleaser/goreleaser/v1.12.0/www/docs/static/schema.json
https://raw.githubusercontent.com/goreleaser/goreleaser/__VERSION__/www/docs/static/schema.json
```
=== "Pro"
```sh
https://raw.githubusercontent.com/goreleaser/goreleaser/v1.12.0/www/docs/static/schema-pro.json
https://raw.githubusercontent.com/goreleaser/goreleaser/__VERSION__/www/docs/static/schema-pro.json
```
[jsonschema]: http://json-schema.org/draft/2020-12/json-schema-validation.html

View File

@ -86,10 +86,10 @@ krews:
# in case there is an indicator for prerelease in the tag e.g. v1.0.0-rc1
skip_upload: true
{% include-markdown "../includes/repository.md" comments=false %}
{% include-markdown "../includes/repository.md" comments=false start='---\n\n' %}
```
{% include-markdown "../includes/templates.md" comments=false %}
<!-- md:templates -->
## Limitations
@ -97,4 +97,4 @@ krews:
- Binary releases (when `archives.format` is set to `binary`) are not allowed;
- Only one `GOARM` build is allowed;
{% include-markdown "../includes/prs.md" comments=false %}
{% include-markdown "../includes/prs.md" comments=false start='---\n\n' %}

View File

@ -67,4 +67,4 @@ metadata:
path: ./README.md
```
{% include-markdown "../includes/templates.md" comments=false %}
<!-- md:templates -->

View File

@ -28,4 +28,4 @@ milestones:
name_template: "Current Release"
```
{% include-markdown "../includes/templates.md" comments=false %}
<!-- md:templates -->

View File

@ -1,6 +1,6 @@
# Monorepo
{% include-markdown "../includes/pro.md" comments=false %}
<!-- md:pro -->
If you want to use GoReleaser within a monorepo and use tag prefixes to mark
"which tags belong to which sub project", GoReleaser has you covered.

View File

@ -1,6 +1,6 @@
# MSI
{% include-markdown "../includes/pro.md" comments=false %}
<!-- md:pro -->
GoReleaser can create MSI installers for windows binaries using [msitools][].
@ -131,7 +131,7 @@ Here's an example `wsx` file that you can build upon:
[msitools][], run a snapshot build and verify the generated installers.
1. Only `amd64` and `386` are supported.
{% include-markdown "../includes/templates.md" comments=false %}
<!-- md:templates -->
[msitools]: https://wiki.gnome.org/msitools
[wix]: https://wixtoolset.org

View File

@ -518,7 +518,7 @@ nfpms:
- foo
```
{% include-markdown "../includes/templates.md" comments=false %}
<!-- md:templates -->
!!! info

View File

@ -1,6 +1,6 @@
# Nightlies
{% include-markdown "../includes/pro.md" comments=false %}
<!-- md:pro -->
Whether if you need beta builds or a rolling-release system, the nightly builds
feature will do it for you.
@ -41,7 +41,7 @@ When you run GoReleaser with `--nightly`, it will set the `Version` template
variable to the evaluation of `nightly.name_template`. This means that if you
use `{{ .Version }}` on your name templates, you'll get the nightly version.
{% include-markdown "../includes/templates.md" comments=false %}
<!-- md:templates -->
## What is skipped when using `--nightly`?

View File

@ -109,10 +109,10 @@ nix:
post_install: |
installShellCompletion ./completions/*
{% include-markdown "../includes/repository.md" comments=false %}
{% include-markdown "../includes/repository.md" comments=false start='---\n\n' %}
```
{% include-markdown "../includes/templates.md" comments=false %}
<!-- md:templates -->
## Things not supported
@ -156,4 +156,4 @@ That's it!
[nur]: https://github.com/nix-community/NUR
{% include-markdown "../includes/prs.md" comments=false %}
{% include-markdown "../includes/prs.md" comments=false start='---\n\n' %}

View File

@ -73,7 +73,7 @@ notarize:
timeout: 20m
```
{% include-markdown "../includes/templates.md" comments=false %}
<!-- md:templates -->
!!! tip "base64"
@ -86,7 +86,7 @@ notarize:
## Signing only
> Since v2.1.
<!-- md:version v2.1 -->
If you want to only sign the binaries, but not notarize them, you can simply
leave the `notarize` section of your configuration empty.

View File

@ -2,7 +2,7 @@
GoReleaser can also split and merge builds.
{% include-markdown "../includes/pro.md" comments=false %}
<!-- md:pro -->
This feature can help in some areas:

View File

@ -156,4 +156,4 @@ These settings should allow you to push your artifacts to any number of
endpoints, which may require non-trivial authentication or has otherwise complex
requirements.
{% include-markdown "../includes/templates.md" comments=false %}
<!-- md:templates -->

View File

@ -203,7 +203,7 @@ release:
[Learn how to set up an API token, GitHub Enterprise, etc](../scm/github.md).
{% include-markdown "../includes/pro.md" comments=false %}
<!-- md:pro -->
## GitLab
@ -332,7 +332,7 @@ ALLOWED_TYPES = application/gzip|application/x-gzip|application/x-gtar|applicati
[Learn how to set up an API token](../scm/gitea.md).
{% include-markdown "../includes/templates.md" comments=false %}
<!-- md:templates -->
!!! warning

View File

@ -101,10 +101,10 @@ scoops:
# Default: 'v1'.
goamd64: v3
{% include-markdown "../includes/repository.md" comments=false %}
{% include-markdown "../includes/repository.md" comments=false start='---\n\n' %}
```
{% include-markdown "../includes/templates.md" comments=false %}
<!-- md:templates -->
By defining the `scoop` section, GoReleaser will take care of publishing the
Scoop app. Assuming that the project name is `drumroll`, and the current tag is
@ -141,4 +141,4 @@ You can check the
[Scoop documentation](https://github.com/lukesampson/scoop/wiki) for more
details.
{% include-markdown "../includes/prs.md" comments=false %}
{% include-markdown "../includes/prs.md" comments=false start='---\n\n' %}

View File

@ -321,7 +321,7 @@ snapcrafts:
- $HOME/.foobar
```
{% include-markdown "../includes/templates.md" comments=false %}
<!-- md:templates -->
!!! note

View File

@ -31,7 +31,7 @@ You can also check if it's a snapshot build inside a template with:
{{ if .IsSnapshot }}something{{ else }}something else{{ end }}
```
{% include-markdown "../includes/templates.md" comments=false %}
<!-- md:templates -->
Note that the idea behind GoReleaser's snapshots is for local builds or to
validate your build on the CI pipeline. Artifacts won't be uploaded and will

View File

@ -78,4 +78,4 @@ source:
mtime: 2008-01-02T15:04:05Z
```
{% include-markdown "../includes/templates.md" comments=false %}
<!-- md:templates -->

View File

@ -1,6 +1,6 @@
# Template Files
{% include-markdown "../includes/pro.md" comments=false %}
<!-- md:pro -->
Template Files allow you to create custom files and/or scripts using
GoReleaser's internal state and template variables, for example, an installer
@ -35,4 +35,4 @@ template_files:
mode: 0755
```
{% include-markdown "../includes/templates.md" comments=false %}
<!-- md:templates -->

View File

@ -94,7 +94,7 @@ You should be able to use all its fields on each item:
- `.Type`
- `.Extra`
{% include-markdown "../includes/pro.md" comments=false %}
<!-- md:pro -->
## Single-artifact extra fields
@ -193,7 +193,7 @@ GOVERSION_NR=$(go version | awk '{print $3;}') goreleaser
## Custom variables
{% include-markdown "../includes/pro.md" comments=false %}
<!-- md:pro -->
You can also declare custom variables. This feature is specially useful with
[includes](includes.md), so you can have more generic configuration

View File

@ -53,7 +53,7 @@ universal_binaries:
post: ./script.sh {{ .Path }}
```
{% include-markdown "../includes/templates.md" comments=false %}
<!-- md:templates -->
For more info about hooks, see the [build section](./builds.md#build-hooks).

View File

@ -264,9 +264,9 @@ uploads:
extra_files_only: true
```
{% include-markdown "../includes/pro.md" comments=false %}
<!-- md:pro -->
These settings should allow you to push your artifacts into multiple HTTP
servers.
{% include-markdown "../includes/templates.md" comments=false %}
<!-- md:templates -->

View File

@ -59,7 +59,7 @@ Notice you can define multiple `upx` definitions, filtering by various fields.
You can use that to have different compression options depending on the target
OS, for instance - or even to run it only on a few selected platforms.
{% include-markdown "../includes/templates.md" comments=false %}
<!-- md:templates -->
[upx]: https://upx.github.io/
[upx-issues]: https://github.com/upx/upx/issues

View File

@ -165,9 +165,9 @@ winget:
minimum_version: 1.2.3
{% include-markdown "../includes/repository.md" comments=false %}
{% include-markdown "../includes/repository.md" comments=false start='---\n\n' %}
```
{% include-markdown "../includes/templates.md" comments=false %}
<!-- md:templates -->
{% include-markdown "../includes/prs.md" comments=false %}
{% include-markdown "../includes/prs.md" comments=false start='---\n\n' %}

View File

@ -1,3 +0,0 @@
!!! success "GoReleaser Pro"
One or more features are available only with [GoReleaser Pro](../pro.md).

View File

@ -1,3 +1,8 @@
---
search:
exclude: true
---
## Pull Requests
GoReleaser allows you to, instead of pushing directly to the main branch, push

View File

@ -1,3 +1,8 @@
---
search:
exclude: true
---
# Repository to push the generated files to.
repository:
# Repository owner.

View File

@ -1,3 +0,0 @@
!!! tip
Learn more about the [name template engine](templates.md).

View File

@ -0,0 +1,48 @@
from __future__ import annotations
import posixpath
import re
from mkdocs.config.defaults import MkDocsConfig
from mkdocs.structure.files import File, Files
from mkdocs.structure.pages import Page
from re import Match
# very much stolen/based on https://github.com/squidfunk/mkdocs-material/blob/master/src/overrides/hooks/shortcodes.py
def on_page_markdown(markdown: str, *, page: Page, config: MkDocsConfig, files: Files):
# Replace callback
def replace(match: Match):
type, args = match.groups()
args = args.strip()
if type == "version": return _version_block(args)
elif type == "pro": return _pro_ad(page, files)
elif type == "templates": return _templates_ad()
# Otherwise, raise an error
raise RuntimeError(f"Unknown shortcode: {type}")
# Find and replace all external asset URLs in current page
return re.sub(
r"<!-- md:(\w+)(.*?) -->",
replace, markdown, flags = re.I | re.M
)
def _pro_ad(page: Page, files: Files):
return "".join([
f"<div class=\"admonition example\">",
f"<p class=\"admonition-title\">GoReleaser Pro</p>",
f"<p>One or more features are available only with <a href=\"/pro/\">GoReleaser Pro</a>.</p>",
f"</div>"
])
def _version_block(text: str):
return f"> Since :material-tag-outline: <a href=\"/blog/goreleaser-{text}\">{text}</a>."
def _templates_ad():
return "".join([
f"<div class=\"admonition tip\">",
f"<p class=\"admonition-title\">Tip</p>",
f"<p>Learn more about the <a href=\"/customization/templates/\">name template engine</a>.</p>",
f"</div>"
])

View File

@ -5,6 +5,8 @@ copyright: Made with ❤️ by GoReleaser contributors.
repo_name: goreleaser/goreleaser
repo_url: https://github.com/goreleaser/goreleaser
edit_uri: edit/main/www/docs/
hooks:
- docs/overrides/hooks/shortcodes.py
theme:
name: material
@ -14,6 +16,9 @@ theme:
favicon: static/favicon.ico
include_search_page: false
search_index_only: true
icon:
admonition:
example: material/professional-hexagon
palette:
- media: "(prefers-color-scheme: light)" # Light mode
scheme: default
@ -255,3 +260,6 @@ markdown_extensions:
- pymdownx.tasklist:
custom_checkbox: true
- footnotes
- pymdownx.emoji:
emoji_index: !!python/name:material.extensions.emoji.twemoji
emoji_generator: !!python/name:material.extensions.emoji.to_svg