@@ -2,7 +2,6 @@ name: Build and Publish
22
33on :
44 push :
5- pull_request :
65 branches :
76 - develop
87
1211 RUN : ${{ github.run_number }}
1312
1413jobs :
15- get-version :
16- runs-on : ubuntu-latest
17- outputs :
18- BUILD_ID : ${{ steps.get_build_id.outputs.BUILD_ID}}
19- APP_VERSION : ${{ steps.get_app_version.outputs.APP_VERSION}}
20- steps :
21- - name : Get New Build Number
22- id : get_build_id
23- shell : bash
24- run : |
25-
26- # Get the build ID
27- if [[ "${{ github.event_name }}" == 'push' && "${{ github.ref_name }}" == "${{ github.event.repository.default_branch }}" ]]; then
28- # Fetch the latest version from the organization NuGet package
29- response=$(curl -s -L \
30- -H "Accept: application/vnd.github+json" \
31- -H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" \
32- -H "X-GitHub-Api-Version: 2022-11-28" \
33- https://api.github.com/orgs/Open-Systems-Pharmacology/packages/nuget/OSPSuite.Core/versions)
34-
35- # Log the raw response for debugging
36- echo "API Response: $response"
37-
38- # Check if the response indicates a package not found error or is not valid JSON
39- if echo "$response" | jq -e '.message == "Package not found." or (.[0].name // empty | length == 0)' >/dev/null 2>&1; then
40- # Set the build number to 15 if no package is found or response is invalid (since the last build was 12.1.14)
41- new_build_id=16
42- else
43- latest_version=$(echo "$response" | jq -r '.[0].name // empty')
44-
45- # Extract MAJOR, MINOR from the latest version
46- IFS='.' read -r last_major last_minor last_build <<< "$latest_version"
47-
48- # Compare with the current MAJOR, MINOR
49- if [[ "$last_major" -eq "${{ env.MAJOR }}" && "$last_minor" -eq "${{ env.MINOR }}" ]]; then
50- # Increment the last number if they match
51- new_build_id=$((last_build + 1))
52- else
53- # Reset build number to 0 if the current version is different
54- new_build_id=0
55- fi
56- fi
57-
58- echo "latest build number: ${latest_version:-'None found'}"
59- echo "new build number: ${new_build_id}"
60- build_id="${new_build_id}"
61- else
62- build_id="9${{ env.RUN }}"
63- fi
64-
65- echo "New Build ID: ${build_id}"
66- echo "BUILD_ID=${build_id}" >> $GITHUB_ENV
67- echo "BUILD_ID=${build_id}" >> $GITHUB_OUTPUT
68-
69- - name : Get App Version
70- id : get_app_version
71- shell : bash
72- run : |
73- app_version="${{ env.MAJOR }}.${{ env.MINOR }}.${{ env.BUILD_ID }}"
74- echo "App Version: ${app_version}"
75- echo "APP_VERSION=${app_version}" >> $GITHUB_ENV
76- echo "APP_VERSION=${app_version}" >> $GITHUB_OUTPUT
77-
78- build :
14+ build-test-publish :
7915 runs-on : windows-latest
80- needs : get-version
8116 steps :
8217 - name : Checkout code
8318 uses : actions/checkout@v4
@@ -90,18 +25,11 @@ jobs:
9025 - name : Restore dependencies
9126 run : |
9227 nuget sources add -username Open-Systems-Pharmacology -password ${{ secrets.GITHUB_TOKEN }} -name OSP-GitHub-Packages -source "https://nuget.pkg.github.com/Open-Systems-Pharmacology/index.json"
93- nuget sources add -name bddhelper -source https://ci.appveyor.com/nuget/ospsuite-bddhelper
94- nuget sources add -name utility -source https://ci.appveyor.com/nuget/ospsuite-utility
95- nuget sources add -name serializer -source https://ci.appveyor.com/nuget/ospsuite-serializer
96- nuget sources add -name databinding -source https://ci.appveyor.com/nuget/ospsuite-databinding
97- nuget sources add -name texreporting -source https://ci.appveyor.com/nuget/ospsuite-texreporting
98- nuget sources add -name databinding-devexpress -source https://ci.appveyor.com/nuget/ospsuite-databinding-devexpress
9928 dotnet restore
10029
10130 - name : define env variables
10231 run : |
103- echo "APP_VERSION=${{needs.get-version.outputs.APP_VERSION}}" | Out-File -FilePath $env:GITHUB_ENV -Append
104- echo "BUILD_ID=${{needs.get-version.outputs.BUILD_ID}}" | Out-File -FilePath $env:GITHUB_ENV -Append
32+ echo "APP_VERSION=${{ env.MAJOR }}.${{ env.MINOR }}.${{ env.RUN }}" | Out-File -FilePath $env:GITHUB_ENV -Append
10533
10634 - name : Build
10735 run : msbuild OSPSuite.Core.sln /p:Version=${{env.APP_VERSION}}
@@ -112,14 +40,6 @@ jobs:
11240 - name : Pack the project
11341 run : dotnet pack .\OSPSuite.Core.sln --no-build --no-restore -o ./ -p:PackageVersion=${{env.APP_VERSION}} --configuration=Debug --no-build
11442
115- - name : Push nupkg as artifact
116- # if it is a push to a branch
117- if : github.event_name == 'push' && github.ref_name != github.event.repository.default_branch
118- uses : actions/upload-artifact@v4
119- with :
120- name : OSPSuite.Core
121- path : ./*.nupkg
122-
12343 - name : Push test log as artifact
12444 uses : actions/upload-artifact@v4
12545 with :
0 commit comments