mirror of
https://github.com/goreleaser/goreleaser.git
synced 2025-01-10 03:47:03 +02:00
118 lines
3.8 KiB
Markdown
118 lines
3.8 KiB
Markdown
---
|
|
title: Artifactory
|
|
series: customization
|
|
hideFromIndex: true
|
|
weight: 120
|
|
---
|
|
|
|
Since [v0.38.0](https://github.com/goreleaser/goreleaser/releases/tag/v0.38.0),
|
|
GoReleaser supports building and pushing artifacts into Artifactory.
|
|
|
|
## How it works
|
|
|
|
You can declare multiple Artifactory instances.
|
|
All binaries generated by your `builds` section will be pushed to
|
|
each configured Artifactory.
|
|
|
|
If you have only one Artifactory instance,
|
|
the configuration is as easy as adding the
|
|
upload target and a username to your `.goreleaser.yml` file:
|
|
|
|
```yaml
|
|
artifactories:
|
|
- name: production
|
|
target: http://<Your-Instance>:8081/artifactory/example-repo-local/{{ .ProjectName }}/{{ .Version }}/
|
|
username: goreleaser
|
|
```
|
|
|
|
Prerequisites:
|
|
|
|
- A running Artifactory instances
|
|
- A user + password / API key with grants to upload an artifact
|
|
|
|
### Target
|
|
|
|
The `target` is the URL to upload the artifacts to (_without_ the name of the artifact).
|
|
|
|
An example configuration for `goreleaser` in upload mode `binary` with the target can look like
|
|
|
|
```yaml
|
|
- mode: binary
|
|
target: 'http://artifacts.company.com:8081/artifactory/example-repo-local/{{ .ProjectName }}/{{ .Version }}/{{ .Os }}/{{ .Arch }}{{ if .Arm }}{{ .Arm }}{{ end }}'
|
|
```
|
|
|
|
and will result in a final deployment like `http://artifacts.company.com:8081/artifactory/example-repo-local/goreleaser/1.0.0/Darwin/x86_64/goreleaser`.
|
|
|
|
Supported variables:
|
|
|
|
- Version
|
|
- Tag
|
|
- ProjectName
|
|
- Os
|
|
- Arch
|
|
- Arm
|
|
|
|
_Attention_: Variables _Os_, _Arch_ and _Arm_ are only supported in upload
|
|
mode `binary`.
|
|
|
|
### Username
|
|
|
|
Your configured username needs to be authenticated against your Artifactory.
|
|
|
|
You can have the username set in the configuration file as shown above
|
|
or you can have it read from an environment variable.
|
|
The configured name of your Artifactory instance will be used to build
|
|
the environment variable name.
|
|
This way we support auth for multiple instances.
|
|
This also means that the `name` per configured instance needs to be unique
|
|
per goreleaser configuration.
|
|
|
|
The name of the environment variable will be `ARTIFACTORY_NAME_USERNAME`.
|
|
If your instance is named `production`, you can store the username in the
|
|
environment variable `ARTIFACTORY_PRODUCTION_USERNAME`.
|
|
The name will be transformed to uppercase.
|
|
|
|
If a configured username is found in the configuration file, then the
|
|
environment variable is not used at all.
|
|
|
|
### Password / API Key
|
|
|
|
The password or API key will be stored in a environment variable.
|
|
The configured name of your Artifactory instance will be used.
|
|
With this way we support auth for multiple instances.
|
|
This also means that the `name` per configured instance needs to be unique
|
|
per goreleaser configuration.
|
|
|
|
The name of the environment variable will be `ARTIFACTORY_NAME_SECRET`.
|
|
If your instance is named `production`, you need to store the secret in the
|
|
environment variable `ARTIFACTORY_PRODUCTION_SECRET`.
|
|
The name will be transformed to uppercase.
|
|
|
|
## Customization
|
|
|
|
Of course, you can customize a lot of things:
|
|
|
|
```yaml
|
|
# .goreleaser.yml
|
|
artifactories:
|
|
# You can have multiple Artifactory instances.
|
|
-
|
|
# Unique name of your artifactory instance. Used to identify the instance
|
|
name: production
|
|
# Upload mode. Valid options are `binary` and `archive`.
|
|
# If mode is `archive`, variables _Os_, _Arch_ and _Arm_ for target name are not supported.
|
|
# In that case these variables are empty.
|
|
# Default is `archive`.
|
|
mode: archive
|
|
# URL of your Artifactory instance + path to deploy to
|
|
target: http://artifacts.company.com:8081/artifactory/example-repo-local/{{ .ProjectName }}/{{ .Version }}/
|
|
# User that will be used for the deployment
|
|
username: deployuser
|
|
# Upload checksums (defaults to false)
|
|
checksum: true
|
|
# Upload signatures (defaults to false)
|
|
signature: true
|
|
```
|
|
|
|
These settings should allow you to push your artifacts into multiple Artifactories.
|