Skip to content
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

NuGet package #789

Merged
merged 12 commits into from Aug 1, 2022
Merged
Show file tree
Hide file tree
Changes from 9 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
106 changes: 106 additions & 0 deletions .github/workflows/build-nuget.yml
@@ -0,0 +1,106 @@
name: Build NuGet Package
on:
simon-berger marked this conversation as resolved.
Show resolved Hide resolved
push:
tags: [ '[0-9]+.[0-9]+.[0-9]+' ]
pull_request:
tags: [ '[0-9]+.[0-9]+.[0-9]+' ]
workflow_dispatch:

jobs:
package-windows-latest:
runs-on: windows-latest
steps:
- name: Checkout
uses: actions/checkout@v3
with:
submodules: true
- name: Setup NuGet.exe
uses: nuget/setup-nuget@v1
- name: "[Release_x86] Build & Install"
env:
CMAKE_GENERATOR: "Visual Studio 17 2022"
uses: ashutoshvarma/action-cmake-build@master
with:
build-dir: ${{github.workspace}}/build
source-dir: ${{github.workspace}}
build-type: Release
target: ALL_BUILD
run-test: false
configure-options: -DBUILD_SHARED_LIBS=ON -DCURL_ZLIB=OFF -A Win32
install-build: true
install-options: --prefix ${{github.workspace}}\install --config Release
- name: "[Release_x86] Copy install files for Release_x86"
run: xcopy /e /i /y ${{github.workspace}}\install ${{github.workspace}}\nuget\build\native\x86\Release && xcopy /e /i /y ${{github.workspace}}\install ${{github.workspace}}\nuget\build\native\Win32\Release
- name: "[Release_x86] Clean build"
run: rm -r -fo ${{github.workspace}}/build
- name: "[Debug_x86] Build & Install"
env:
CMAKE_GENERATOR: "Visual Studio 17 2022"
uses: ashutoshvarma/action-cmake-build@master
with:
build-dir: ${{github.workspace}}/build
source-dir: ${{github.workspace}}
build-type: Debug
target: ALL_BUILD
run-test: false
configure-options: -DBUILD_SHARED_LIBS=ON -DCURL_ZLIB=OFF -A Win32
install-build: true
install-options: --prefix ${{github.workspace}}\install --config Debug
- name: "[Debug_x86] Copy install files for Debug_x86"
run: xcopy /e /i /y ${{github.workspace}}\install ${{github.workspace}}\nuget\build\native\x86\Debug && xcopy /e /i /y ${{github.workspace}}\install ${{github.workspace}}\nuget\build\native\Win32\Debug
- name: "[Debug_x86] Clean build"
run: rm -r -fo ${{github.workspace}}/build
- name: "[Release_x64] Build & Install"
env:
CMAKE_GENERATOR: "Visual Studio 17 2022"
uses: ashutoshvarma/action-cmake-build@master
with:
build-dir: ${{github.workspace}}/build
source-dir: ${{github.workspace}}
build-type: Release
target: ALL_BUILD
run-test: false
configure-options: -DBUILD_SHARED_LIBS=ON -DCURL_ZLIB=OFF -A x64
install-build: true
install-options: --prefix ${{github.workspace}}\install --config Release
- name: "[Release_x64] Copy install files for Release_x64"
run: xcopy /e /i /y ${{github.workspace}}\install ${{github.workspace}}\nuget\build\native\x64\Release
- name: "[Release_x64] Clean build"
run: rm -r -fo ${{github.workspace}}/build
- name: "[Debug_x64] Build & Install"
env:
CMAKE_GENERATOR: "Visual Studio 17 2022"
uses: ashutoshvarma/action-cmake-build@master
with:
build-dir: ${{github.workspace}}/build
source-dir: ${{github.workspace}}
build-type: Debug
target: ALL_BUILD
run-test: false
configure-options: -DBUILD_SHARED_LIBS=ON -DCURL_ZLIB=OFF -A x64
install-build: true
install-options: --prefix ${{github.workspace}}\install --config Debug
- name: "[Debug_x64] Copy install files for Debug_x64"
run: xcopy /e /i /y ${{github.workspace}}\install ${{github.workspace}}\nuget\build\native\x64\Debug
- name: "Get latest release tag"
uses: oprypin/find-latest-tag@v1
with:
repository: libcpr/cpr
releases-only: true
id: find_release_tag
- name: "Copy Readme.md"
run: xcopy /y ${{github.workspace}}\README.md ${{github.workspace}}\nuget
- name: "Create NuGet package"
env:
VERSION: ${{ steps.find_release_tag.outputs.tag }}
COMMIT_HASH: ${{ github.sha }}
run: nuget pack ${{github.workspace}}\nuget\libcpr.nuspec -OutputDirectory ${{github.workspace}} -Properties "VERSION=$ENV:VERSION;COMMIT_HASH=$ENV:COMMIT_HASH"
- name: "Upload artifact"
uses: actions/upload-artifact@v3
with:
name: artifact-nuget
path: ${{github.workspace}}\*.nupkg
- name: "Publish package to NuGet.org"
env:
NUGET_API_KEY: ${{ secrets.NUGET_API_KEY }}
run: nuget push ${{github.workspace}}\*.nupkg $ENV:NUGET_API_KEY -Source https://api.nuget.org/v3/index.json
1 change: 1 addition & 0 deletions .gitignore
Expand Up @@ -36,6 +36,7 @@ install_manifest.txt

# Custom
build/
!nuget/build

# Jekyll stuff
_includes/
Expand Down
29 changes: 29 additions & 0 deletions nuget/build/native/libcpr.props
@@ -0,0 +1,29 @@
<?xml version="1.0" encoding="utf-8"?>
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003"
ToolsVersion="15.0">
<PropertyGroup>
<LibraryType Condition="'$(Configuration)'=='Debug'">mdd</LibraryType>
<LibraryType Condition="'$(Configuration)'=='Release'">md</LibraryType>
</PropertyGroup>
<ItemGroup>
<CprLibs Include="$(MSBuildThisFileDirectory)\$(Platform)\$(Configuration)\lib\*.lib" />
</ItemGroup>
<ItemGroup>
<CprDlls Include="$(MSBuildThisFileDirectory)\$(Platform)\$(Configuration)\bin\*.dll" />
<None Include="@(CprDlls)">
<Link>%(RecursiveDir)%(FileName)%(Extension)</Link>
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
</ItemGroup>
<PropertyGroup>
<CprLibraries>@(CprLibs)</CprLibraries>
</PropertyGroup>
<ItemDefinitionGroup>
<ClCompile>
<AdditionalIncludeDirectories>$(MSBuildThisFileDirectory)\$(Platform)\$(Configuration)\include</AdditionalIncludeDirectories>
</ClCompile>
<Link>
<AdditionalDependencies>$(CprLibraries);%(AdditionalDependencies)</AdditionalDependencies>
</Link>
</ItemDefinitionGroup>
</Project>
6 changes: 6 additions & 0 deletions nuget/build/native/libcpr.targets
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Target Name="PlatformCheck" BeforeTargets="InjectReference" Condition="(('$(Platform)' != 'x86') AND ('$(Platform)' != 'x64')) AND ('$(Platform)' != 'Win32'))">
<Error Text="$(MSBuildThisFileName) does not work correctly on this platform: '$(Platform)'. You need to specify platform x86, x64, or Win32." />
</Target>
</Project>
19 changes: 19 additions & 0 deletions nuget/libcpr.nuspec
@@ -0,0 +1,19 @@
<?xml version="1.0" encoding="utf-8"?>
<package xmlns="http://schemas.microsoft.com/packaging/2010/07/nuspec.xsd">
<metadata>
<id>libcpr</id>
<version>$VERSION$</version>
<title>C++ Requests: Curl for People</title>
<authors>Simon Berger</authors>
<owners>Fabian Sauter, Kilian Traub, many other libcpr contributors</owners>
<requireLicenseAcceptance>false</requireLicenseAcceptance>
<license type="expression">MIT</license>
<icon>resources/cpr.png</icon>
<readme>README.md</readme>
<projectUrl>https://github.com/libcpr</projectUrl>
<description>C++ Requests: Curl for People, a spiritual port of Python Requests.</description>
<tags>Native, native</tags>
<language>english</language>
<repository type="git" url="https://github.com/libcpr/cpr" branch="master" commit="$COMMIT_HASH$" />
</metadata>
</package>
Binary file added nuget/resources/cpr.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.