@@ -7,12 +7,16 @@ inputs:
7
7
target_framework :
8
8
description : ' The target framework to build on'
9
9
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
10
14
runtime_version :
11
- description : ' Build runtime version default linux-x64'
15
+ description : ' Build runtime version ( default linux-x64) if using a runtime flag '
12
16
required : false
13
17
default : ' linux-x64'
14
18
nuget_push :
15
- description : ' Push to Nuget on release?'
19
+ description : ' Push to NuGet on release?'
16
20
required : false
17
21
default : false
18
22
nuget_key :
@@ -34,35 +38,46 @@ runs:
34
38
# Generate semver compatible version from current tag and commit hash
35
39
- name : Create version
36
40
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
38
42
shell : bash
39
43
40
44
- name : Check Prerelease
41
45
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
47
63
shell : bash
48
64
49
65
# Commands that are used multiple times.
50
- # Placed in one place to make sure that the arguments would always be the same
51
66
- name : Common commands
52
67
id : common-commands
53
68
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
57
72
shell : bash
58
73
59
- # Install dependencies (this needs to be a separate step from build for caching)
74
+ # Install dependencies (separate step for caching)
60
75
- name : Install dependencies
61
76
run : |
62
77
${{ steps.common-commands.outputs.dotnet-restore }}
63
78
pwsh -File .github/actions/project-build/run-command-for-every-tests-project.ps1 "$GITHUB_WORKSPACE/tests" '${{ steps.common-commands.outputs.dotnet-restore }}'
64
79
env :
65
- PROJECT_PATH : ${{ inputs.project_path }} # Used by commands in `common-commands` step
80
+ PROJECT_PATH : ${{ inputs.project_path }}
66
81
shell : bash
67
82
68
83
# Build project
@@ -71,27 +86,29 @@ runs:
71
86
${{ steps.common-commands.outputs.dotnet-build }}
72
87
pwsh -File .github/actions/project-build/run-command-for-every-tests-project.ps1 "$GITHUB_WORKSPACE/tests" '${{ steps.common-commands.outputs.dotnet-build }}'
73
88
env :
74
- PROJECT_PATH : ${{ inputs.project_path }} # Used by commands in `common-commands` step
89
+ PROJECT_PATH : ${{ inputs.project_path }}
75
90
shell : bash
76
91
77
92
# Test project
78
93
- name : Test
79
94
run : |
80
95
pwsh -File .github/actions/project-build/run-command-for-every-tests-project.ps1 "$GITHUB_WORKSPACE/tests" '${{ steps.common-commands.outputs.dotnet-test }}'
81
96
env :
82
- PROJECT_PATH : ${{ inputs.project_path }} # Used by commands in `common-commands` step
97
+ PROJECT_PATH : ${{ inputs.project_path }}
83
98
shell : bash
84
99
85
- # Push to GitHub packages on each commit and release
100
+ # Push to GitHub packages on each commit and release (Nightly)
86
101
- 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;
89
105
fi
90
106
shell : bash
91
107
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)
93
109
- 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;
96
113
fi
97
- shell : bash
114
+ shell : bash
0 commit comments