Skip to content

Commit 2cd956c

Browse files
feat: Create action.yml
1 parent 186ec68 commit 2cd956c

1 file changed

Lines changed: 94 additions & 0 deletions

File tree

action.yml

Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
name: 'Setup Jython'
2+
description: 'Installs Jython using the provided version'
3+
4+
inputs:
5+
jython-version:
6+
description: 'The version of Jython to use'
7+
required: true
8+
default: '2.7.2'
9+
10+
outputs:
11+
jython-download-url:
12+
description: "Random number"
13+
value: ${{ steps.jython_installer_url.outputs.download_url }}
14+
15+
runs:
16+
using: "composite"
17+
steps:
18+
- name: Set up JDK 8
19+
uses: actions/setup-java@v3
20+
with:
21+
java-version: '8'
22+
distribution: 'temurin'
23+
24+
- name: Determine Jython installer URL
25+
shell: bash
26+
id: jython_installer_url
27+
run: |
28+
url_maven="https://repo1.maven.org/maven2/org/python/jython-installer/${{ inputs.jython-version }}/jython-installer-${{ inputs.jython-version }}.jar";
29+
url_sourceforge="https://master.dl.sourceforge.net/project/jython/jython/${{ inputs.jython-version }}/jython_installer-${{ inputs.jython-version }}.jar?viasf=1";
30+
31+
printf "Testing:\n"
32+
printf -- "- Maven : %s\n" "${url_maven}";
33+
printf -- "- SourceForge: %s\n" "${url_sourceforge}";
34+
35+
maven_headers="$(curl -sIL "${url_maven}")";
36+
37+
if echo "${maven_headers}" | grep -qE "HTTP/([0-9.]+) 200 (OK)?"; then
38+
download_url="${url_maven}";
39+
else
40+
download_url="${url_sourceforge}";
41+
fi
42+
43+
echo "Download URL: ${download_url}"
44+
echo "::set-output name=download_url::${download_url}"
45+
46+
- name: Download Jython Installer
47+
shell: bash
48+
run: |
49+
curl -sL "${{ steps.jython_installer_url.outputs.download_url }}" --output /tmp/jython_installer.jar;
50+
51+
- name: Install Jython
52+
shell: bash
53+
run: |
54+
# Installation types:
55+
# - all : everything (including src)
56+
# - standard : core, mod, demo, doc, ensurepip
57+
# standard is the default
58+
# - minimum : core
59+
# - standalone: install a single, executable .jar,
60+
# containing all the modules
61+
#
62+
# Note - standalone installation may fail with the following stacktrace (tested on 2.7.2):1
63+
# org.python.util.install.InstallerException: Error accessing jar file
64+
# at org.python.util.install.JarInstaller.inflate(JarInstaller.java:177)
65+
# at org.python.util.install.ConsoleInstaller.install(ConsoleInstaller.java:66)
66+
# at org.python.util.install.Installation.internalMain(Installation.java:389)
67+
# at org.python.util.install.Installation.main(Installation.java:43)
68+
# Caused by: java.util.zip.ZipException: duplicate entry: module-info.class
69+
# at java.util.zip.ZipOutputStream.putNextEntry(ZipOutputStream.java:232)
70+
# at java.util.jar.JarOutputStream.putNextEntry(JarOutputStream.java:109)
71+
# at org.python.util.install.StandalonePackager.addJarFile(StandalonePackager.java:92)
72+
# at org.python.util.install.JarInstaller.inflate(JarInstaller.java:163)
73+
# ... 3 more
74+
75+
# This is why I use the standard installation
76+
# java -jar /tmp/jython_installer.jar \
77+
# --silent \
78+
# --directory ~/jython/ \
79+
# --type standalone;
80+
81+
java -jar /tmp/jython_installer.jar \
82+
--silent \
83+
--directory ~/jython/ \
84+
--type standard;
85+
86+
echo "::set-output name=download_url::${download_url}"
87+
88+
- name: Setup Jython alias
89+
shell: bash
90+
run: |
91+
mkdir -p ~/.local/bin;
92+
echo 'java -jar ~/jython/jython.jar "$@"' >> ~/.local/bin/jython;
93+
chmod +x ~/.local/bin/jython;
94+
echo ~/.local/bin >> $GITHUB_PATH

0 commit comments

Comments
 (0)