Skip to content
This repository has been archived by the owner on Jul 12, 2024. It is now read-only.

Commit

Permalink
feat: nuget
Browse files Browse the repository at this point in the history
  • Loading branch information
MiroKaku committed May 23, 2022
1 parent 684c787 commit 3f32d49
Show file tree
Hide file tree
Showing 5 changed files with 122 additions and 83 deletions.
88 changes: 88 additions & 0 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
@@ -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
42 changes: 0 additions & 42 deletions .github/workflows/main.yaml

This file was deleted.

41 changes: 0 additions & 41 deletions .github/workflows/release.yaml

This file was deleted.

28 changes: 28 additions & 0 deletions nuget/ucxxrt.nuspec
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<?xml version="1.0" encoding="utf-8"?>
<package xmlns="http://schemas.microsoft.com/packaging/2013/01/nuspec.xsd">
<metadata minClientVersion="2.5">
<id>ucxxrt</id>
<version>$version$</version>
<title>Universal C++ RunTime (UCXXRT)</title>
<authors>MiroKaku (MeeSong)</authors>
<owners>MiroKaku (MeeSong)</owners>
<developmentDependency>true</developmentDependency>
<requireLicenseAcceptance>true</requireLicenseAcceptance>
<license type="file">lib\native\LICENSE</license>
<readme>lib\native\README.md</readme>
<projectUrl>https://github.com/MiroKaku/ucxxrt</projectUrl>
<description>The Universal C++ RunTime library, supporting kernel-mode C++ exception-handler and STL.</description>
<releaseNotes>$releaseNotes$</releaseNotes>
<copyright>Copyright© MiroKaku</copyright>
<language>en-US</language>
<tags>ucxxrt wdk driver kernel</tags>
<repository type="git" url="https://github.com/MiroKaku/ucxxrt.git" branch="master" commit="$commit$" />
<dependencies>
<dependency id="YY.NuGet.Import.Helper" version="1.0.0.4" />
</dependencies>
</metadata>
<files>
<file src="ucxxrt.props" target="build\ucxxrt.props" />
<file src="..\ucxxrt\**" target="lib\native" exclude="**\*.lastcodeanalysissucceeded;"/>
</files>
</package>
6 changes: 6 additions & 0 deletions nuget/ucxxrt.props
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<NuGetImportAfterCppProps Condition="Exists('$(MSBuildThisFileDirectory)..\lib\native\ucxxrt.props')">$(NuGetImportAfterCppProps);$(MSBuildThisFileDirectory)..\lib\native\ucxxrt.props</NuGetImportAfterCppProps>
</PropertyGroup>
</Project>

0 comments on commit 3f32d49

Please sign in to comment.