1- name : " Publish module "
1+ name : " Module Release "
22
33on :
4- workflow_dispatch :
5-
4+ workflow_call :
5+
66jobs :
7- create-github-release :
8- name : Deploy GitHub Release
9- runs-on : ubuntu-20.04
7+ release :
8+ name : " Release"
9+ runs-on : " ubuntu-latest"
10+
1011 steps :
11- - name : Checkout code
12- uses : actions/checkout@v2
12+
13+ - name : " Set up Ruby"
14+ uses : " ruby/setup-ruby@v1"
15+ with :
16+ ruby-version : " 3.1"
17+
18+ - name : " Checkout"
19+ uses : " actions/checkout@v4"
1320 with :
14- ref : ${{ github.ref }}
21+ ref : " ${{ github.ref }}"
1522 clean : true
1623 fetch-depth : 0
17- - name : Get Version
18- id : gv
24+
25+ - name : " Get version"
26+ id : " get_version"
1927 run : |
20- echo "::set-output name=ver::$(jq --raw-output .version metadata.json)"
21- - name : Create Release
22- uses : actions/create-release@v1
23- id : create_release
28+ ruby <<-EOF >> $GITHUB_OUTPUT
29+ require "json"
30+ version = JSON.parse(File.read("metadata.json"))["version"]
31+
32+ # from https://github.com/voxpupuli/metadata-json-lint/blob/b5e68049c6be58aa63263357bb0dcad8635a6829/lib/metadata-json-lint/schema.rb#L141-L150
33+ numeric = '(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)' # Major . Minor . Patch
34+ pre = '(?:-([0-9A-Za-z-]+(?:\.[0-9A-Za-z-]+)*))?' # Prerelease
35+ build = '(?:\+([0-9A-Za-z-]+(?:\.[0-9A-Za-z-]+)*))?' # Build
36+ full = numeric + pre + build
37+ semver_regex = /\A#{full}\Z/
38+ if version&.match?(semver_regex)
39+ puts "version=#{version}"
40+ else
41+ raise "Version #{version} is invalid. Exiting workflow."
42+ end
43+ EOF
44+
45+ - name : " PDK build"
46+ uses : " docker://puppet/pdk:nightly"
47+ with :
48+ args : " build"
49+
50+ - name : " Generate release notes"
51+ run : |
52+ export GH_HOST=github.com
53+ gh extension install chelnak/gh-changelog
54+ gh changelog get --latest > OUTPUT.md
55+ env :
56+ GH_TOKEN : ${{ secrets.GITHUB_TOKEN }}
57+
58+ - name : " Create release"
59+ run : |
60+ gh release create v${{ steps.get_version.outputs.version }} --title v${{ steps.get_version.outputs.version }} -F OUTPUT.md
2461 env :
2562 GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
26- with :
27- tag_name : " v${{ steps.gv.outputs.ver }}"
28- draft : false
29- prerelease : false
3063
31- deploy-forge :
32- name : Deploy to Forge
33- runs-on : ubuntu-20.04
34- steps :
35- - name : Checkout code
36- uses : actions/checkout@v2
37- with :
38- ref : ${{ github.ref }}
39- clean : true
40- - name : " PDK Build"
41- uses : docker://puppet/pdk:nightly
42- with :
43- args : ' build'
44- - name : " Push to Forge"
45- uses : docker://puppet/pdk:nightly
64+ - name : " Publish module"
65+ uses : " docker://puppet/pdk:nightly"
4666 with :
47- args : ' release publish --forge-token ${{ secrets.FORGE_API_KEY }} --force'
67+ args : ' release publish --forge-token ${{ secrets.FORGE_API_KEY }} --force'
0 commit comments