Skip to content

Commit

Permalink
feat: Create action.yml
Browse files Browse the repository at this point in the history
  • Loading branch information
LukeSavefrogs authored May 18, 2023
1 parent 186ec68 commit 2cd956c
Showing 1 changed file with 94 additions and 0 deletions.
94 changes: 94 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
name: 'Setup Jython'
description: 'Installs Jython using the provided version'

inputs:
jython-version:
description: 'The version of Jython to use'
required: true
default: '2.7.2'

outputs:
jython-download-url:
description: "Random number"
value: ${{ steps.jython_installer_url.outputs.download_url }}

runs:
using: "composite"
steps:
- name: Set up JDK 8
uses: actions/setup-java@v3
with:
java-version: '8'
distribution: 'temurin'

- name: Determine Jython installer URL
shell: bash
id: jython_installer_url
run: |
url_maven="https://repo1.maven.org/maven2/org/python/jython-installer/${{ inputs.jython-version }}/jython-installer-${{ inputs.jython-version }}.jar";
url_sourceforge="https://master.dl.sourceforge.net/project/jython/jython/${{ inputs.jython-version }}/jython_installer-${{ inputs.jython-version }}.jar?viasf=1";
printf "Testing:\n"
printf -- "- Maven : %s\n" "${url_maven}";
printf -- "- SourceForge: %s\n" "${url_sourceforge}";
maven_headers="$(curl -sIL "${url_maven}")";
if echo "${maven_headers}" | grep -qE "HTTP/([0-9.]+) 200 (OK)?"; then
download_url="${url_maven}";
else
download_url="${url_sourceforge}";
fi
echo "Download URL: ${download_url}"
echo "::set-output name=download_url::${download_url}"
- name: Download Jython Installer
shell: bash
run: |
curl -sL "${{ steps.jython_installer_url.outputs.download_url }}" --output /tmp/jython_installer.jar;
- name: Install Jython
shell: bash
run: |
# Installation types:
# - all : everything (including src)
# - standard : core, mod, demo, doc, ensurepip
# standard is the default
# - minimum : core
# - standalone: install a single, executable .jar,
# containing all the modules
#
# Note - standalone installation may fail with the following stacktrace (tested on 2.7.2):1
# org.python.util.install.InstallerException: Error accessing jar file
# at org.python.util.install.JarInstaller.inflate(JarInstaller.java:177)
# at org.python.util.install.ConsoleInstaller.install(ConsoleInstaller.java:66)
# at org.python.util.install.Installation.internalMain(Installation.java:389)
# at org.python.util.install.Installation.main(Installation.java:43)
# Caused by: java.util.zip.ZipException: duplicate entry: module-info.class
# at java.util.zip.ZipOutputStream.putNextEntry(ZipOutputStream.java:232)
# at java.util.jar.JarOutputStream.putNextEntry(JarOutputStream.java:109)
# at org.python.util.install.StandalonePackager.addJarFile(StandalonePackager.java:92)
# at org.python.util.install.JarInstaller.inflate(JarInstaller.java:163)
# ... 3 more
# This is why I use the standard installation
# java -jar /tmp/jython_installer.jar \
# --silent \
# --directory ~/jython/ \
# --type standalone;
java -jar /tmp/jython_installer.jar \
--silent \
--directory ~/jython/ \
--type standard;
echo "::set-output name=download_url::${download_url}"
- name: Setup Jython alias
shell: bash
run: |
mkdir -p ~/.local/bin;
echo 'java -jar ~/jython/jython.jar "$@"' >> ~/.local/bin/jython;
chmod +x ~/.local/bin/jython;
echo ~/.local/bin >> $GITHUB_PATH

0 comments on commit 2cd956c

Please sign in to comment.