Compare commits
14 commits
Author | SHA1 | Date | |
---|---|---|---|
9df19435e9 | |||
|
ab17acedd9 | ||
|
f2226e009e | ||
|
2c142e07de | ||
|
8b970bcd10 | ||
|
3bef4586af | ||
|
9d00b8a3e3 | ||
|
77fb95c777 | ||
|
7848b6eb87 | ||
|
2848f4bf5e | ||
|
4405eb1113 | ||
|
7feb30071b | ||
|
f4b19f681f | ||
|
1be32a4768 |
4 changed files with 93 additions and 34 deletions
10
.github/workflows/test.yml
vendored
10
.github/workflows/test.yml
vendored
|
@ -1,9 +1,10 @@
|
|||
name: Test
|
||||
|
||||
on: push
|
||||
on:
|
||||
push:
|
||||
workflow_dispatch:
|
||||
|
||||
jobs:
|
||||
|
||||
test:
|
||||
name: 'JReleaser ${{ matrix.tag }}, Java ${{ matrix.java }}, ${{ matrix.os }}'
|
||||
strategy:
|
||||
|
@ -15,10 +16,11 @@ jobs:
|
|||
runs-on: ${{ matrix.os }}
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
|
||||
- uses: actions/setup-java@v1
|
||||
with:
|
||||
java-version: ${{ matrix.java }}
|
||||
|
||||
- uses: ./
|
||||
with:
|
||||
arguments: --version
|
||||
- run: echo "Here be assertions and dragons..."
|
||||
arguments: --version
|
51
README.adoc
51
README.adoc
|
@ -27,16 +27,17 @@ jobs:
|
|||
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v2
|
||||
uses: actions/checkout@v3
|
||||
with:
|
||||
fetch-depth: 0
|
||||
|
||||
# Configure build steps as you'd normally do
|
||||
|
||||
- name: Setup Java
|
||||
uses: actions/setup-java@v1
|
||||
uses: actions/setup-java@v3
|
||||
with:
|
||||
java-version: 1.8
|
||||
java-version: 11
|
||||
distribution: 'zulu'
|
||||
server-id: central
|
||||
server-username: MAVEN_USERNAME
|
||||
server-password: MAVEN_CENTRAL_TOKEN
|
||||
|
@ -56,29 +57,34 @@ jobs:
|
|||
git config user.email "${{ github.event.head_commit.committer.email }}"
|
||||
mvn -B --file pom.xml release:prepare release:perform
|
||||
|
||||
# IMPORTANT!
|
||||
|
||||
- name: Setup Java for JReleaser
|
||||
uses: actions/setup-java@v1
|
||||
with:
|
||||
java-version: 11
|
||||
|
||||
# Create a release
|
||||
|
||||
- name: Run JReleaser
|
||||
uses: jreleaser/release-action@v1
|
||||
uses: jreleaser/release-action@v2
|
||||
env:
|
||||
JRELEASER_GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
|
||||
# Persist logs
|
||||
|
||||
- name: JReleaser release output
|
||||
if: always()
|
||||
uses: actions/upload-artifact@v3
|
||||
with:
|
||||
name: jreleaser-release
|
||||
path: |
|
||||
out/jreleaser/trace.log
|
||||
out/jreleaser/output.properties
|
||||
----
|
||||
|
||||
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.
|
||||
|
||||
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.
|
||||
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.
|
||||
|
||||
IMPORTANT: This action requires Java 11+ to download and execute JReleaser. If your project already builds with Java 11+
|
||||
then you can skip the second "setup" step.
|
||||
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.
|
||||
|
||||
== Customizing
|
||||
|
||||
|
@ -88,14 +94,17 @@ Following inputs can be used as `step.with` keys
|
|||
|
||||
[%header,cols="<2,<,<2,<3",width="100%"]
|
||||
|===
|
||||
| Name | Type | Default | Description
|
||||
| version | String | latest | The JReleaser version to use. +
|
||||
| Name | Type | Default | Description
|
||||
| version | String | latest | The JReleaser version to use. +
|
||||
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.
|
||||
| arguments | String | full-release | The JReleaser command to run.
|
||||
| working-directory | String | ${{ github.workspace }} | The directory to change into. +
|
||||
| arguments | String | full-release | The JReleaser command to run.
|
||||
| working-directory | String | ${{ github.workspace }} | The directory to change into. +
|
||||
Defaults to the directory the calling workflow runs in.
|
||||
| setup-java | boolean | true | Automatically setup a Java runtime. +
|
||||
Java runtime defaults to Zulu 17.
|
||||
| java-opts | boolean | | Additional JVM parameters for running JReleaser
|
||||
|===
|
||||
|
||||
== Environment Variables
|
||||
|
@ -122,7 +131,7 @@ If you create a secret named `GH_PAT`, the step will look like this
|
|||
[source,yaml]
|
||||
----
|
||||
- name: Run JReleaser
|
||||
uses: jreleaser/release-action@v1
|
||||
uses: jreleaser/release-action@v2
|
||||
env:
|
||||
JRELEASER_GITHUB_TOKEN: ${{ secrets.GH_PAT }}
|
||||
----
|
||||
|
@ -133,7 +142,7 @@ you may apply the `GH_PAT` token as follows
|
|||
[source,yaml]
|
||||
----
|
||||
- name: Run JReleaser
|
||||
uses: jreleaser/release-action@v1
|
||||
uses: jreleaser/release-action@v2
|
||||
env:
|
||||
JRELEASER_GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
JRELEASER_HOMEBREW_GITHUB_TOKEN: ${{ secrets.GH_PAT }}
|
||||
|
|
20
action.yml
20
action.yml
|
@ -7,7 +7,6 @@ branding:
|
|||
color: 'gray-dark'
|
||||
|
||||
inputs:
|
||||
|
||||
version:
|
||||
description: 'The version of JReleaser to download and execute.'
|
||||
default: 'latest'
|
||||
|
@ -23,9 +22,26 @@ inputs:
|
|||
default: ${{ github.workspace }}
|
||||
description: 'The directory to change into.'
|
||||
|
||||
setup-java:
|
||||
default: 'true'
|
||||
description: 'Setup internal Java runtime.'
|
||||
required: false
|
||||
|
||||
java-opts:
|
||||
default: ''
|
||||
description: 'Additional JVM parameters'
|
||||
required: false
|
||||
|
||||
runs:
|
||||
using: 'composite'
|
||||
steps:
|
||||
- name: 'Setup Java'
|
||||
uses: https://github.com/actions/setup-java@v3
|
||||
if: ${{ inputs.setup-java == 'true' }}
|
||||
with:
|
||||
java-version: 17
|
||||
distribution: 'zulu'
|
||||
|
||||
- name: 'Download JReleaser'
|
||||
shell: bash
|
||||
working-directory: ${{ inputs.working-directory }}
|
||||
|
@ -40,4 +56,4 @@ runs:
|
|||
working-directory: ${{ inputs.working-directory }}
|
||||
run: |
|
||||
echo "☕ java -jar jreleaser-cli.jar ${{ inputs.arguments }}"
|
||||
java -jar jreleaser-cli.jar ${{ inputs.arguments }}
|
||||
java ${{ inputs.java-opts }} -jar jreleaser-cli.jar ${{ inputs.arguments }}
|
||||
|
|
|
@ -1,9 +1,15 @@
|
|||
//JAVA 11+
|
||||
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.IOException;
|
||||
import java.net.URL;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.nio.file.StandardCopyOption;
|
||||
|
||||
import static java.nio.file.StandardCopyOption.REPLACE_EXISTING;
|
||||
import static java.nio.file.StandardOpenOption.CREATE;
|
||||
import static java.nio.file.StandardOpenOption.TRUNCATE_EXISTING;
|
||||
import static java.nio.file.StandardOpenOption.WRITE;
|
||||
|
||||
class get_jreleaser {
|
||||
public static void main(String... args) throws Exception {
|
||||
|
@ -26,15 +32,27 @@ class get_jreleaser {
|
|||
System.exit(1);
|
||||
}
|
||||
|
||||
var versionFile = Path.of("JRELEASER_VERSION");
|
||||
|
||||
var cachedVersion = "";
|
||||
if (Files.exists(versionFile)) {
|
||||
try {
|
||||
cachedVersion = Files.readString(versionFile).trim();
|
||||
} catch (IOException e) {
|
||||
System.out.printf("☠️ JReleaser %s could not be resolved%n", version);
|
||||
e.printStackTrace();
|
||||
System.exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
// resolve latest to a tagged release
|
||||
if ("latest".equalsIgnoreCase(version)) {
|
||||
var url = "https://jreleaser.org/releases/latest/download/VERSION";
|
||||
var file = Path.of("JRELEASER_VERSION");
|
||||
|
||||
try (var stream = new URL(url).openStream()) {
|
||||
System.out.printf("✅ Located version marker%n");
|
||||
Files.copy(stream, file, StandardCopyOption.REPLACE_EXISTING);
|
||||
version = new String(Files.readAllBytes(file)).trim();
|
||||
Files.copy(stream, versionFile, REPLACE_EXISTING);
|
||||
version = new String(Files.readAllBytes(versionFile)).trim();
|
||||
System.out.printf("✅ JReleaser latest resolves to %s%n", version);
|
||||
} catch (FileNotFoundException e) {
|
||||
System.out.printf("❌ JReleaser %s not found%n", version);
|
||||
|
@ -45,18 +63,32 @@ class get_jreleaser {
|
|||
e.printStackTrace();
|
||||
System.exit(1);
|
||||
}
|
||||
} else {
|
||||
try {
|
||||
Files.writeString(versionFile, version, CREATE, TRUNCATE_EXISTING, WRITE);
|
||||
} catch (IOException e) {
|
||||
System.out.printf("☠️ JReleaser %s could not be resolved%n", version);
|
||||
e.printStackTrace();
|
||||
System.exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
var jreleaserJar = Path.of("jreleaser-cli.jar");
|
||||
if (version.equals(cachedVersion) && Files.exists(jreleaserJar)) {
|
||||
// assume jreleaserJar has the expected version for now
|
||||
System.out.printf("✅ JReleaser %s already downloaded%n", version);
|
||||
System.exit(0);
|
||||
}
|
||||
|
||||
// setup the actual download
|
||||
var tag = !"early-access".equals(version) ? "v" + version : version;
|
||||
var url = "https://github.com/jreleaser/jreleaser/releases/download/" + tag + "/jreleaser-tool-provider-" + version + ".jar";
|
||||
var file = Path.of("jreleaser-cli.jar");
|
||||
|
||||
try (var stream = new URL(url).openStream()) {
|
||||
System.out.printf("✅ Located JReleaser %s%n", version);
|
||||
System.out.printf("⬇️ Downloading %s%n", url);
|
||||
var size = Files.copy(stream, file, StandardCopyOption.REPLACE_EXISTING);
|
||||
System.out.printf("%s << copied %d bytes%n", file, size);
|
||||
var size = Files.copy(stream, jreleaserJar, REPLACE_EXISTING);
|
||||
System.out.printf("%s << copied %d bytes%n", jreleaserJar, size);
|
||||
System.out.printf("✅ JReleaser installed successfully%n");
|
||||
} catch (FileNotFoundException e) {
|
||||
System.out.printf("❌ JReleaser %s not found%n", version);
|
||||
|
|
Loading…
Reference in a new issue