1+ name : ' Project Build'
2+ description : ' Builds FixLibrary project'
3+ inputs :
4+ project_path :
5+ description : ' Path to project folder'
6+ required : true
7+ runtime_version :
8+ description : ' Build runtime version default linux-x64'
9+ required : false
10+ default : ' linux-x64'
11+ nuget_push :
12+ description : ' Push to Nuget on release?'
13+ required : false
14+ default : false
15+ nuget_key :
16+ description : ' NuGet deploy key'
17+ required : false
18+ github_token :
19+ description : ' GitHub token'
20+ required : false
21+ outputs :
22+ version :
23+ description : " Generated version (SemVersion compatible)"
24+ value : ${{ steps.get-version.outputs.version }}
25+ is_prerelease :
26+ description : ' Gets if the version is a prerelease'
27+ value : ${{ steps.check-prerelease.outputs.is_prerelease }}
28+ runs :
29+ using : " composite"
30+ steps :
31+ # Generate semver compatible version from current tag and commit hash
32+ - name : Create version
33+ id : get-version
34+ run : echo "version=$(git describe --tags `git rev-list --tags --max-count=1`)+$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT
35+ shell : bash
36+
37+ - name : Check Prerelease
38+ id : check-prerelease
39+ run : " if ${{ contains(steps.get-version.outputs.version, '-') }}; then
40+ echo is_prerelease=true >> $GITHUB_OUTPUT;
41+ else
42+ echo is_prerelease=false >> $GITHUB_OUTPUT;
43+ fi"
44+ shell : bash
45+
46+ # Commands that are used multiple times.
47+ # Placed in one place to make sure that the arguments would always be the same
48+ - name : Common commands
49+ id : common-commands
50+ run : |
51+ echo "dotnet-restore=dotnet restore \$PROJECT_PATH --runtime ${{ inputs.runtime_version }}" >> $GITHUB_OUTPUT
52+ echo "dotnet-build=dotnet build \$PROJECT_PATH --configuration Release --no-restore -p:FixLibraryVersion=${{ steps.get-version.outputs.version }} --runtime ${{ inputs.runtime_version }}" >> $GITHUB_OUTPUT
53+ echo "dotnet-test=dotnet test \$PROJECT_PATH --configuration Release --no-restore --no-build --runtime ${{ inputs.runtime_version }}" >> $GITHUB_OUTPUT
54+ shell : bash
55+
56+ # Install dependencies (this needs to be a separate step from build for caching)
57+ - name : Install dependencies
58+ run : |
59+ ${{ steps.common-commands.outputs.dotnet-restore }}
60+ pwsh -File .github/actions/project-build/run-command-for-every-tests-project.ps1 "$PROJECT_PATH" '${{ steps.common-commands.outputs.dotnet-restore }}'
61+ env :
62+ PROJECT_PATH : ${{ inputs.project_path }} # Used by commands in `common-commands` step
63+ shell : bash
64+
65+ # Build project
66+ - name : Build
67+ run : |
68+ ${{ steps.common-commands.outputs.dotnet-build }}
69+ pwsh -File .github/actions/project-build/run-command-for-every-tests-project.ps1 "$PROJECT_PATH" '${{ steps.common-commands.outputs.dotnet-build }}'
70+ env :
71+ PROJECT_PATH : ${{ inputs.project_path }} # Used by commands in `common-commands` step
72+ shell : bash
73+
74+ # Test project
75+ - name : Test
76+ run : |
77+ pwsh -File .github/actions/project-build/run-command-for-every-tests-project.ps1 "$PROJECT_PATH" '${{ steps.common-commands.outputs.dotnet-test }}'
78+ env :
79+ PROJECT_PATH : ${{ inputs.project_path }} # Used by commands in `common-commands` step
80+ shell : bash
81+
82+ # Push to GitHub packages on each commit and release
83+ - name : Push to NuGet (Nightly)
84+ if : |
85+ inputs.nuget_push == 'true' && (github.event_name == 'push' ||
86+ github.event_name == 'create' && github.event.ref_type == 'tag')
87+ run : dotnet nuget push ${{ inputs.project_path }}/bin/Release/*.nupkg --api-key ${{ inputs.github_token }} --skip-duplicate --source https://nuget.pkg.github.com/UnturnedCommunity/index.json;
88+ shell : bash
89+
90+ # Push to NuGet on each tag, but only if the tag is not a pre-release version
91+ - name : Push to NuGet (Release)
92+ if : |
93+ inputs.nuget_push == 'true' && steps.check-prerelease.outputs.is_prerelease == 'false' &&
94+ github.event_name == 'create' && github.event.ref_type == 'tag'
95+ run : 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+ shell : bash
0 commit comments