oracle-actions / setup-java

GitHub Action to download and install Oracle's Java Development Kit builds
Universal Permissive License v1.0
62 stars 11 forks source link

Update to use GitHub's environment files #43

Closed sormuras closed 1 year ago

sormuras commented 1 year ago

https://github.com/oracle-actions/setup-java/blob/2e3562c72585cd036e42706589f272ed8d08f24d/src/Download.java#L221

Action and workflow authors who are using save-state or set-output via stdout should update to use the new environment files.

https://github.blog/changelog/2022-10-11-github-actions-deprecating-save-state-and-set-output-commands/

derlin commented 1 year ago

Are you suggesting to modify this line with the following ?

System.out.printf("echo \"%s=%s\" >> $GITHUB_OUTPUT%n", name, value); 

Or do you see other changes that are necessary ?

(I am interested in taking this issue)

sormuras commented 1 year ago

Yes, as far as I can tell, it's the only line that requires a change: image

Your proposed change woudn't work on Windows (cmd.exe nor PowerShell), would it? Perhaps using NIO's Files.write[String]() is platform-agnostic solution. Something like:

var output = Path.of(System.env...);
Files.write(
    output,
    List.of(name + "=" + value),
    StandardCharsets.UTF_8,
    StandardOpenOption.CREATE,
    StandardOpenOption.APPEND,
    StandardOpenOption.WRITE);

Before you hack away and create a pull request, I first need to clarify whether and how contributions can be submitted.

sormuras commented 1 year ago

Starting today runner version 2.298.2 will begin to warn you if you use the save-state or set-output commands via stdout.

Warnings are now in place.

image

sormuras commented 1 year ago

@derlin I am taking care of this issue because I want to get rid of the warnings as soon as possible. That's why I removed the good first issue label and filed:

sormuras commented 1 year ago

Outputs are empty?!

image

sormuras commented 1 year ago

Fixed by https://github.com/oracle-actions/setup-java/commit/e81158a0e3112b4b04c18bbdcd2b276a6df82436