File tree Expand file tree Collapse file tree 1 file changed +21
-1
lines changed Expand file tree Collapse file tree 1 file changed +21
-1
lines changed Original file line number Diff line number Diff line change 14
14
15
15
steps :
16
16
17
+ - name : " Set up Ruby"
18
+ uses : " actions/setup-ruby@v1"
19
+ with :
20
+ ruby-version : " 3.1"
21
+
17
22
- name : " Checkout"
18
23
uses : " actions/checkout@v4"
19
24
with :
24
29
- name : " Get version"
25
30
id : " get_version"
26
31
run : |
27
- echo "version=$(jq --raw-output .version metadata.json)" >> $GITHUB_OUTPUT
32
+ ruby <<-EOF >> $GITHUB_OUTPUT
33
+ require "json"
34
+ version = JSON.parse(File.read("metadata.json"))["version"]
35
+
36
+ # from https://github.com/voxpupuli/metadata-json-lint/blob/b5e68049c6be58aa63263357bb0dcad8635a6829/lib/metadata-json-lint/schema.rb#L141-L150
37
+ numeric = '(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)' # Major . Minor . Patch
38
+ pre = '(?:-([0-9A-Za-z-]+(?:\.[0-9A-Za-z-]+)*))?' # Prerelease
39
+ build = '(?:\+([0-9A-Za-z-]+(?:\.[0-9A-Za-z-]+)*))?' # Build
40
+ full = numeric + pre + build
41
+ semver_regex = /\A#{full}\Z/
42
+ if version&.match?(semver_regex)
43
+ puts "version=#{version}"
44
+ else
45
+ raise "Version #{version} is invalid. Exiting workflow."
46
+ end
47
+ EOF
28
48
29
49
- name : " PDK build"
30
50
uses : " docker://puppet/pdk:nightly"
You can’t perform that action at this time.
0 commit comments