Skip to content

Commit

Permalink
Add perl (#5)
Browse files Browse the repository at this point in the history
  • Loading branch information
TGWolf committed Apr 20, 2023
1 parent 295ca9f commit 765f385
Show file tree
Hide file tree
Showing 3 changed files with 162 additions and 12 deletions.
117 changes: 117 additions & 0 deletions .github/workflows/test-action-perl.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,117 @@
name: Test action (Perl)

on:
push:
branches:
- '**'
pull_request:
branches:
- '**'

jobs:
test-output-method-setup:
name: min-version=5.34
runs-on: ubuntu-latest
outputs:
version-matrix: ${{ steps.get-versions.outputs.latest-versions }}
steps:
- name: Checkout the repository
uses: actions/checkout@v3
- name: Get versions
uses: ./
id: get-versions
with:
language: perl
min-version: "5.34"

test-output-method-load:
name: min-version=5.34
needs: test-output-method-setup
runs-on: ubuntu-latest
strategy:
matrix:
version-matrix: ${{fromJson(needs.test-output-method-setup.outputs.version-matrix)}}
steps:
- name: Setup Perl ${{ matrix.version-matrix }}
uses: shogo82148/actions-setup-perl@v1
with:
perl-version: ${{ matrix.version-matrix }}

test-output-method-setup-eol:
name: min-version=EOL
runs-on: ubuntu-latest
outputs:
version-matrix: ${{ steps.get-versions.outputs.latest-versions }}
steps:
- name: Checkout the repository
uses: actions/checkout@v3
- name: Get versions
uses: ./
id: get-versions
with:
language: perl

test-output-method-load-eol:
name: min-version=EOL
needs: test-output-method-setup-eol
runs-on: ubuntu-latest
strategy:
matrix:
version-matrix: ${{fromJson(needs.test-output-method-setup-eol.outputs.version-matrix)}}
steps:
- name: Setup Perl ${{ matrix.version-matrix }}
uses: shogo82148/actions-setup-perl@v1
with:
perl-version: ${{ matrix.version-matrix }}


test-output-method-setup-highest-only:
name: Highest version only
runs-on: ubuntu-latest
outputs:
highest-version: ${{ steps.get-versions.outputs.latest-versions }}
steps:
- name: Checkout the repository
uses: actions/checkout@v3
- name: Get versions
uses: ./
id: get-versions
with:
language: perl
highest-only: true

test-output-method-load-highest-only:
name: Build for highest version only
needs: test-output-method-setup-highest-only
runs-on: ubuntu-latest
steps:
- name: Setup Perl ${{ needs.test-output-method-setup-highest-only.outputs.highest-version }}
uses: shogo82148/actions-setup-perl@v1
with:
perl-version: ${{ needs.test-output-method-setup-highest-only.outputs.highest-version }}

test-output-method-setup-highest-only-patch-only:
name: Highest version only (Patch Only)
runs-on: ubuntu-latest
outputs:
highest-version: ${{ steps.get-versions.outputs.latest-versions }}
steps:
- name: Checkout the repository
uses: actions/checkout@v3
- name: Get versions
uses: ./
id: get-versions
with:
language: perl
highest-only: true
remove-patch-version: true

test-output-method-load-highest-only-patch-only:
name: Build for highest version only (Patch Only)
needs: test-output-method-setup-highest-only-patch-only
runs-on: ubuntu-latest
steps:
- name: Setup Perl ${{ needs.test-output-method-setup-highest-only-patch-only.outputs.highest-version }}
uses: shogo82148/actions-setup-perl@v1
with:
php-version: ${{ needs.test-output-method-setup-highest-only-patch-only.outputs.highest-version }}
17 changes: 9 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ This action will fetch up-to-date data on the latest version(s) available on Git
| ------------- |:---------------------------------------------------------------:|:--------------------------------------------------------------------------------------------------------:|
| Go | [setup-go](https://github.com/actions/setup-go) | [go-versions](https://github.com/raw/actions/go-versions/main/versions-manifest.json) |
| Node / NodeJS | [setup-node](https://github.com/actions/setup-node) | [node-versions](https://github.com/raw/actions/node-versions/main/versions-manifest.json) |
| Perl | [setup-perl](https://github.com/shogo82148/actions-setup-perl) | [perl-versions](https://github.com/raw/shogo82148/actions-setup-perl/main/versions/linux.json) |
| PHP | [setup-php](https://github.com/shivammathur/setup-php) | [php-versions](https://phpreleases.com/api/releases/) |
| Python | [setup-python](https://github.com/actions/setup-python) | [python-versions](https://github.com/raw/actions/python-versions/main/versions-manifest.json) |
| Ruby | [setup-ruby](https://github.com/ruby/setup-ruby) | [ruby-versions](https://github.com/raw/ruby/setup-ruby/master/ruby-builder-versions.json) |
Expand Down Expand Up @@ -71,14 +72,14 @@ ${{ steps.get-versions.outputs.latest-versions }}

## All Parameters

| Parameters | Required | Default | Options |
| -------------------- |:--------:| -------- | ----------------------------------------- |
| language | Yes | | Go, Node, PHP, Python, Ruby or Terraform. |
| min-version | No | "EOL" | semver, "EOL" or "ALL" |
| max-version | No | "latest" | semver or "latest" |
| include-prereleases | No | false | true or false |
| highest-only | No | false | true or false |
| remove-patch-version | No | false | true or false |
| Parameters | Required | Default | Options |
| -------------------- |:--------:| -------- | ----------------------------------------------- |
| language | Yes | | Go, Node, Perl, PHP, Python, Ruby or Terraform. |
| min-version | No | "EOL" | semver, "EOL" or "ALL" |
| max-version | No | "latest" | semver or "latest" |
| include-prereleases | No | false | true or false |
| highest-only | No | false | true or false |
| remove-patch-version | No | false | true or false |

See examples below for recommended usage.

Expand Down
40 changes: 36 additions & 4 deletions entrypoint.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,11 @@
1. Go
2. Node / NodeJS
3. PHP
4. Python
5. Ruby
3. Perl
4. PHP
5. Python
6. Ruby
7. Terraform
"""
import datetime
import json
Expand Down Expand Up @@ -39,6 +41,10 @@
"versions_url": 'https://github.com/raw/actions/node-versions/main/versions-manifest.json',
"eol_url": 'https://endoflife.date/api/nodejs.json'
},
"perl": {
"versions_url": 'https://github.com/raw/shogo82148/actions-setup-perl/main/versions/linux.json',
"eol_url": 'https://endoflife.date/api/perl.json'
},
"php": {
"versions_url": 'https://phpreleases.com/api/releases/',
"eol_url": 'https://endoflife.date/api/php.json'
Expand Down Expand Up @@ -242,6 +248,30 @@ def get_versions(stable_versions: dict) -> list:
return versions


def get_perl_versions(stable_versions: dict) -> list:
"""
Get versions from returned dataset.
Different version urls return the version data in different formats, this handles the data for Ruby only.
Arguments:
stable_versions (dict) -- The dataset returned from the versions-url.
Returns:
list -- A list containing JUST the version numbers.
"""
versions: list = []

for version in stable_versions:
try:
if semver.Version(version):
versions.append(version)
except semver.InvalidVersion:
continue

return versions


def get_php_versions(stable_versions: dict) -> list:
"""
Get versions from returned dataset.
Expand Down Expand Up @@ -382,7 +412,9 @@ def main(language: str,
else:
stable_versions: list = get_stable_versions(language)

if language.upper() == "PHP":
if language.upper() == "PERL":
versions: list = get_perl_versions(stable_versions)
elif language.upper() == "PHP":
versions: list = get_php_versions(stable_versions)
elif language.upper() == "RUBY":
versions = get_ruby_versions(stable_versions)
Expand Down

0 comments on commit 765f385

Please sign in to comment.