@@ -25,23 +25,23 @@ jobs:
2525 strategy :
2626 matrix :
2727 compiler :
28- - gcc-11
28+ - gcc-14
2929 generator :
3030 - " Unix Makefiles"
3131 build_type :
3232 - Debug
33- developer_mode :
33+ packaging_maintainer_mode :
3434 - OFF
3535
3636 steps :
37- - uses : actions/checkout@v3
37+ - uses : actions/checkout@v6
3838
3939 - name : Setup Cache
4040 uses : ./.github/actions/setup_cache
4141 with :
4242 compiler : ${{ matrix.compiler }}
4343 build_type : ${{ matrix.build_type }}
44- developer_mode : ${{ matrix.developer_mode }}
44+ package_maintainer_mode : ${{ matrix.package_maintainer_mode }}
4545 generator : ${{ matrix.generator }}
4646
4747 - name : Get organization and project name
@@ -53,23 +53,47 @@ jobs:
5353 - uses : octokit/request-action@v2.x
5454 id : get_repo_meta
5555 with :
56- route : GET /repos/{owner}/{repo}
57- owner : ${{ env.NEW_ORG }}
58- repo : ${{ env.NEW_PROJECT }}
56+ route : GET /repos/${{ env.NEW_ORG }}/${{ env.NEW_PROJECT }}
5957 env :
6058 GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
6159
60+ - name : Export description to variable
61+ # This is basically needed as we have to have the value in an env variable to further process it in a safe manner.
62+ # Also we can inject a mock-string for testing if the project is still the template.
63+ if : fromJson(steps.get_repo_meta.outputs.data).is_template == false
64+ run : |
65+ # description can contain characters that mess with the sed command, so store it in a variable first.
66+ # The content of the description will be copied as-is by the action which makes it nearly impossible to "just" use it.
67+ # But by storing it in a variable with a heredoc the sed command will accept quotes and single quotes without a problem.
68+ # The heredoc delimiter is deliberately verbose and complex to reduce the likeliness someone accidentally puts it in their
69+ # description.
70+ echo NEW_DESCRIPTION="$(cat <<'do;not(include}this[in%the$description'
71+ ${{ fromJson(steps.get_repo_meta.outputs.data).description }}
72+ do;not(include}this[in%the$description
73+ )" >> $GITHUB_ENV
74+
6275 - name : Use testing variables if still a template
6376 if : fromJson(steps.get_repo_meta.outputs.data).is_template == true
6477 run : |
6578 # This name is unsafe because it is not a valid C++ identifier
6679 echo "NEW_PROJECT=my-unsafe.project" >> $GITHUB_ENV
80+ # This name is unsafe as the sed command later uses surrounding quotes and the pipe symbol. The other characters are generally harmful too.
81+ NEW_DESCRIPTION=$(cat <<'EOF'
82+ Unsafe because of "quotes" and unbalanced "quotes ('Also' 'unbalanced single). The sed uses | and used to have /. Variable expansion might be bad $GITHUB_ENV as well. Also \ should stay.
83+ EOF
84+ )
85+ echo NEW_DESCRIPTION="$NEW_DESCRIPTION" >> $GITHUB_ENV
6786
6887 - name : Add safe replacement variable versions
6988 run : |
7089 # hyphens and dots in c++ identifiers are forbidden. Use underscores instead.
7190 NEW_SAFE_PROJECT=$(echo ${{ env.NEW_PROJECT }} | sed "s/-/_/g" | sed "s/\./_/g" )
72- echo "NEW_SAFE_PROJECT=$NEW_SAFE_PROJECT" >> $GITHUB_ENV
91+ echo "NEW_SAFE_PROJECT=$NEW_SAFE_PROJECT" >> $GITHUB_ENV
92+ # The sed command uses the pipe as the delimiter so escape that to make it safe.
93+ # Also as we would remove any literal \ we have to escape those aswell and that has to
94+ # be done first as it would mess with the escape for the | otherwise.
95+ NEW_SAFE_DESCRIPTION="$(echo "$NEW_DESCRIPTION" | sed 's/\\/\\\\/g' | sed 's/|/\\|/g' )"
96+ echo "NEW_SAFE_DESCRIPTION=$NEW_SAFE_DESCRIPTION" >> $GITHUB_ENV
7397
7498 # Rename all cpp_starter_project occurences to current repository and remove this workflow
7599 - name : Insert new org and project
83107 # fill in placeholders of readme and move it into place
84108 sed -i "s/%%myorg%%/${{ env.NEW_ORG }}/g" ${{ env.TEMPLATES_PATH }}/README.md
85109 sed -i "s/%%myproject%%/${{ env.NEW_PROJECT }}/g" ${{ env.TEMPLATES_PATH }}/README.md
86- sed -i "s|%%description%%|${{ fromJson(steps.get_repo_meta.outputs.data).description }}|g" ${{ env.TEMPLATES_PATH }}/README.md
110+ # Use the variable from the env directly as githubs expansion would break the sed command.
111+ sed -i "s|%%description%%|$NEW_SAFE_DESCRIPTION|g" ${{ env.TEMPLATES_PATH }}/README.md
87112 mv include/myproject include/${{ env.NEW_SAFE_PROJECT }}
88113 cp ${{ env.TEMPLATES_PATH }}/README.md README.md
89114
@@ -161,18 +186,18 @@ jobs:
161186 - " Unix Makefiles"
162187 build_type :
163188 - Debug
164- developer_mode :
165- - OFF
189+ packaging_maintainer_mode :
190+ - ON
166191
167192 steps :
168- - uses : actions/checkout@v3
193+ - uses : actions/checkout@v6
169194
170195 - name : Setup Cache
171196 uses : ./.github/actions/setup_cache
172197 with :
173198 compiler : ${{ matrix.compiler }}
174199 build_type : ${{ matrix.build_type }}
175- developer_mode : ${{ matrix.developer_mode }}
200+ packaging_maintainer_mode : ${{ matrix.packaging_maintainer_mode }}
176201 generator : ${{ matrix.generator }}
177202
178203 - name : Get organization and project name
@@ -187,9 +212,7 @@ jobs:
187212 - uses : octokit/request-action@v2.x
188213 id : get_repo_meta
189214 with :
190- route : GET /repos/{owner}/{repo}
191- owner : ${{ env.NEW_ORG }}
192- repo : ${{ env.NEW_PROJECT }}
215+ route : GET /repos/${{ env.NEW_ORG }}/${{ env.NEW_PROJECT }}
193216 env :
194217 GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
195218
@@ -230,7 +253,7 @@ jobs:
230253 opencppcoverage : false
231254
232255
233- - name : Test simple configuration to make sure nothing broke (default compiler,cmake,developer_mode OFF)
256+ - name : Test simple configuration to make sure nothing broke (default compiler,cmake,packaging_maintainer_mode OFF)
234257 run : |
235258 cmake -S . -B ./build -G "${{ matrix.generator }}" -DCMAKE_BUILD_TYPE:STRING=${{ matrix.build_type }} -D${{ env.PROJECT_NAME }}_PACKAGING_MAINTAINER_MODE:BOOL=ON
236259
0 commit comments