Skip to content

Commit

Permalink
Adding check for version from metadata.json
Browse files Browse the repository at this point in the history
  • Loading branch information
malikparvez committed Jun 18, 2024
1 parent 25a7fb2 commit f2c6dff
Showing 1 changed file with 21 additions and 1 deletion.
22 changes: 21 additions & 1 deletion .github/workflows/module_release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,11 @@ jobs:

steps:

- name: "Set up Ruby"
uses: "actions/setup-ruby@v1"
with:
ruby-version: "3.1"

- name: "Checkout"
uses: "actions/checkout@v4"
with:
Expand All @@ -24,7 +29,22 @@ jobs:
- name: "Get version"
id: "get_version"
run: |
echo "version=$(jq --raw-output .version metadata.json)" >> $GITHUB_OUTPUT
ruby <<-EOF >> $GITHUB_OUTPUT
require "json"
version = JSON.parse(File.read("metadata.json"))["version"]
# from https://github.com/voxpupuli/metadata-json-lint/blob/b5e68049c6be58aa63263357bb0dcad8635a6829/lib/metadata-json-lint/schema.rb#L141-L150
numeric = '(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)' # Major . Minor . Patch
pre = '(?:-([0-9A-Za-z-]+(?:\.[0-9A-Za-z-]+)*))?' # Prerelease
build = '(?:\+([0-9A-Za-z-]+(?:\.[0-9A-Za-z-]+)*))?' # Build
full = numeric + pre + build
semver_regex = /\A#{full}\Z/
if version&.match?(semver_regex)
puts "version=#{version}"
else
raise "Version #{version} is invalid. Exiting workflow."
end
EOF
- name: "PDK build"
uses: "docker://puppet/pdk:nightly"
Expand Down

0 comments on commit f2c6dff

Please sign in to comment.