88 repository_dispatch :
99 types :
1010 - webhook
11- env :
12- library_last_version : 0.0.0
13- template_last_version : 0.0.0
14- template_current_version : 0.0.0
15- document_last_version : 0.0.0
16- document_current_version : 0.0.0
17- major_template_last_version : 0
18- minor_template_last_version : 0
19- patch_template_last_version : 0
20- major_template_current_version : 0
21- minor_template_current_version : 0
22- patch_template_current_version : 0
23- major_version_change : false
24- minor_version_change : false
25- patch_version_change : false
26- commit_message : " "
2711jobs :
28- get-template-version :
12+ auto-update- :
2913 runs-on : ubuntu-latest
3014 steps :
31- - name : Get utility library
32- uses : actions/checkout@v2
15+ - uses : actions/checkout@v3
16+
17+ - uses : actions/setup-node@v3
3318 with :
34- repository : tyleradams/json-toolkit
35- path : " ./tooling"
36- - name : Install and build utility tools
37- run : cd ./tooling && make && sudo make install && cd ..
38- - uses : actions/checkout@v2
39- # Find all relevant semver versions needed to figure out how to update the client
40- - name : Fetch the last AsyncAPI document version that generated the client
41- run : echo "document_last_version=$(cat ./configs.json | jq -r '.document_last_version')" >> $GITHUB_ENV
42- - name : Fetch the last template version that generated the client
43- run : echo "template_last_version=$(cat ./configs.json | jq -r '.template_last_version')" >> $GITHUB_ENV
44- - name : Fetch the last library version
45- run : echo "library_last_version=$(cat ./AsyncapiNatsClient/AsyncapiNatsClient.csproj | xml-to-json | jq -r '.Project.PropertyGroup.Version')" >> $GITHUB_ENV
46- - name : Fetch current template version
47- run : echo "template_current_version=$(curl -sL https://api.github.com/repos/asyncapi/dotnet-nats-template/releases/latest | jq -r '.tag_name' | sed 's/v//')" >> $GITHUB_ENV
48- - name : Get all the application AsyncAPI documents
49- uses : actions/checkout@v2
50- with :
51- repository : GamingAPI/definitions
52- path : " ./definitions"
53- - name : Get the version of the API
54- run : echo "document_current_version=$(cat ./definitions/bundled/rust.asyncapi.json | jq -r '.info.version' | sed 's/v//')" >> $GITHUB_ENV
19+ node-version : ' 14'
5520
56- # Figure out how the template version have changed
57- - run : semver_template_last_version=( ${template_last_version//./ } ) && major_template_last_version=${semver_template_last_version[0]} && echo "major_template_last_version=$major_template_last_version" >> $GITHUB_ENV
58- - run : semver_template_last_version=( ${template_last_version//./ } ) && minor_template_last_version=${semver_template_last_version[1]} && echo "minor_template_last_version=$minor_template_last_version" >> $GITHUB_ENV
59- - run : semver_template_last_version=( ${template_last_version//./ } ) && patch_template_last_version=${semver_template_last_version[2]} && echo "patch_template_last_version=$patch_template_last_version" >> $GITHUB_ENV
60- - run : semver_template_current_version=( ${template_current_version//./ } ) && major_template_current_version=${semver_template_current_version[0]} && echo "major_template_current_version=$major_template_current_version" >> $GITHUB_ENV
61- - run : semver_template_current_version=( ${template_current_version//./ } ) && minor_template_current_version=${semver_template_current_version[1]} && echo "minor_template_current_version=$minor_template_current_version" >> $GITHUB_ENV
62- - run : semver_template_current_version=( ${template_current_version//./ } ) && patch_template_current_version=${semver_template_current_version[2]} && echo "patch_template_current_version=$patch_template_current_version" >> $GITHUB_ENV
63- - if : ${{ env.major_template_current_version > env.major_template_last_version }}
64- run : echo "major_version_change=true" >> $GITHUB_ENV && echo "commit_message=${commit_message}Template have changed to a new major version." >> $GITHUB_ENV
65- - if : ${{ env.minor_template_current_version > env.minor_template_last_version }}
66- run : echo "minor_version_change=true" >> $GITHUB_ENV && echo "commit_message=${commit_message}Template have changed to a new minor version." >> $GITHUB_ENV
67- - if : ${{ env.patch_template_current_version > env.patch_template_last_version }}
68- run : echo "patch_version_change=true" >> $GITHUB_ENV && echo "commit_message=${commit_message}Template have changed to a new patch version." >> $GITHUB_ENV
69-
70- # Figure out how the AsyncAPI document have changed
71- - run : semver_document_last_version=( ${document_last_version//./ } ) && major_document_last_version=${semver_document_last_version[0]} && echo "major_document_last_version=$major_document_last_version" >> $GITHUB_ENV
72- - run : semver_document_last_version=( ${document_last_version//./ } ) && minor_document_last_version=${semver_document_last_version[1]} && echo "minor_document_last_version=$minor_document_last_version" >> $GITHUB_ENV
73- - run : semver_document_last_version=( ${document_last_version//./ } ) && patch_document_last_version=${semver_document_last_version[2]} && echo "patch_document_last_version=$patch_document_last_version" >> $GITHUB_ENV
74- - run : semver_document_current_version=( ${document_current_version//./ } ) && major_document_current_version=${semver_document_current_version[0]} && echo "major_document_current_version=$major_document_current_version" >> $GITHUB_ENV
75- - run : semver_document_current_version=( ${document_current_version//./ } ) && minor_document_current_version=${semver_document_current_version[1]} && echo "minor_document_current_version=$minor_document_current_version" >> $GITHUB_ENV
76- - run : semver_document_current_version=( ${document_current_version//./ } ) && patch_document_current_version=${semver_document_current_version[2]} && echo "patch_document_current_version=$patch_document_current_version" >> $GITHUB_ENV
77- - if : ${{ env.major_document_current_version > env.major_document_last_version }}
78- run : echo "major_version_change=true" >> $GITHUB_ENV && echo "commit_message=${commit_message}AsyncAPI document have changed to a new major version. " >> $GITHUB_ENV
79- - if : ${{ env.minor_document_current_version > env.minor_document_last_version && env.major_document_current_version < env.major_document_last_version }}
80- run : echo "minor_version_change=true" >> $GITHUB_ENV && echo "commit_message=${commit_message}AsyncAPI document have changed to a new minor version. " >> $GITHUB_ENV
81- - if : ${{ env.patch_document_current_version > env.patch_document_last_version && env.minor_document_current_version < env.minor_document_last_version && env.major_document_current_version < env.major_document_last_version }}
82- run : echo "patch_version_change=true" >> $GITHUB_ENV && echo "commit_message=${commit_message}AsyncAPI document have changed to a new patch template version. " >> $GITHUB_ENV
21+ - name : Generate code
22+ run : chmod +x ./generate.sh && ./generate.sh
8323
84- # Make changes to the code if needed
85- - name : Remove previous files to ensure clean slate
86- if : ${{env.major_version_change == 'true' || env.minor_version_change == 'true' || env.patch_version_change == 'true'}}
87- run : find . -not \( -name configs.json -or -name .gitignore -or -iwholename *.github* -or -iwholename *./definitions* -or -iwholename *.git* -or -name . \) -exec echo {} +
88- - name : Generating code from the AsyncAPI document
89- if : ${{env.major_version_change == 'true' || env.minor_version_change == 'true' || env.patch_version_change == 'true'}}
90- uses : docker://asyncapi/github-action-for-generator
24+ - name : Set Environment Variables from generator file
25+ uses : ./.github/actions/setvars
9126 with :
92- template : ' @asyncapi/dotnet-nats-template'
93- filepath : ./definitions/bundled/rust.asyncapi.json
94- output : ./
95- parameters : " version=${{env.library_last_version}}"
96- - name : Write new config file to ensure we keep the new state for next time
97- if : ${{env.major_version_change == 'true' || env.minor_version_change == 'true' || env.patch_version_change == 'true'}}
98- run : |
99- contents="$(jq ".template_last_version = \"$template_current_version\" | .document_last_version = \"$document_current_version\"" configs.json)" && echo "${contents}" > configs.json
100-
101- # Clean up from code generation
102- - name : Remove excess files
103- if : ${{env.major_version_change == 'true' || env.minor_version_change == 'true' || env.patch_version_change == 'true'}}
104- run : rm -rf ./definitions && rm -rf ./tooling
105-
27+ varFilePath : ./.github/variables/generator.env
10628 # Follow conventional commit for PR's to ensure accurate updates
10729 - name : Create pull request for major version if needed
10830 if : ${{env.major_version_change == 'true'}}
109- uses : peter-evans/create-pull-request@v3
31+ uses : peter-evans/create-pull-request@v4
11032 with :
11133 title : " feat!: major version change"
112- committer : GamingEventapiBot <gamingeventapi@gmail.com>
113- author : GamingEventapiBot <gamingeventapi@gmail.com>
114- delete-branch : true
115- commit-message : ${{env.commit_message}}. Library require a new major version change.
116- body : ${{env.commit_message}}. Library require a new major version change.
34+
11735 - name : Create pull request for minor version if needed
118- if : ${{env.major_version_change == 'false' && env. minor_version_change == 'true'}}
119- uses : peter-evans/create-pull-request@v3
36+ if : ${{env.minor_version_change == 'true'}}
37+ uses : peter-evans/create-pull-request@v4
12038 with :
12139 title : " feat: minor version change"
122- committer : GamingEventapiBot <gamingeventapi@gmail.com>
123- author : GamingEventapiBot <gamingeventapi@gmail.com>
124- delete-branch : true
125- commit-message : ${{env.commit_message}}. Library require a new minor version change.
126- body : ${{env.commit_message}}. Library require a new minor version change.
40+
12741 - name : Create pull request for patch version if needed
128- if : ${{env.major_version_change == 'false' && env.minor_version_change == 'false' && env. patch_version_change == 'true'}}
129- uses : peter-evans/create-pull-request@v3
42+ if : ${{env.patch_version_change == 'true'}}
43+ uses : peter-evans/create-pull-request@v4
13044 with :
13145 title : " fix: patch version change"
132- committer : GamingEventapiBot <gamingeventapi@gmail.com>
133- author : GamingEventapiBot <gamingeventapi@gmail.com>
134- delete-branch : true
135- commit-message : ${{env.commit_message}}. Library require a new patch version change.
136- body : ${{env.commit_message}}. Library require a new patch version change.
0 commit comments