You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Fields like java-version aren't processing shell environment variables. Consequently, establishing a primary source of truth for version numbers involves quite elaborate boilerplate, especially when reusing version numbers across multiple workflows.
Task version:
4
Platform:
Tested on Ubuntu, likely happens on the others as well.
A rube goldberg involving expressions and outputs can succeed, but it results in code that's harder to read and write.
Ideally, the field updates to account for shell variables.
This needs to be done in a platform agnostic way. We can reasonably support at least POSIX shell syntax, Command Prompt, and PowerShell. We may constrain the POSIX variable expansion syntax to at most $VAR and ${VAR}, with no default values or substitutions, for simplicity.
The text was updated successfully, but these errors were encountered:
To ensure that the JAVA_VERSION environment variable is properly set and used across different steps in the workflow, you need to:
Source the tools.sh script in the workflow to set the JAVA_VERSION variable in the shell running the actions.
Export the JAVA_VERSION variable to $GITHUB_ENV. Since each step in GitHub Actions runs in a separate shell, environment variables need to be explicitly exported using $GITHUB_ENV to persist across steps within the same job.
By appending to $GITHUB_ENV, the JAVA_VERSION variable becomes available throughout the entire job. Without this step, the variable would only be accessible within the scope of the first run block (the script sourcing), and subsequent steps wouldn't have access to it.
Here’s how you can modify your workflow:
- name: Set up Java version
run: |
# Source tools.sh to set the JAVA_VERSION environment variable
source .github/workflows/tools.sh
# Export JAVA_VERSION to $GITHUB_ENV to persist it across subsequent steps
echo ""JAVA_VERSION=$JAVA_VERSION"" >> $GITHUB_ENV
- name: Set up Java using the exported JAVA_VERSION
uses: ""actions/setup-java@v4""
with:
distribution: ""corretto""
java-version: ""${{ env.JAVA_VERSION }}"" # Use the JAVA_VERSION from $GITHUB_ENV
Description:
Fields like
java-version
aren't processing shell environment variables. Consequently, establishing a primary source of truth for version numbers involves quite elaborate boilerplate, especially when reusing version numbers across multiple workflows.Task version:
4
Platform:
Tested on Ubuntu, likely happens on the others as well.
Runner type:
Repro steps:
Expected behavior:
java-version
populates with a value of17
, based on aJAVA_VERSION='17'
command in a reusabletools.sh
script.Actual behavior:
setup-java treats
$JAVA_VERSION
as a string literal.Workaround
tools.txt:
build.yaml:
A rube goldberg involving expressions and outputs can succeed, but it results in code that's harder to read and write.
Ideally, the field updates to account for shell variables.
This needs to be done in a platform agnostic way. We can reasonably support at least POSIX shell syntax, Command Prompt, and PowerShell. We may constrain the POSIX variable expansion syntax to at most
$VAR
and${VAR}
, with no default values or substitutions, for simplicity.The text was updated successfully, but these errors were encountered: