Compare commits

..

No commits in common. "main" and "v1" have entirely different histories.
main ... v1

4 changed files with 34 additions and 93 deletions

View file

@ -1,10 +1,9 @@
name: Test
on:
push:
workflow_dispatch:
on: push
jobs:
test:
name: 'JReleaser ${{ matrix.tag }}, Java ${{ matrix.java }}, ${{ matrix.os }}'
strategy:
@ -16,11 +15,10 @@ jobs:
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v2
- uses: actions/setup-java@v1
with:
java-version: ${{ matrix.java }}
- uses: ./
with:
arguments: --version
arguments: --version
- run: echo "Here be assertions and dragons..."

View file

@ -27,17 +27,16 @@ jobs:
steps:
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v2
with:
fetch-depth: 0
# Configure build steps as you'd normally do
- name: Setup Java
uses: actions/setup-java@v3
uses: actions/setup-java@v1
with:
java-version: 11
distribution: 'zulu'
java-version: 1.8
server-id: central
server-username: MAVEN_USERNAME
server-password: MAVEN_CENTRAL_TOKEN
@ -57,34 +56,29 @@ 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@v2
uses: jreleaser/release-action@v1
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. 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.
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.
== Customizing
@ -94,17 +88,14 @@ 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
@ -131,7 +122,7 @@ If you create a secret named `GH_PAT`, the step will look like this
[source,yaml]
----
- name: Run JReleaser
uses: jreleaser/release-action@v2
uses: jreleaser/release-action@v1
env:
JRELEASER_GITHUB_TOKEN: ${{ secrets.GH_PAT }}
----
@ -142,7 +133,7 @@ you may apply the `GH_PAT` token as follows
[source,yaml]
----
- name: Run JReleaser
uses: jreleaser/release-action@v2
uses: jreleaser/release-action@v1
env:
JRELEASER_GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
JRELEASER_HOMEBREW_GITHUB_TOKEN: ${{ secrets.GH_PAT }}

View file

@ -7,6 +7,7 @@ branding:
color: 'gray-dark'
inputs:
version:
description: 'The version of JReleaser to download and execute.'
default: 'latest'
@ -22,26 +23,9 @@ 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 }}
@ -56,4 +40,4 @@ runs:
working-directory: ${{ inputs.working-directory }}
run: |
echo "☕ java -jar jreleaser-cli.jar ${{ inputs.arguments }}"
java ${{ inputs.java-opts }} -jar jreleaser-cli.jar ${{ inputs.arguments }}
java -jar jreleaser-cli.jar ${{ inputs.arguments }}

View file

@ -1,15 +1,9 @@
//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 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;
import java.nio.file.StandardCopyOption;
class get_jreleaser {
public static void main(String... args) throws Exception {
@ -32,27 +26,15 @@ 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, versionFile, REPLACE_EXISTING);
version = new String(Files.readAllBytes(versionFile)).trim();
Files.copy(stream, file, StandardCopyOption.REPLACE_EXISTING);
version = new String(Files.readAllBytes(file)).trim();
System.out.printf("✅ JReleaser latest resolves to %s%n", version);
} catch (FileNotFoundException e) {
System.out.printf("❌ JReleaser %s not found%n", version);
@ -63,32 +45,18 @@ 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, jreleaserJar, REPLACE_EXISTING);
System.out.printf("%s << copied %d bytes%n", jreleaserJar, size);
var size = Files.copy(stream, file, StandardCopyOption.REPLACE_EXISTING);
System.out.printf("%s << copied %d bytes%n", file, size);
System.out.printf("✅ JReleaser installed successfully%n");
} catch (FileNotFoundException e) {
System.out.printf("❌ JReleaser %s not found%n", version);