Spec
JReleaser can generate and publish a RPM Spec file and publish it to a repository that you have access to.
The spec
section specifies how the Spec should be created.
The following artifact extensions are supported by this packager:
-
.tbz2
-
.tgz
-
.txz
-
.tar.gz
-
.tar.xz
-
.tar.bz2
-
.tar
-
.zip
Configuration
Legend:
-
required
-
optional
-
may use environment variable
-
accepts Name Templates
#
packagers:
#
spec:
# Enables or disables Spec.
# Supported values are [`NEVER`, `ALWAYS`, `RELEASE`, `SNAPSHOT`].
# Defaults to `NEVER`.
#
active: ALWAYS
# Let the release continue if the packager fails.
# Defaults to `false`.
#
continueOnError: true
# Custom download URL.
#
downloadUrl: https://my.server.com/{{projectName}}/{{tagName}}/{{artifactFile}}
# Additional properties used when evaluating templates.
#
extraProperties:
# Key will be capitalized and prefixed with `spec`, i.e, `specFoo`.
foo: bar
# Directory with file templates used to prepare the Spec distribution.
# Defaults to `src/jreleaser/distributions/#{distribution.name}/spec`.
# If specified, path must exist.
#
templateDirectory: path/to/spec/templates
# List of template files to be skipped.
# Value may be an exact match or a regex.
#
skipTemplates:
- README.md.tpl
# Git author used to commit to the repository.
#
commitAuthor:
# Name used when authoring commits.
# Defaults to `jreleaserbot`.
#
name: jreleaserbot
# E-mail used when authoring commits.
# Defaults to `jreleaser@kordamp.org`.
#
email: jreleaser@kordamp.org
# Git repository to push the spec to.
# Defaults are shown.
#
repository:
# Enables or disables the repository.
# Supported values are [`NEVER`, `ALWAYS`, `RELEASE`, `SNAPSHOT`].
# Defaults to `RELEASE`.
#
active: ALWAYS
# The owner of the repository.
# Defaults to the same owner as the release repository.
#
owner: duke
# The name of the repository.
# Defaults to `duke-spec`.
#
name: duke-spec
# The tag associated with the spec.
# If left unspecified, will use `{{tagName}}`.
#
tagName: '{{distributionName}}-{{tagName}}'
# The target branch to pull from.
# Defaults to the branch pointed by HEAD.
#
branch: HEAD
# The target branch to push to.
# Defaults to the branch pointed by `#{branch}`.
#
branchPush: '{{projectName}}-{{tagName}}'
# Username used for authoring commits.
# Must have write access to the repository.
# Defaults to the same username as the release repository.
#
username: duke
# Password or OAuth token with write access to the repository.
#
token: __USE_ENVIRONMENT_VARIABLE__
# Message when committing to the repository.
# If left unspecified, `{{distributionName}} {{tagName}}` will be used.
#
commitMessage: '{{distributionName}} {{tagName}}'
# Additional properties used when evaluating templates.
#
extraProperties:
# Key will be capitalized and prefixed with `repository`, i.e, `repositoryFoo`.
foo: bar
# Name of the Spec package.
# Defaults to `#{distribution.name}`.
#
packageName: app
# Spec release number.
# Defaults to `1%{?dist}`.
#
release: '1%{?dist}'
# List of package requirements.
# Defaults to `[java]`.
#
categories:
- 'java'
#
[packagers.spec]
# Enables or disables Spec.
# Supported values are [`NEVER`, `ALWAYS`, `RELEASE`, `SNAPSHOT`].
# Defaults to `NEVER`.
#
active = "ALWAYS"
# Let the release continue if the packager fails.
# Defaults to `false`.
#
continueOnError = true
# Custom download URL.
#
downloadUrl = "https://my.server.com/{{projectName}}/{{tagName}}/{{artifactFile}}"
# Additional properties used when evaluating templates.
#
extraProperties.foo = "bar"
# Key will be capitalized and prefixed with `spec`, i.e, `specFoo`.
# Directory with file templates used to prepare the Spec distribution.
# Defaults to `src/jreleaser/distributions/#{distribution.name}/spec`.
# If specified, path must exist.
#
templateDirectory = "path/to/spec/templates"
# List of template files to be skipped.
# Value may be an exact match or a regex.
#
skipTemplates = [ "README.md.tpl" ]
# Git author used to commit to the repository.
# Name used when authoring commits.
# Defaults to `jreleaserbot`.
#
commitAuthor.name = "jreleaserbot"
# E-mail used when authoring commits.
# Defaults to `jreleaser@kordamp.org`.
#
commitAuthor.email = "jreleaser@kordamp.org"
# Git repository to push the spec to.
# Defaults are shown.
# Enables or disables the repository.
# Supported values are [`NEVER`, `ALWAYS`, `RELEASE`, `SNAPSHOT`].
# Defaults to `RELEASE`.
#
repository.active = "ALWAYS"
# The owner of the repository.
# Defaults to the same owner as the release repository.
#
repository.owner = "duke"
# The name of the repository.
# Defaults to `duke-spec`.
#
repository.name = "duke-spec"
# The tag associated with the spec.
# If left unspecified, will use `{{tagName}}`.
#
repository.tagName = "{{distributionName}}-{{tagName}}"
# The target branch to pull from.
# Defaults to the branch pointed by HEAD.
#
repository.branch = "HEAD"
# The target branch to push to.
# Defaults to the branch pointed by `#{branch}`.
#
repository.branchPush = "{{projectName}}-{{tagName}}"
# Username used for authoring commits.
# Must have write access to the repository.
# Defaults to the same username as the release repository.
#
repository.username = "duke"
# Password or OAuth token with write access to the repository.
#
repository.token = "__USE_ENVIRONMENT_VARIABLE__"
# Message when committing to the repository.
# If left unspecified, `{{distributionName}} {{tagName}}` will be used.
#
repository.commitMessage = "{{distributionName}} {{tagName}}"
# Additional properties used when evaluating templates.
#
repository.extraProperties.foo = "bar"
# Key will be capitalized and prefixed with `repository`, i.e, `repositoryFoo`.
# Name of the Spec package.
# Defaults to `#{distribution.name}`.
#
packageName = "app"
# Spec release number.
# Defaults to `1%{?dist}`.
#
release = "1%{?dist}"
# List of package requirements.
# Defaults to `[java]`.
#
categories = ["java"]
{
//
"packagers": {
//
"spec": {
// Enables or disables Spec.
// Supported values are [`NEVER`, `ALWAYS`, `RELEASE`, `SNAPSHOT`].
// Defaults to `NEVER`.
//
"active": "ALWAYS",
// Let the release continue if the packager fails.
// Defaults to `false`.
//
"continueOnError": true,
// Custom download URL.
//
"downloadUrl": "https://my.server.com/{{projectName}}/{{tagName}}/{{artifactFile}}",
// Additional properties used when evaluating templates.
//
"extraProperties": {
// Key will be capitalized and prefixed with `spec`, i.e, `specFoo`.
"foo": "bar"
},
// Directory with file templates used to prepare the Spec distribution.
// Defaults to `src/jreleaser/distributions/#{distribution.name}/spec`.
// If specified, path must exist.
//
"templateDirectory": "path/to/spec/templates",
// List of template files to be skipped.
// Value may be an exact match or a regex.
//
"skipTemplates": [
"README.md.tpl"
],
// Git author used to commit to the repository.
//
"commitAuthor": {
// Name used when authoring commits.
// Defaults to `jreleaserbot`.
//
"name": "jreleaserbot",
// E-mail used when authoring commits.
// Defaults to `jreleaser@kordamp.org`.
//
"email": "jreleaser@kordamp.org"
},
// Git repository to push the spec to.
// Defaults are shown.
//
"repository": {
// Enables or disables the repository.
// Supported values are [`NEVER`, `ALWAYS`, `RELEASE`, `SNAPSHOT`].
// Defaults to `RELEASE`.
//
"active": "ALWAYS",
// The owner of the repository.
// Defaults to the same owner as the release repository.
//
"owner": "duke",
// The name of the repository.
// Defaults to `duke-spec`.
//
"name": "duke-spec",
// The tag associated with the spec.
// If left unspecified, will use `{{tagName}}`.
//
"tagName": "{{distributionName}}-{{tagName}}",
// The target branch to pull from.
// Defaults to the branch pointed by HEAD.
//
"branch": "HEAD",
// The target branch to push to.
// Defaults to the branch pointed by `#{branch}`.
//
"branchPush": "{{projectName}}-{{tagName}}",
// Username used for authoring commits.
// Must have write access to the repository.
// Defaults to the same username as the release repository.
//
"username": "duke",
// Password or OAuth token with write access to the repository.
//
"token": "__USE_ENVIRONMENT_VARIABLE__",
// Message when committing to the repository.
// If left unspecified, `{{distributionName}} {{tagName}}` will be used.
//
"commitMessage": "{{distributionName}} {{tagName}}",
// Additional properties used when evaluating templates.
//
"extraProperties": {
// Key will be capitalized and prefixed with `repository`, i.e, `repositoryFoo`.
"foo": "bar"
}
},
// Name of the Spec package.
// Defaults to `#{distribution.name}`.
//
"packageName": "app",
// Spec release number.
// Defaults to `1%{?dist}`.
//
"release": "1%{?dist}",
// List of package requirements.
// Defaults to `[java]`.
//
"categories": ["java"],
}
}
}
<jreleaser>
<!--
-->
<packagers>
<!--
-->
<spec>
<!--
Enables or disables Spec.
Supported values are [`NEVER`, `ALWAYS`, `RELEASE`, `SNAPSHOT`].
Defaults to `NEVER`.
-->
<active>ALWAYS</active>
<!--
Let the release continue if the packager fails.
Defaults to `false`.
-->
<continueOnError>true</continueOnError>
<!--
Custom download URL.
-->
<downloadUrl>https://my.server.com/{{projectName}}/{{tagName}}/{{artifactFile}}</downloadUrl>
<!--
Additional properties used when evaluating templates.
-->
<extraProperties>
<!--
Key will be capitalized and prefixed with `spec`, i.e, `specFoo`.
-->
<foo>bar</foo>
</extraProperties>
<!--
Directory with file templates used to prepare the Spec distribution.
Defaults to `src/jreleaser/distributions/#{distribution.name}/spec`.
If specified, path must exist.
-->
<templateDirectory>path/to/spec/templates</templateDirectory>
<!--
List of template files to be skipped.
Value may be an exact match or a regex.
-->
<skipTemplates>
<skipTemplate>README.md.tpl</skipTemplate>
</skipTemplates>
<!--
Git author used to commit to the repository.
-->
<commitAuthor>
<!--
Name used when authoring commits.
Defaults to `jreleaserbot`.
-->
<name>jreleaserbot</name>
<!--
E-mail used when authoring commits.
Defaults to `jreleaser@kordamp.org`.
-->
<email>jreleaser@kordamp.org</email>
</commitAuthor>
<!--
Git repository to push the spec to.
Defaults are shown.
-->
<repository>
<!--
Enables or disables the repository.
Supported values are [`NEVER`, `ALWAYS`, `RELEASE`, `SNAPSHOT`].
Defaults to `RELEASE`.
-->
<active>ALWAYS</active>
<!--
The owner of the repository.
Defaults to the same owner as the release repository.
-->
<owner>duke</owner>
<!--
The name of the repository.
Defaults to `duke-spec`.
-->
<name>duke-spec</name>
<!--
The tag associated with the spec.
If left unspecified, will use `{{tagName}}`.
-->
<tagName>{{distributionName}}-{{tagName}}</tagName>
<!--
The target branch to pull from.
Defaults to the branch pointed by HEAD.
-->
<branch>HEAD</branch>
<!--
The target branch to push to.
Defaults to the branch pointed by `#{branch}`.
-->
<branchPush>{{projectName}}-{{tagName}}</branchPush>
<!--
Username used for authoring commits.
Must have write access to the repository.
Defaults to the same username as the release repository.
-->
<username>duke</username>
<!--
Password or OAuth token with write access to the repository.
-->
<token>__USE_ENVIRONMENT_VARIABLE__</token>
<!--
Message when committing to the repository.
If left unspecified, `{{distributionName}} {{tagName}}` will be used.
-->
<commitMessage>{{distributionName}} {{tagName}}</commitMessage>
<!--
Additional properties used when evaluating templates.
-->
<extraProperties>
<!--
Key will be capitalized and prefixed with `repository`, i.e, `repositoryFoo`.
-->
<foo>bar</foo>
</extraProperties>
</repository>
<!--
Name of the Spec package.
Defaults to `#{distribution.name}`.
-->
<packageName>app</packageName>
<!--
Spec release number.
Defaults to `1%{?dist}`.
-->
<release>1%{?dist}</release>
<!--
List of package requirements.
Defaults to `[java]`.
-->
<categories>java</categories>
</spec>
</packagers>
</jreleaser>
jreleaser {
//
packagers {
//
spec {
// Enables or disables Spec.
// Supported values are [`NEVER`, `ALWAYS`, `RELEASE`, `SNAPSHOT`].
// Defaults to `NEVER`.
//
active = 'ALWAYS'
// Let the release continue if the packager fails.
// Defaults to `false`.
//
continueOnError = true
// Custom download URL.
//
downloadUrl = 'https://my.server.com/{{projectName}}/{{tagName}}/{{artifactFile}}'
// Additional properties used when evaluating templates.
// Key will be capitalized and prefixed with `spec`, i.e, `specFoo`.
//
extraProperties.put('foo', 'bar')
// Directory with file templates used to prepare the Spec distribution.
// Defaults to `src/jreleaser/distributions/#{distribution.name}/spec`.
// If specified, path must exist.
//
templateDirectory = 'path/to/spec/templates'
// List of template files to be skipped.
// Value may be an exact match or a regex.
//
skipTemplate('README.md.tpl')
// Git author used to commit to the repository.
//
commitAuthor {
// Name used when authoring commits.
// Defaults to `jreleaserbot`.
//
name = 'jreleaserbot'
// E-mail used when authoring commits.
// Defaults to `jreleaser@kordamp.org`.
//
email = 'jreleaser@kordamp.org'
}
// Git repository to push the spec to.
// Defaults are shown.
//
repository {
// Enables or disables the repository.
// Supported values are [`NEVER`, `ALWAYS`, `RELEASE`, `SNAPSHOT`].
// Defaults to `RELEASE`.
//
active = 'ALWAYS'
// The owner of the repository.
// Defaults to the same owner as the release repository.
//
repoOwner = 'duke'
// The name of the repository.
// Defaults to `duke-spec`.
//
name = 'duke-spec'
// The tag associated with the spec.
// If left unspecified, will use `{{tagName}}`.
//
tagName = '{{distributionName}}-{{tagName}}'
// The target branch to pull from.
// Defaults to the branch pointed by HEAD.
//
branch = 'HEAD'
// The target branch to push to.
// Defaults to the branch pointed by `#{branch}`.
//
branchPush = '{{projectName}}-{{tagName}}'
// Username used for authoring commits.
// Must have write access to the repository.
// Defaults to the same username as the release repository.
//
username = 'duke'
// Password or OAuth token with write access to the repository.
//
token = '__USE_ENVIRONMENT_VARIABLE__'
// Message when committing to the repository.
// If left unspecified, `{{distributionName}} {{tagName}}` will be used.
//
commitMessage = '{{distributionName}} {{tagName}}'
// Additional properties used when evaluating templates.
// Key will be capitalized and prefixed with `repository`, i.e, `repositoryFoo`.
//
extraProperties.put('foo', 'bar')
}
// Name of the Spec package.
// Defaults to `#{distribution.name}`.
//
packageName = 'app'
// Spec release number.
// Defaults to `1%{?dist}`.
//
release = '1%{?dist}'
// List of package requirements.
// Defaults to `[java]`.
//
categories = ['java']
}
}
}
Environment
When not explicitly set, the value of the following properties may be resolved from an environment variable or a system property as shown in the table. The system property takes precedence over the environment variable.
Inside packagers
section
System Property | Environment Variable |
---|---|
active |
|
jreleaser.packagers.spec.active |
JRELEASER_PACKAGERS_SPEC_ACTIVE |
Inside distributions
section
System Property | Environment Variable |
---|---|
active |
|
jreleaser.distributions.${name}.spec.active |
JRELEASER_DISTRIBUTIONS_${name}_SPEC_ACTIVE |
repository.active |
|
jreleaser.distributions.${name}.spec.repository.active |
JRELEASER_DISTRIBUTIONS_${name}_SPEC_REPOSITORY_ACTIVE |
repository.username |
|
jreleaser.distributions.${name}.spec.repository.username |
JRELEASER_DISTRIBUTIONS_${name}_SPEC_REPOSITORY_USERNAME |
repository.token |
|
jreleaser.distributions.${name}.spec.repository.token |
JRELEASER_DISTRIBUTIONS_${name}_SPEC_REPOSITORY_TOKEN |
repository.branch |
|
jreleaser.distributions.${name}.spec.repository.branch |
JRELEASER_DISTRIBUTIONS_${name}_SPEC_REPOSITORY_BRANCH |
repository.branchPush |
|
jreleaser.distributions.${name}.spec.repository.branch.push |
JRELEASER_DISTRIBUTIONS_${name}_SPEC_REPOSITORY_BRANCH_PUSH |
Substitute ${name} for the value of the named instance. |
Space (' '), underscore (_
), and dash (-
) will be replaced by dot (.
) to separate tokens in the System property.
Space (' '), dash (-
), and dot (.
) will be replaced by underscore (_
) to separate tokens in the environment variable,
such that:
${name} | System Property | Environment Variable |
---|---|---|
foobar |
|
|
fooBar |
|
|
foo bar |
|
|
foo-bar |
|
|
foo_bar |
|
|
foo.bar |
|
|
Tokens
The repository token environment variable must match with the chosen Release service. |
On GitHub, you can’t use the default
|
DownloadURL
JReleaser follows these rules to find the download URL to use for a given artifact:
-
if
artifact.extraProperties.specDownloadUrl
exists, use it. -
if
artifact.extraProperties.downloadUrl
exists, use it. -
if explicit
downloadUrl
is set onspec
, use it. -
if
distribution.extraProperties.specDownloadUrl
exists, use it. -
if
distribution.extraProperties.downloadUrl
exists, use it. -
if
releaser.${release}.skipRelease
isfalse
then use the releaser’sdownloadUrl
. -
if
releaser.${release}.skipRelease
istrue
then look for a matching uploader given an extraProperty nameddownloadUrlFrom
onartifact
,distribution, `spec
(in that order). The value must be<uploaderType>:<uploaderName>
such as "artifactory:app" or "s3:uploads". -
fail if no suitable URL is found.
With no extra configuration from your side rule 6. will be chosen which is the suitable default that most projects need.
Example
Assuming the current version is 1.2.3
, and a distribution named app
, the above configuration will generate
a app.spec
file in the duke/duke-spec
repository:
Name: app
Version: 1.2.3
Release: 1%{?dist}
Summary: Sample App
License: Apache-2.0
URL: https://acme.com/app
Source0: https://github.com/duke/app/releases/download/v1.2.3/app-1.2.3.tar.gz
BuildArch: noarch
Requires: java
%description
Sample app
%prep
%setup -q
%install
mkdir -p %{buildroot}%{_bindir}
%define _appdir %{buildroot}%{_datadir}/%{name}
mkdir -p %{_appdir}/bin
cat > %{buildroot}%{_bindir}/app <<-EOF
#!/bin/sh
%{_datadir}/%{name}/bin/app "$@"
EOF
chmod 0755 %{buildroot}%{_bindir}/app
mkdir -p %{_appdir}/lib
install -p -m 755 bin/app %{_appdir}/bin/app
install -p -m 644 lib/app-%{version}.jar %{_appdir}/lib/app-%{version}.jar
%files
%{_bindir}/%{name}
%{_datadir}/%{name}/bin/app
%{_datadir}/%{name}/lib/app-%{version}.jar
You may configure automated builds with Fedora COPR or any other service that accepts spec files as inputs.
Templates
The default location for templates is:
src/jreleaser/distributions/<distribution-name>/spec
The following list shows the filenames that may be used to override default templates:
-
app.spec.tpl
Any additional files found in the template directories will be copied as is unless their filename ends with .tpl
in
which case Name Templates substitution will take place.
Templates may be initialized using the template
command
Skip Templates
You may skip any template files by defining a set of skip rules in the skipTemplates
property. For example, you may use
any of these expressions to skip a template named README.md.tpl
:
-
README.md.tpl
: matches the full template name -
README.md
: matches the transformed template name -
README.*
: matches using a regex
Skip Artifacts
If there is more than one matching artifact in a given distribution you may add a skipSpec
extra property
to the target artifact to mark it as skipped for packaging with spec.
Skip License
If there’s a matching LICENSE
file available at the root of the project it will be copied to the repository by default.
You may set an extra property named skipLicenseFile
on spec to skip this behavior.
Repository
The repository
section allows setting extra properties that may be used to provide additional hints when interacting
with the git repository that holds packager files.
GitLab
Define a projectIdentifier
property to directly locate the project associated with the repository, such as
packagers:
spec:
repository:
extraProperties:
projectIdentifier: 12345678
[packagers.spec]
repository.extraProperties.projectIdentifier = "12345678"
{
"packagers": {
"spec": {
"repository": {
"extraProperties": {
"projectIdentifier": "12345678"
}
}
}
}
}
<jreleaser>
<packagers>
<spec>
<repository>
<extraProperties>
<projectIdentifier>12345678</projectIdentifier>
</extraProperties>
</repository>
</spec>
</packagers>
</jreleaser>
jreleaser {
packagers {
spec {
repository {
extraProperties.put("projectIdentifier", "12345678")
}
}
}
}