Skip to content

Commit edf86e4

Browse files
authored
Merge pull request #11 from perl-actions/to-perl
Add the concept of to-perl
2 parents 1c4168b + 6084419 commit edf86e4

File tree

5 files changed

+45
-2
lines changed

5 files changed

+45
-2
lines changed

.github/workflows/check.yml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,20 @@ jobs:
4444
since-perl: 5.36
4545
with-devel: true
4646

47+
since-524-to-532:
48+
runs-on: ubuntu-latest
49+
name: 'since 5.24 to 5.32'
50+
outputs:
51+
perl-versions: ${{ steps.action.outputs.perl-versions }}
52+
steps:
53+
- uses: actions/checkout@v4
54+
- name: "uses perl-versions"
55+
id: action
56+
uses: ./
57+
with:
58+
since-perl: "5.24"
59+
to-perl: "5.32"
60+
4761
test-matrix:
4862
runs-on: ubuntu-latest
4963
needs:
@@ -75,6 +89,7 @@ jobs:
7589
- since-v520
7690
- since-520
7791
- since-536-with-devel
92+
- since-524-to-532
7893
runs-on: ubuntu-latest
7994
steps:
8095

@@ -89,3 +104,7 @@ jobs:
89104
- name: "Testing since-536-with-devel"
90105
run: |
91106
[[ '${{ needs.since-536-with-devel.outputs.perl-versions }}' == '["5.36","5.38","5.40","5.42","devel"]' ]] && echo "ok"
107+
108+
- name: "Testing since-524-to-532"
109+
run: |
110+
[[ '${{ needs.since-524-to-532.outputs.perl-versions }}' == '["5.24","5.26","5.28","5.30","5.32"]' ]] && echo "ok"

README.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,15 @@ Returns perl versions since this (including).
1616

1717
When unknown version is provided, returns empty list.
1818

19+
### to-perl
20+
21+
Optional parameter.
22+
23+
When set, returns perl versions up to this version (including this version).
24+
Can be combined with `since-perl` to get a specific range of versions.
25+
26+
When not set, returns all versions from `since-perl` onwards.
27+
1928
### with-devel
2029

2130
Default: `false`
@@ -37,6 +46,7 @@ jobs:
3746
uses: perl-actions/perl-versions@v1
3847
with:
3948
since-perl: v5.20
49+
to-perl: v5.36
4050
with-devel: false
4151

4252
##

action.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,10 @@ inputs:
55
description: "List all Perl versions since this (including this). Example: 5.10"
66
type: string
77
required: true
8+
to-perl:
9+
description: "List all Perl versions up to this (including this). Example: 5.30"
10+
type: string
11+
required: false
812
with-devel:
913
description: "Whether to include also 'devel' Perl"
1014
type: boolean

dist/index.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30267,14 +30267,19 @@ let available = [
3026730267

3026830268
try {
3026930269
const since_perl = semver.coerce(core.getInput('since-perl'));
30270+
const to_perl_input = core.getInput('to-perl');
30271+
const to_perl = to_perl_input ? semver.coerce(to_perl_input) : null;
3027030272
const with_devel = core.getInput('with-devel') == "true";
3027130273

3027230274
let filtered = available.filter(
3027330275
(item) => {
3027430276
if (item == "devel") {
3027530277
return with_devel;
3027630278
}
30277-
return semver.gte(semver.coerce(item), since_perl);
30279+
const version = semver.coerce(item);
30280+
const meetsLowerBound = semver.gte(version, since_perl);
30281+
const meetsUpperBound = !to_perl || semver.lte(version, to_perl);
30282+
return meetsLowerBound && meetsUpperBound;
3027830283
}
3027930284
);
3028030285

index.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,19 @@ let available = [
1212

1313
try {
1414
const since_perl = semver.coerce(core.getInput('since-perl'));
15+
const to_perl_input = core.getInput('to-perl');
16+
const to_perl = to_perl_input ? semver.coerce(to_perl_input) : null;
1517
const with_devel = core.getInput('with-devel') == "true";
1618

1719
let filtered = available.filter(
1820
(item) => {
1921
if (item == "devel") {
2022
return with_devel;
2123
}
22-
return semver.gte(semver.coerce(item), since_perl);
24+
const version = semver.coerce(item);
25+
const meetsLowerBound = semver.gte(version, since_perl);
26+
const meetsUpperBound = !to_perl || semver.lte(version, to_perl);
27+
return meetsLowerBound && meetsUpperBound;
2328
}
2429
);
2530

0 commit comments

Comments
 (0)