5252 description : ' Models to include in the release documentation'
5353 required : false
5454 type : string
55+ patch :
56+ description : ' Create a patch release. If true, only bug fixes will be included in generated documentation.'
57+ required : false
58+ type : boolean
59+ default : false
5560jobs :
5661 set_options :
5762 name : Set release options
6671 compiler_version : ${{ steps.set_compiler.outputs.compiler_version }}
6772 version : ${{ steps.set_version.outputs.version }}
6873 models : ${{ steps.set_models.outputs.models }}
74+ patch : ${{ steps.set_patch.outputs.patch }}
6975 steps :
7076 - name : Set branch
7177 id : set_branch
@@ -144,6 +150,37 @@ jobs:
144150 exit 1
145151 fi
146152 echo "models=$models" >> $GITHUB_OUTPUT
153+ - name : Set patch
154+ id : set_patch
155+ run : |
156+ # if patch was provided explicitly via workflow_dispatch, use it
157+ if [[ ("${{ github.event_name }}" == "workflow_dispatch") && (-n "${{ inputs.patch }}") ]]; then
158+ patch="${{ inputs.patch }}"
159+ echo "using patch setting $patch from workflow_dispatch"
160+ elif [[ ("${{ github.event_name }}" == "push") && ("${{ github.ref_name }}" != "master") ]]; then
161+ # if release was triggered by pushing a release branch, check the version against the latest
162+ # tag on master to determine if this is a patch release
163+ latest_tag=$(git ls-remote --tags origin "6.*" | awk -F/ '{print $3}' | sort -V | tail -n1)
164+ echo "latest version on master is $latest_tag"
165+ IFS='.' read -r -a latest_parts <<< "$latest_tag"
166+ IFS='.' read -r -a new_parts <<< "${{ steps.set_version.outputs.version }}"
167+ if [[ ${#latest_parts[@]} -ne 3 || ${#new_parts[@]} -ne 3 ]]; then
168+ echo "error: version number is not in major.minor.patch format"
169+ exit 1
170+ fi
171+ if [[ ${latest_parts[0]} -ne ${new_parts[0]} || ${latest_parts[1]} -ne ${new_parts[1]} ]]; then
172+ patch="false"
173+ echo "major or minor version has changed, not a patch release"
174+ elif [[ ${latest_parts[2]} -lt ${new_parts[2]} ]]; then
175+ patch="true"
176+ echo "patch version has changed, this is a patch release"
177+ fi
178+ else
179+ # otherwise exit with an error
180+ echo "error: this workflow should not have triggered for event ${{ github.event_name }} on branch ${{ github.ref_name }}"
181+ exit 1
182+ fi
183+ echo "patch=$patch" >> $GITHUB_OUTPUT
147184 make_dist :
148185 name : Make distribution
149186 uses : MODFLOW-ORG/modflow6/.github/workflows/release.yml@develop
@@ -164,6 +201,7 @@ jobs:
164201 run_tests : ${{ (github.event_name == 'workflow_dispatch' && inputs.run_tests == 'true') || github.event_name != 'workflow_dispatch' }}
165202 version : ${{ needs.set_options.outputs.version }}
166203 models : ${{ needs.set_options.outputs.models }}
204+ patch : ${{ (github.event_name == 'workflow_dispatch' && inputs.patch == 'true') || (github.event_name != 'workflow_dispatch' && needs.set_options.outputs.patch == 'true') }}
167205 pr :
168206 name : Draft release PR
169207 if : ${{ github.ref_name != 'master' && ((github.event_name == 'workflow_dispatch' && inputs.approve == 'true') || (github.event_name != 'workflow_dispatch' && !contains(github.ref_name, 'rc'))) }}
0 commit comments