From 3f32d49ab346f14719209a6d496adb6178d3cd2b Mon Sep 17 00:00:00 2001
From: MiroKaku <50670906+MiroKaku@users.noreply.github.com>
Date: Mon, 23 May 2022 16:39:23 +0800
Subject: [PATCH] feat: nuget
---
.github/workflows/build.yaml | 88 ++++++++++++++++++++++++++++++++++
.github/workflows/main.yaml | 42 ----------------
.github/workflows/release.yaml | 41 ----------------
nuget/ucxxrt.nuspec | 28 +++++++++++
nuget/ucxxrt.props | 6 +++
5 files changed, 122 insertions(+), 83 deletions(-)
create mode 100644 .github/workflows/build.yaml
delete mode 100644 .github/workflows/main.yaml
delete mode 100644 .github/workflows/release.yaml
create mode 100644 nuget/ucxxrt.nuspec
create mode 100644 nuget/ucxxrt.props
diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml
new file mode 100644
index 0000000..d51c3d1
--- /dev/null
+++ b/.github/workflows/build.yaml
@@ -0,0 +1,88 @@
+# This is a basic workflow to help you get started with Actions
+
+name: Build & Publish
+
+# Controls when the action will run. Triggers the workflow on push or pull request
+# events but only for the master branch
+on: [push, pull_request]
+
+# A workflow run is made up of one or more jobs that can run sequentially or in parallel
+jobs:
+ # This workflow contains a single job called "build"
+ build:
+ # The type of runner that the job will run on
+ runs-on: windows-2019
+
+ # Any commit that contains [build] will now trigger these jobs, everything else will be skipped.
+ # if: "contains(github.event.head_commit.message, '[build]')"
+
+ # Steps represent a sequence of tasks that will be executed as part of the job
+ steps:
+ # Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
+ - uses: actions/checkout@v3
+
+ - name: build nuspec
+ if: contains(github.ref, 'tags/')
+ working-directory: ${{github.workspace}}
+ shell: pwsh
+ run: |
+ if($env:GITHUB_REF.StartsWith("refs/tags/v", "CurrentCultureIgnoreCase"))
+ {
+ $BuildVersion = $env:GITHUB_REF.Remove(0, 11);
+ echo "BuildVersion=$BuildVersion" >> $env:GITHUB_ENV
+
+ # github的内置版本有Bug,此行必须添加,否则无法获得内容
+ git fetch --depth=1 origin +refs/tags/*:refs/tags/*
+
+ $releaseNotes = & git tag -l --format='%(contents)' $env:GITHUB_REF.Remove(0, 10)
+ $content = [System.IO.File]::ReadAllText("nuget\ucxxrt.nuspec")
+
+ $releaseNotesToken = '$releaseNotes$'
+ $releaseNotesIndex = $content.IndexOf($releaseNotesToken)
+
+ if($releaseNotesIndex -ne -1)
+ {
+ echo $content.Substring(0, $releaseNotesIndex) | out-file "nuget\ucxxrt-new.nuspec" -NoNewline
+ echo $releaseNotes | out-file "nuget\ucxxrt-new.nuspec" -Append
+ echo $content.Remove(0, $releaseNotesIndex + $releaseNotesToken.Length) | out-file "nuget\ucxxrt-new.nuspec" -NoNewline -Append
+ }
+ }
+
+ - name: compile
+ working-directory: ${{github.workspace}}
+ shell: cmd
+ run: call .\.github\workflows\build.bat
+
+ - name: upload an artifact
+ uses: actions/upload-artifact@v3
+ with:
+ name: ucxxrt
+ path: ucxxrt\
+ if-no-files-found: error
+
+ - name: pack zip
+ if: contains(github.ref, 'tags/')
+ working-directory: ${{github.workspace}}
+ shell: cmd
+ run: 7z a -tzip ucxxrt.zip ucxxrt\
+
+ - name: pack nuget
+ if: contains(github.ref, 'tags/')
+ working-directory: ${{github.workspace}}
+ shell: cmd
+ run: |
+ if "${{env.BuildVersion}}" NEQ "" (
+ nuget pack nuget\ucxxrt-new.nuspec -Properties version=${{env.BuildVersion}};commit=%GITHUB_SHA%
+ )
+
+ if %ERRORLEVEL% NEQ 0 exit /B %ERRORLEVEL%
+
+ - name: publish a version
+ if: contains(github.ref, 'tags/')
+ uses: "marvinpinto/action-automatic-releases@v1.2.1"
+ with:
+ repo_token: "${{ secrets.GITHUB_TOKEN }}"
+ prerelease: false
+ files: |
+ ucxxrt.zip
+ nuget\*.nupkg
\ No newline at end of file
diff --git a/.github/workflows/main.yaml b/.github/workflows/main.yaml
deleted file mode 100644
index f6d5e5e..0000000
--- a/.github/workflows/main.yaml
+++ /dev/null
@@ -1,42 +0,0 @@
-# This is a basic workflow to help you get started with Actions
-
-name: CI
-
-# Controls when the action will run. Triggers the workflow on push or pull request
-# events but only for the master branch
-on:
- push:
- branches: [ master ]
- pull_request:
- branches: [ master ]
-
-# A workflow run is made up of one or more jobs that can run sequentially or in parallel
-jobs:
- # This workflow contains a single job called "build"
- build:
- # The type of runner that the job will run on
- runs-on: windows-2019
-
- # Any commit that contains [build] will now trigger these jobs, everything else will be skipped.
- # if: "contains(github.event.head_commit.message, '[build]')"
-
- # Steps represent a sequence of tasks that will be executed as part of the job
- steps:
- # Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- - name: Checkout
- uses: actions/checkout@v2
-
- - name: Build Library
- shell: cmd
- run: call .\.github\workflows\build.bat
-
- #- name: Build Artifact
- # shell: cmd
- # run: 7z a -tzip ucxxrt.zip ucxxrt\
-
- - name: Upload a Build Artifact
- uses: actions/upload-artifact@v3
- with:
- name: ucxxrt
- path: ucxxrt\
- if-no-files-found: error
diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml
deleted file mode 100644
index ee8b789..0000000
--- a/.github/workflows/release.yaml
+++ /dev/null
@@ -1,41 +0,0 @@
-# This is a basic workflow to help you get started with Actions
-
-name: CI-Release
-
-# Controls when the action will run. Triggers the workflow on push or pull request
-# events but only for the master branch
-on:
- push:
- tags:
- - "v*"
-
-# A workflow run is made up of one or more jobs that can run sequentially or in parallel
-jobs:
- # This workflow contains a single job called "build"
- build:
- # The type of runner that the job will run on
- runs-on: windows-2019
-
- # Any commit that contains [build] will now trigger these jobs, everything else will be skipped.
- # if: "contains(github.event.head_commit.message, '[build]')"
-
- # Steps represent a sequence of tasks that will be executed as part of the job
- steps:
- # Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- - name: Checkout
- uses: actions/checkout@v2
-
- - name: Build Library
- shell: cmd
- run: call .\.github\workflows\build.bat
-
- - name: Build Artifact
- shell: cmd
- run: 7z a -tzip ucxxrt.zip ucxxrt\
-
- - name: Release a Build Artifact
- uses: "marvinpinto/action-automatic-releases@v1.2.1"
- with:
- repo_token: "${{ secrets.GITHUB_TOKEN }}"
- prerelease: false
- files: ucxxrt.zip
diff --git a/nuget/ucxxrt.nuspec b/nuget/ucxxrt.nuspec
new file mode 100644
index 0000000..7f26ea7
--- /dev/null
+++ b/nuget/ucxxrt.nuspec
@@ -0,0 +1,28 @@
+
+
+
+ ucxxrt
+ $version$
+ Universal C++ RunTime (UCXXRT)
+ MiroKaku (MeeSong)
+ MiroKaku (MeeSong)
+ true
+ true
+ lib\native\LICENSE
+ lib\native\README.md
+ https://github.com/MiroKaku/ucxxrt
+ The Universal C++ RunTime library, supporting kernel-mode C++ exception-handler and STL.
+ $releaseNotes$
+ Copyright© MiroKaku
+ en-US
+ ucxxrt wdk driver kernel
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/nuget/ucxxrt.props b/nuget/ucxxrt.props
new file mode 100644
index 0000000..9ef1ec6
--- /dev/null
+++ b/nuget/ucxxrt.props
@@ -0,0 +1,6 @@
+
+
+
+ $(NuGetImportAfterCppProps);$(MSBuildThisFileDirectory)..\lib\native\ucxxrt.props
+
+
\ No newline at end of file