@@ -7,12 +7,16 @@ inputs:
77 target_framework :
88 description : ' The target framework to build on'
99 required : true
10+ use_runtime :
11+ description : ' Include runtime flag? Set to true for self-contained builds, false (default) for global tools.'
12+ required : false
13+ default : true
1014 runtime_version :
11- description : ' Build runtime version default linux-x64'
15+ description : ' Build runtime version ( default linux-x64) if using a runtime flag '
1216 required : false
1317 default : ' linux-x64'
1418 nuget_push :
15- description : ' Push to Nuget on release?'
19+ description : ' Push to NuGet on release?'
1620 required : false
1721 default : false
1822 nuget_key :
@@ -34,35 +38,46 @@ runs:
3438 # Generate semver compatible version from current tag and commit hash
3539 - name : Create version
3640 id : get-version
37- run : echo "version=$(git describe --tags ` git rev-list --tags --max-count=1` )+$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT
41+ run : echo "version=$(git describe --tags $( git rev-list --tags --max-count=1) )+$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT
3842 shell : bash
3943
4044 - name : Check Prerelease
4145 id : check-prerelease
42- run : " if ${{ contains(steps.get-version.outputs.version, '-') }}; then
43- echo is_prerelease=true >> $GITHUB_OUTPUT;
44- else
45- echo is_prerelease=false >> $GITHUB_OUTPUT;
46- fi"
46+ run : |
47+ if [[ "${{ steps.get-version.outputs.version }}" == *"-"* ]]; then
48+ echo "is_prerelease=true" >> $GITHUB_OUTPUT
49+ else
50+ echo "is_prerelease=false" >> $GITHUB_OUTPUT
51+ fi
52+ shell : bash
53+
54+ # Determine whether to include the --runtime flag.
55+ - name : Set runtime flag
56+ id : set-runtime-flag
57+ run : |
58+ if [ "${{ inputs.use_runtime }}" = "true" ]; then
59+ echo "runtime=--runtime ${{ inputs.runtime_version }}" >> $GITHUB_OUTPUT
60+ else
61+ echo "runtime=" >> $GITHUB_OUTPUT
62+ fi
4763 shell : bash
4864
4965 # Commands that are used multiple times.
50- # Placed in one place to make sure that the arguments would always be the same
5166 - name : Common commands
5267 id : common-commands
5368 run : |
54- echo "dotnet-restore=dotnet restore \$PROJECT_PATH --runtime ${{ inputs.runtime_version }} -p:Configuration=Release -p:TargetFramework=${{ inputs.target_framework }}" >> $GITHUB_OUTPUT
55- echo "dotnet-build=dotnet build \$PROJECT_PATH --configuration Release --no-restore --runtime ${{ inputs.runtime_version }} -p:TargetFramework=${{ inputs.target_framework }} -p:BitMonoVersion=${{ steps.get-version.outputs.version }}" >> $GITHUB_OUTPUT
56- echo "dotnet-test=dotnet test \$PROJECT_PATH --configuration Release --no-restore --no-build --runtime ${{ inputs.runtime_version }} -p:TargetFramework=${{ inputs.target_framework }}" >> $GITHUB_OUTPUT
69+ echo "dotnet-restore=dotnet restore \$PROJECT_PATH ${{ steps.set-runtime-flag.outputs.runtime }} -p:Configuration=Release -p:TargetFramework=${{ inputs.target_framework }}" >> $GITHUB_OUTPUT
70+ echo "dotnet-build=dotnet build \$PROJECT_PATH --configuration Release --no-restore ${{ steps.set-runtime-flag.outputs.runtime }} -p:TargetFramework=${{ inputs.target_framework }} -p:BitMonoVersion=${{ steps.get-version.outputs.version }}" >> $GITHUB_OUTPUT
71+ echo "dotnet-test=dotnet test \$PROJECT_PATH --configuration Release --no-restore --no-build ${{ steps.set-runtime-flag.outputs.runtime }} -p:TargetFramework=${{ inputs.target_framework }}" >> $GITHUB_OUTPUT
5772 shell : bash
5873
59- # Install dependencies (this needs to be a separate step from build for caching)
74+ # Install dependencies (separate step for caching)
6075 - name : Install dependencies
6176 run : |
6277 ${{ steps.common-commands.outputs.dotnet-restore }}
6378 pwsh -File .github/actions/project-build/run-command-for-every-tests-project.ps1 "$GITHUB_WORKSPACE/tests" '${{ steps.common-commands.outputs.dotnet-restore }}'
6479 env :
65- PROJECT_PATH : ${{ inputs.project_path }} # Used by commands in `common-commands` step
80+ PROJECT_PATH : ${{ inputs.project_path }}
6681 shell : bash
6782
6883 # Build project
@@ -71,27 +86,29 @@ runs:
7186 ${{ steps.common-commands.outputs.dotnet-build }}
7287 pwsh -File .github/actions/project-build/run-command-for-every-tests-project.ps1 "$GITHUB_WORKSPACE/tests" '${{ steps.common-commands.outputs.dotnet-build }}'
7388 env :
74- PROJECT_PATH : ${{ inputs.project_path }} # Used by commands in `common-commands` step
89+ PROJECT_PATH : ${{ inputs.project_path }}
7590 shell : bash
7691
7792 # Test project
7893 - name : Test
7994 run : |
8095 pwsh -File .github/actions/project-build/run-command-for-every-tests-project.ps1 "$GITHUB_WORKSPACE/tests" '${{ steps.common-commands.outputs.dotnet-test }}'
8196 env :
82- PROJECT_PATH : ${{ inputs.project_path }} # Used by commands in `common-commands` step
97+ PROJECT_PATH : ${{ inputs.project_path }}
8398 shell : bash
8499
85- # Push to GitHub packages on each commit and release
100+ # Push to GitHub packages on each commit and release (Nightly)
86101 - name : Push to NuGet (Nightly)
87- run : if ${{ inputs.nuget_push == 'true' && (github.event_name == 'push' || (github.event_name == 'create' && github.event.ref_type == 'tag')) }}; then
88- dotnet nuget push ${{ inputs.project_path }}/bin/Release/*.nupkg --api-key ${{ inputs.github_token }} --skip-duplicate --source https://nuget.pkg.github.com/sunnamed434/index.json;
102+ run : |
103+ if [ "${{ inputs.nuget_push }}" = "true" ] && ( [ "${{ github.event_name }}" = "push" ] || ( [ "${{ github.event_name }}" = "create" ] && [ "${{ github.event.ref_type }}" = "tag" ] ) ); then
104+ dotnet nuget push ${{ inputs.project_path }}/bin/Release/*.nupkg --api-key ${{ inputs.github_token }} --skip-duplicate --source https://nuget.pkg.github.com/sunnamed434/index.json;
89105 fi
90106 shell : bash
91107
92- # Push to NuGet on each tag, but only if the tag is not a pre-release version
108+ # Push to NuGet on each tag, but only if not a pre-release version (Release)
93109 - name : Push to NuGet (Release)
94- run : if ${{ inputs.nuget_push == 'true' && github.event_name == 'create' && github.event.ref_type == 'tag' && steps.check-prerelease.outputs.is_prerelease == 'false' }}; then
95- dotnet nuget push ${{ inputs.project_path }}/bin/Release/*.nupkg --api-key ${{ inputs.nuget_key }} --skip-duplicate --source https://api.nuget.org/v3/index.json;
110+ run : |
111+ if [ "${{ inputs.nuget_push }}" = "true" ] && [ "${{ github.event_name }}" = "create" ] && [ "${{ github.event.ref_type }}" = "tag" ] && [ "${{ steps.check-prerelease.outputs.is_prerelease }}" = "false" ]; then
112+ dotnet nuget push ${{ inputs.project_path }}/bin/Release/*.nupkg --api-key ${{ inputs.nuget_key }} --skip-duplicate --source https://api.nuget.org/v3/index.json;
96113 fi
97- shell : bash
114+ shell : bash
0 commit comments