aboutsummaryrefslogtreecommitdiff
path: root/thirdparty/cpr/.github/workflows/build-nuget.yml
blob: c7cf4ca26e0a55eb38d5bc02c8ca25b4b97d6273 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
name: Build NuGet Package
on:
  push:
    tags: [ '[0-9]+.[0-9]+.[0-9]+' ]
  workflow_dispatch:
    inputs:
      version:
        description: 'The optional semantic version number. If not supplied the branch/tag will be used.'
        type: string
      no_publish:
          description: 'Prevent publishing the NuGet package. Just build it and then upload it as an artifact.'
          type: boolean
          default: false

jobs:
  package-windows-latest:
    runs-on: windows-latest
    steps:
    - name: Set version based on input
      if: ${{ inputs.version }}
      run: echo "RELEASE_VERSION=${{ inputs.version }}" | Out-File -Append -FilePath $env:GITHUB_ENV -Encoding utf8
    - name: Set version based on ref
      if: ${{ !inputs.version }}
      run: echo "RELEASE_VERSION=$($env:GITHUB_REF -replace 'refs/.*/', '')" | Out-File -Append -FilePath $env:GITHUB_ENV -Encoding utf8
    - name: Print Version
      run: echo "NuGet version will be '${{ env.RELEASE_VERSION }}'"
    - 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: "Copy Readme.md"
      run: xcopy /y ${{github.workspace}}\README.md ${{github.workspace}}\nuget
    - name: "Create NuGet package"
      env: 
        VERSION: ${{ env.RELEASE_VERSION }}
        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"
      if: ${{ !inputs.no_publish }}
      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