Skip to content

Commit 2f0a736

Browse files
authored
Adding ruby and multiple regex validations for module version
1 parent 30270be commit 2f0a736

File tree

1 file changed

+6
-7
lines changed

1 file changed

+6
-7
lines changed

.github/workflows/module_release.yml

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,11 @@ jobs:
1414

1515
steps:
1616

17+
- name: "Set up Ruby"
18+
uses: "actions/setup-ruby@v1"
19+
with:
20+
ruby-version: "3.1"
21+
1722
- name: "Checkout"
1823
uses: "actions/checkout@v4"
1924
with:
@@ -24,13 +29,7 @@ jobs:
2429
- name: "Get version"
2530
id: "get_version"
2631
run: |
27-
version=$(jq --raw-output '.version | gsub("[^0-9.]"; "")' metadata.json)
28-
if [ -z "$version" ]; then
29-
echo "Version is empty. Exiting workflow."
30-
failure "Failed to retrieve version from metadata.json"
31-
else
32-
echo "version=$version" >> $GITHUB_OUTPUT
33-
fi
32+
ruby -e 'require "json"; version = JSON.parse(File.read("metadata.json"))["version"]; semver_regex = /\A(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-([0-9A-Za-z-]+(?:\.[0-9A-Za-z-]+)*))?(?:\+([0-9A-Za-z-]+(?:\.[0-9A-Za-z-]+)*))?\z/; if version&.match?(semver_regex); puts "version=#{version}"; else; raise "Version #{version} is invalid. Exiting workflow."; end' >> $GITHUB_OUTPUT
3433
3534
- name: "PDK build"
3635
uses: "docker://puppet/pdk:nightly"

0 commit comments

Comments
 (0)