release-action/README.adoc

154 lines
5.6 KiB
Text
Raw Normal View History

2021-03-28 22:06:38 +00:00
= JReleaser
:linkattrs:
2021-03-29 09:14:49 +00:00
:project-owner: jreleaser
:project-name: release-action
2021-03-28 22:06:38 +00:00
image:https://github.com/{project-owner}/{project-name}/workflows/Test/badge.svg["Build Status", link="https://github.com/{project-owner}/{project-name}/actions"]
2021-03-29 12:21:42 +00:00
image:https://img.shields.io/github/v/release/{project-owner}/{project-name}["GitHub release", link="https://github.com/jreleaser/release-action/releases"]
2021-03-29 12:19:12 +00:00
image:https://img.shields.io/twitter/follow/{project-owner}?style=social["Twitter Follow", link="https://twitter.com/jreleaser"]
2021-03-28 22:06:38 +00:00
This action executes a link:https://jreleaser.org[JReleaser] workflow.
== Usage
=== Workflow
[source,yaml]
----
name: release
on:
workflow_dispatch:
jobs:
release:
name: Release
runs-on: ubuntu-latest
steps:
- name: Checkout
2021-04-04 17:30:54 +00:00
uses: actions/checkout@v2
with:
fetch-depth: 0
2021-03-28 22:06:38 +00:00
# Configure build steps as you'd normally do
- name: Setup Java
2022-01-02 17:49:24 +00:00
uses: actions/setup-java@v2
2021-03-28 22:06:38 +00:00
with:
2022-01-02 17:49:24 +00:00
java-version: 11
distribution: 'zulu'
2021-03-28 22:06:38 +00:00
server-id: central
server-username: MAVEN_USERNAME
server-password: MAVEN_CENTRAL_TOKEN
gpg-private-key: ${{ secrets.GPG_PRIVATE_KEY }}
gpg-passphrase: MAVEN_GPG_PASSPHRASE
# Post JARs to Maven Central
- name: Release to Maven Central
env:
MAVEN_USERNAME: ${{ secrets.SONATYPE_USERNAME }}
MAVEN_CENTRAL_TOKEN: ${{ secrets.SONATYPE_PASSWORD }}
MAVEN_GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }}
run: |
export GPG_TTY=$(tty)
git config user.name "${{ github.event.head_commit.committer.name }}"
git config user.email "${{ github.event.head_commit.committer.email }}"
mvn -B --file pom.xml release:prepare release:perform
# Create a release
- name: Run JReleaser
2022-01-02 17:49:24 +00:00
uses: jreleaser/release-action@v2
2021-03-28 22:06:38 +00:00
env:
JRELEASER_GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
2022-02-02 18:33:02 +00:00
# Persist logs
- name: JReleaser release output
if: always()
uses: actions/upload-artifact@v2
with:
name: jreleaser-release
path: |
out/jreleaser/trace.log
out/jreleaser/output.properties
2021-03-28 22:06:38 +00:00
----
2021-04-04 17:30:54 +00:00
WARNING: Note the `fetch-depth: 0` option on the `Checkout` workflow step. It is required for JReleaser to work properly.
Without that, JReleaser might fail or behave incorrectly.
2022-01-02 17:49:24 +00:00
The last step executes a `full-release` with the default `jreleaser.yml` configuration that's expected to be located at
the root of the repository.
2021-03-28 22:06:38 +00:00
2022-01-02 17:49:24 +00:00
IMPORTANT: This action requires Java 11+ to download and execute JReleaser. The action will setup a suitable Java runtime
automatically. If you would like to use a different Java version/distribution then set the value of `setup-java` to `false`
and make sure you have a previous step with `actions/setup-java` setup as needed.
2021-03-29 09:01:49 +00:00
2021-03-28 22:06:38 +00:00
== Customizing
== Inputs
Following inputs can be used as `step.with` keys
2021-03-30 14:10:07 +00:00
[%header,cols="<2,<,<2,<3",width="100%"]
2021-03-28 22:06:38 +00:00
|===
2022-01-02 17:49:24 +00:00
| Name | Type | Default | Description
| version | String | latest | The JReleaser version to use. +
2021-05-07 21:23:13 +00:00
Should match any of the link:https://github.com/jreleaser/jreleaser/releases[published releases]. +
You may use `latest` to pull the latest stable release or +
`early-access` to pull the latest snapshot.
2022-01-02 17:49:24 +00:00
| arguments | String | full-release | The JReleaser command to run.
| working-directory | String | ${{ github.workspace }} | The directory to change into. +
2021-03-30 12:01:36 +00:00
Defaults to the directory the calling workflow runs in.
2022-01-02 17:49:24 +00:00
| setup-java | boolean | true | Automatically setup a Java runtime. +
Java runtime defaults to Zulu 17.
2021-03-28 22:06:38 +00:00
|===
== Environment Variables
Following environment variables can be used as `step.env` keys
2021-03-28 22:11:54 +00:00
[%header,width="100%"]
2021-03-28 22:06:38 +00:00
|===
| Name | Description
| JRELEASER_GITHUB_TOKEN | link:https://help.github.com/en/actions/configuring-and-managing-workflows/authenticating-with-the-github_token[GITHUB_TOKEN]
as provided by `secrets`
|===
== Caution
The default `GITHUB_TOKEN` from `secrets` is link:https://help.github.com/en/actions/configuring-and-managing-workflows/authenticating-with-the-github_token#about-the-github_token-secret[limited]
2021-05-07 21:23:13 +00:00
to the repository that contains your workflow.
2021-03-28 22:06:38 +00:00
Pushing to other repositories such as Homebrew tap requires additional permissions, you must create a custom
link:https://help.github.com/articles/creating-a-personal-access-token-for-the-command-line/[Personal Access Token] with
`repo` permissions and link:https://help.github.com/en/actions/automating-your-workflow-with-github-actions/creating-and-using-encrypted-secrets[add it as a secret in the repository].
If you create a secret named `GH_PAT`, the step will look like this
[source,yaml]
----
- name: Run JReleaser
2022-01-02 17:49:24 +00:00
uses: jreleaser/release-action@v2
2021-03-28 22:06:38 +00:00
env:
JRELEASER_GITHUB_TOKEN: ${{ secrets.GH_PAT }}
----
If you'd rather have separate tokens for each additional repository and keep the original `GITHUB_TOKEN` intact then
you may apply the `GH_PAT` token as follows
[source,yaml]
----
- name: Run JReleaser
2022-01-02 17:49:24 +00:00
uses: jreleaser/release-action@v2
2021-03-28 22:06:38 +00:00
env:
JRELEASER_GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
JRELEASER_HOMEBREW_GITHUB_TOKEN: ${{ secrets.GH_PAT }}
----
2021-03-28 22:11:54 +00:00
Additional environment variables may be needed depending on your specific setup, such as those needed for signing files
with GPG or announcing a release via Twitter. Review the docs at link:https://jreleaser.org[] to find more about these
variables and how to set them up.
2021-03-28 22:06:38 +00:00