-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Build on GHA #9
Merged
+257
−37
Merged
Build on GHA #9
Changes from all commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
b940aab
initial GHA test
rwmcintosh 2d340d7
update upload-artifact@v4
rwmcintosh a26eb70
local directory execute
rwmcintosh 7acdacf
start
rwmcintosh 45ab730
start
rwmcintosh 990d5f0
target cmd
rwmcintosh 041d9d3
leave echo on
rwmcintosh 045ac49
do not use batch
rwmcintosh a4bbb07
cmd shell
rwmcintosh 788f05a
artifact spelling
rwmcintosh 165dcf0
restore batch file
rwmcintosh d95b3f1
update badge
rwmcintosh 183621e
Update README.md
rwmcintosh 30c8d65
Update README.md
rwmcintosh File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,256 @@ | ||
name: Build and Publish NuGet Package for all supported platforms | ||
|
||
on: | ||
push: | ||
pull_request: | ||
branches: | ||
- master | ||
|
||
|
||
env: | ||
MAJOR: 5 | ||
MINOR: 8 | ||
RELEASE: 0 | ||
RUN: ${{ github.run_number }} | ||
|
||
jobs: | ||
get-version: | ||
runs-on: ubuntu-latest | ||
outputs: | ||
BUILD_ID: ${{ steps.get_build_id.outputs.BUILD_ID}} | ||
APP_VERSION: ${{ steps.get_app_version.outputs.APP_VERSION}} | ||
steps: | ||
- name: Get New Build Number | ||
id: get_build_id | ||
shell: bash | ||
run: | | ||
|
||
# Get the build ID | ||
if [[ "${{ github.event_name }}" == 'push' && "${{ github.ref_name }}" == "${{ github.event.repository.default_branch }}" ]]; then | ||
# Fetch the latest version from the organization NuGet package | ||
response=$(curl -s -L \ | ||
-H "Accept: application/vnd.github+json" \ | ||
-H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" \ | ||
-H "X-GitHub-Api-Version: 2022-11-28" \ | ||
https://api.github.com/orgs/Open-Systems-Pharmacology/packages/nuget/OSPSuite.FuncParser/versions) | ||
|
||
# Log the raw response for debugging | ||
echo "API Response: $response" | ||
|
||
# Check if the response indicates a package not found error or is not valid JSON | ||
if echo "$response" | jq -e '.message == "Package not found." or (.[0].name // empty | length == 0)' >/dev/null 2>&1; then | ||
# Set the build number to 9 if no package is found or response is invalid (since the last released was 5.8.0.8) | ||
new_build_id=9 | ||
else | ||
latest_version=$(echo "$response" | jq -r '.[0].name // empty') | ||
|
||
# Extract MAJOR, MINOR, and RELEASE from the latest version | ||
IFS='.' read -r last_major last_minor last_release last_build <<< "$latest_version" | ||
|
||
# Compare with the current MAJOR, MINOR, and RELEASE | ||
if [[ "$last_major" -eq "${{ env.MAJOR }}" && "$last_minor" -eq "${{ env.MINOR }}" && "$last_release" -eq "${{ env.RELEASE }}" ]]; then | ||
# Increment the last number if they match | ||
new_build_id=$((last_build + 1)) | ||
else | ||
# Reset build number to 0 if the current version is different | ||
new_build_id=0 | ||
fi | ||
fi | ||
|
||
echo "latest build number: ${latest_version:-'None found'}" | ||
echo "new build number: ${new_build_id}" | ||
build_id="${new_build_id}" | ||
else | ||
build_id="999${{ env.RUN }}" | ||
fi | ||
|
||
echo "New Build ID: ${build_id}" | ||
echo "BUILD_ID=${build_id}" >> $GITHUB_ENV | ||
echo "::set-output name=BUILD_ID::${build_id}" | ||
|
||
- name: Get App Version | ||
id: get_app_version | ||
shell: bash | ||
run: | | ||
app_version="${{ env.MAJOR }}.${{ env.MINOR }}.${{ env.RELEASE }}.${{ env.BUILD_ID }}" | ||
echo "App Version: ${app_version}" | ||
echo "APP_VERSION=${app_version}" >> $GITHUB_ENV | ||
echo "::set-output name=APP_VERSION::${app_version}" | ||
|
||
build-macos-arm64: | ||
runs-on: macos-latest | ||
needs: get-version | ||
|
||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v4 | ||
with: | ||
submodules: 'true' | ||
|
||
- name: define env variables | ||
run: | | ||
echo "APP_VERSION=${{needs.get-version.outputs.APP_VERSION}}" >> $GITHUB_ENV | ||
echo "BUILD_ID=${{needs.get-version.outputs.BUILD_ID}}" >> $GITHUB_ENV | ||
|
||
- name: Build native libraries | ||
run: | | ||
chmod ugo+x buildNix.sh | ||
./buildNix.sh | ||
|
||
- name: Pack the project | ||
run: | | ||
chmod ugo+x createNugetPackage_Nix.sh | ||
./createNugetPackage_Nix.sh ${{env.APP_VERSION}} | ||
|
||
- name: Push nupkg as artifact | ||
# if it is a push to a branch | ||
if: github.event_name == 'push' && github.ref_name != github.event.repository.default_branch | ||
uses: actions/upload-artifact@v4 | ||
with: | ||
name: CVODES.MacOS.Arm64 | ||
path: ./*.nupkg | ||
|
||
- name: Publish to GitHub registry | ||
# if it is a merge to default branch | ||
if: github.event_name == 'push' && github.ref_name == github.event.repository.default_branch | ||
run: dotnet nuget push ./*.nupkg --source https://nuget.pkg.github.com/${{github.repository_owner}}/index.json --api-key ${{ secrets.GITHUB_TOKEN }} | ||
|
||
build-macos-x64: | ||
runs-on: macos-13 | ||
needs: get-version | ||
|
||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v4 | ||
with: | ||
submodules: 'true' | ||
|
||
- name: define env variables | ||
run: | | ||
echo "APP_VERSION=${{needs.get-version.outputs.APP_VERSION}}" >> $GITHUB_ENV | ||
echo "BUILD_ID=${{needs.get-version.outputs.BUILD_ID}}" >> $GITHUB_ENV | ||
|
||
- name: Build native libraries | ||
run: | | ||
chmod ugo+x buildNix.sh | ||
./buildNix.sh | ||
|
||
- name: Pack the project | ||
run: | | ||
chmod ugo+x createNugetPackage_Nix.sh | ||
./createNugetPackage_Nix.sh ${{env.APP_VERSION}} | ||
|
||
- name: Push nupkg as artifact | ||
# if it is a push to a branch | ||
if: github.event_name == 'push' && github.ref_name != github.event.repository.default_branch | ||
uses: actions/upload-artifact@v4 | ||
with: | ||
name: CVODES.MacOS.x64 | ||
path: ./*.nupkg | ||
|
||
- name: Publish to GitHub registry | ||
# if it is a merge to default branch | ||
if: github.event_name == 'push' && github.ref_name == github.event.repository.default_branch | ||
run: dotnet nuget push ./*.nupkg --source https://nuget.pkg.github.com/${{github.repository_owner}}/index.json --api-key ${{ secrets.GITHUB_TOKEN }} | ||
|
||
build-linux-x64: | ||
runs-on: ubuntu-22.04 | ||
needs: get-version | ||
|
||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v4 | ||
with: | ||
submodules: 'true' | ||
|
||
- name: define env variables | ||
run: | | ||
echo "APP_VERSION=${{needs.get-version.outputs.APP_VERSION}}" >> $GITHUB_ENV | ||
echo "BUILD_ID=${{needs.get-version.outputs.BUILD_ID}}" >> $GITHUB_ENV | ||
|
||
- name: Build native libraries | ||
run: | | ||
chmod ugo+x buildNix.sh | ||
./buildNix.sh | ||
|
||
- name: Pack the project | ||
run: | | ||
chmod ugo+x createNugetPackage_Nix.sh | ||
./createNugetPackage_Nix.sh ${{env.APP_VERSION}} | ||
|
||
- name: Push nupkg as artifact | ||
# if it is a push to a branch | ||
if: github.event_name == 'push' && github.ref_name != github.event.repository.default_branch | ||
uses: actions/upload-artifact@v4 | ||
with: | ||
name: CVODES.Ubuntu22 | ||
path: ./*.nupkg | ||
|
||
- name: Publish to GitHub registry | ||
# if it is a merge to default branch | ||
if: github.event_name == 'push' && github.ref_name == github.event.repository.default_branch | ||
run: dotnet nuget push ./*.nupkg --source https://nuget.pkg.github.com/${{github.repository_owner}}/index.json --api-key ${{ secrets.GITHUB_TOKEN }} | ||
|
||
build-windows-x64: | ||
runs-on: windows-latest | ||
needs: get-version | ||
|
||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v4 | ||
with: | ||
submodules: 'true' | ||
|
||
- name: define env variables | ||
run: | | ||
echo "APP_VERSION=${{needs.get-version.outputs.APP_VERSION}}" | Out-File -FilePath $env:GITHUB_ENV -Append | ||
echo "BUILD_ID=${{needs.get-version.outputs.BUILD_ID}}" | Out-File -FilePath $env:GITHUB_ENV -Append | ||
|
||
- name: Add msbuild to PATH | ||
uses: microsoft/setup-msbuild@v2 | ||
|
||
- name: build debug | ||
run: | | ||
if not exist BuildCVODES_Windows mkdir BuildCVODES_Windows | ||
echo Compiling for build type = Debug | ||
cmake -BBuildCVODES_Windows/Debug/x64/ -Hsrc/CVODES/ -DCMAKE_BUILD_TYPE=Debug -DEXAMPLES_ENABLE_C=OFF -DBUILD_SHARED_LIBS=OFF -DBUILD_STATIC_LIBS=ON -DENABLE_KLU=OFF -DCMAKE_POSITION_INDEPENDENT_CODE=ON -DKLU_INCLUDE_DIR=BuildSuiteSparse/include/ -DKLU_LIBRARY_DIR=BuildSuiteSparse/lib64/ -DCMAKE_C_FLAGS_RELEASE="/O2 /Ob2 /DNDEBUG /Oi" | ||
IF %ERRORLEVEL% NEQ 0 EXIT /B %ERRORLEVEL% | ||
msbuild BuildCVODES_Windows/Debug/x64/ALL_BUILD.vcxproj /property:Configuration=Debug | ||
IF %ERRORLEVEL% NEQ 0 EXIT /B %ERRORLEVEL% | ||
if exist Dist\Windows\Debug\x64 rmdir /S /Q Dist\Windows\Debug\x64 | ||
IF %ERRORLEVEL% NEQ 0 EXIT /B %ERRORLEVEL% | ||
mkdir Dist\Windows\Debug\x64 | ||
IF %ERRORLEVEL% NEQ 0 EXIT /B %ERRORLEVEL% | ||
shell: cmd | ||
|
||
- name: build release | ||
run: | | ||
if not exist BuildCVODES_Windows mkdir BuildCVODES_Windows | ||
echo Compiling for build type = Release | ||
cmake -BBuildCVODES_Windows/Release/x64/ -Hsrc/CVODES/ -DCMAKE_BUILD_TYPE=Release -DEXAMPLES_ENABLE_C=OFF -DBUILD_SHARED_LIBS=OFF -DBUILD_STATIC_LIBS=ON -DENABLE_KLU=OFF -DCMAKE_POSITION_INDEPENDENT_CODE=ON -DKLU_INCLUDE_DIR=BuildSuiteSparse/include/ -DKLU_LIBRARY_DIR=BuildSuiteSparse/lib64/ -DCMAKE_C_FLAGS_RELEASE="/O2 /Ob2 /DNDEBUG /Oi" | ||
IF %ERRORLEVEL% NEQ 0 EXIT /B %ERRORLEVEL% | ||
msbuild BuildCVODES_Windows/Release/x64/ALL_BUILD.vcxproj /property:Configuration=Release | ||
IF %ERRORLEVEL% NEQ 0 EXIT /B %ERRORLEVEL% | ||
if exist Dist\Windows\Release\x64 rmdir /S /Q Dist\Windows\Release\x64 | ||
IF %ERRORLEVEL% NEQ 0 EXIT /B %ERRORLEVEL% | ||
mkdir Dist\Windows\Release\x64 | ||
IF %ERRORLEVEL% NEQ 0 EXIT /B %ERRORLEVEL% | ||
shell: cmd | ||
|
||
- name: Pack the project | ||
run: ./createNugetPackage_Windows.bat ${{env.APP_VERSION}} | ||
shell: cmd | ||
|
||
- name: Push nupkg as artifact | ||
# if it is a push to a branch | ||
if: github.event_name == 'push' && github.ref_name != github.event.repository.default_branch | ||
uses: actions/upload-artifact@v4 | ||
with: | ||
name: CVODES | ||
path: ./*.nupkg | ||
|
||
- name: Publish to GitHub registry | ||
# if it is a merge to default branch | ||
if: github.event_name == 'push' && github.ref_name == github.event.repository.default_branch | ||
shell: pwsh | ||
run: dotnet nuget push .\CVODES*.nupkg --source https://nuget.pkg.github.com/${{github.repository_owner}}/index.json --api-key ${{ secrets.GITHUB_TOKEN }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
# CVODES | ||
|
||
[![Build status](https://ci.appveyor.com/api/projects/status/4mh7psxcwyhyjohi?svg=true)](https://ci.appveyor.com/project/open-systems-pharmacology-ci/cvodes) | ||
[![Build status](https://img.shields.io/github/actions/workflow/status/Open-Systems-Pharmacology/CVODES/build-and-publish.yml?logo=nuget&label=Build%20status)](https://github.com/Open-Systems-Pharmacology/CVODES/actions/workflows/build-and-publish.yml) | ||
|
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
use build_Windows.bat 🙂
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok, let's merge AS IS for now.
Created an issue: #10