Compare commits

...

14 commits
v1 ... main

Author SHA1 Message Date
9df19435e9 „action.yml“ ändern
Some checks failed
Test / JReleaser ${{ matrix.tag }}, Java ${{ matrix.java }}, ${{ matrix.os }} (11, ubuntu-latest, early-access) (push) Failing after 5s
Test / JReleaser ${{ matrix.tag }}, Java ${{ matrix.java }}, ${{ matrix.os }} (11, macos-latest, early-access) (push) Has been cancelled
Test / JReleaser ${{ matrix.tag }}, Java ${{ matrix.java }}, ${{ matrix.os }} (11, windows-latest, early-access) (push) Has been cancelled
2023-05-28 09:18:59 +00:00
Andres Almiray
ab17acedd9
Check if matching version is already downloaded 2023-05-24 20:16:06 +02:00
Andres Almiray
f2226e009e
Revert to bash 2023-03-07 10:27:26 +01:00
Andres Almiray
2c142e07de
Refine boolean evaluation for setup-java. Fixes #10 2022-10-29 17:15:24 +02:00
Andres Almiray
8b970bcd10
Update readme instructions 2022-10-27 11:44:26 +02:00
Andres Almiray
3bef4586af
Update setup-java to v3. Fixes #9 2022-10-27 11:41:38 +02:00
Andres Almiray
9d00b8a3e3
Add java-opts argument. Fixes #8 2022-06-21 17:32:17 +02:00
Andres Almiray
77fb95c777
Remove thruthy check for setup-java. Fixes #7 2022-04-17 18:39:16 -05:00
Andres Almiray
7848b6eb87
Remove shell configuration 2022-02-02 22:41:01 +01:00
Andres Almiray
2848f4bf5e
Use powershell by default 2022-02-02 22:34:56 +01:00
Andres Almiray
4405eb1113
Format GH workflow 2022-02-02 21:12:52 +01:00
Andres Almiray
7feb30071b
Make running shell configurable 2022-02-02 19:33:02 +01:00
Andres Almiray
f4b19f681f
Autoconfigure a Java runtime 2022-01-02 18:57:49 +01:00
Max Rydahl Andersen
1be32a4768 make get_jreleaser just work with jbang
By adding //JAVA 11 you can just do `jbang git.io/get-jreleaser`
2021-12-08 11:27:55 +01:00
4 changed files with 93 additions and 34 deletions

View file

@ -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

View file

@ -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 }}

View file

@ -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 }}

View file

@ -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);