diff --git a/.github/workflows/publish-nuget.yaml b/.github/workflows/publish-nuget.yaml new file mode 100644 index 0000000..734d1d4 --- /dev/null +++ b/.github/workflows/publish-nuget.yaml @@ -0,0 +1,112 @@ +name: Build & Publish NuGet Package + +on: + push: + branches: + - master + release: + types: [created] + +permissions: + contents: write + packages: write + +jobs: + build-and-publish: + runs-on: ubuntu-latest + env: + NUGET_API_KEY: ${{ secrets.NUGET_API_KEY }} + + steps: + - name: Checkout code + uses: actions/checkout@v6 + with: + fetch-depth: 0 + submodules: 'recursive' + + - name: Set up .NET + uses: actions/setup-dotnet@v5 + with: + dotnet-version: '10.0.x' + + - name: Download OpenVR Dependencies + run: | + curl -L -o openvr_api.cs https://raw.githubusercontent.com/ValveSoftware/openvr/master/headers/openvr_api.cs + + - name: Restore dependencies + run: dotnet restore + + - name: Build the project + run: dotnet build --configuration Release --no-restore + + - name: Determine version + id: version + run: | + if [ "${{ github.event_name }}" == "release" ]; then + VERSION="${{ github.event.release.tag_name }}" + VERSION="${VERSION#v}" + else + LATEST_TAG=$(git describe --tags --abbrev=0 2>/dev/null || echo "v0.0.0") + BASE_VERSION="${LATEST_TAG#v}" + MAJOR=$(echo $BASE_VERSION | cut -d. -f1) + MINOR=$(echo $BASE_VERSION | cut -d. -f2) + PATCH=$(echo $BASE_VERSION | cut -d. -f3) + NEXT_PATCH=$((PATCH + 1)) + VERSION="${MAJOR}.${MINOR}.${NEXT_PATCH}-preview.${{ github.run_number }}" + fi + echo "version=$VERSION" >> $GITHUB_OUTPUT + + - name: Pack the project + run: dotnet pack --configuration Release --no-build -o ./nupkg -p:Version=${{ steps.version.outputs.version }} + + - name: Upload package as artifact + id: upload-artifact + uses: actions/upload-artifact@v7 + with: + name: nuget-package + path: ./nupkg/*.nupkg + + - name: Upload package to release + id: upload-release + if: github.event_name == 'release' + run: gh release upload ${{ github.event.release.tag_name }} ./nupkg/*.nupkg + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + + - name: Push package to GitHub Packages + id: push-github + run: | + dotnet nuget add source \ + --username ${{ github.actor }} \ + --password ${{ secrets.GITHUB_TOKEN }} \ + --store-password-in-clear-text \ + --name github \ + "https://nuget.pkg.github.com/${{ github.repository_owner }}/index.json" + dotnet nuget push ./nupkg/*.nupkg --source github --skip-duplicate + + - name: Push package to NuGet + id: push-nuget + if: github.event_name == 'release' && env.NUGET_API_KEY != '' + run: dotnet nuget push ./nupkg/*.nupkg --source https://api.nuget.org/v3/index.json --api-key ${{ env.NUGET_API_KEY }} --skip-duplicate + + - name: Job summary + if: always() + run: | + echo "## NuGet Package" >> $GITHUB_STEP_SUMMARY + echo "" >> $GITHUB_STEP_SUMMARY + echo "**Version:** \`${{ steps.version.outputs.version }}\`" >> $GITHUB_STEP_SUMMARY + echo "" >> $GITHUB_STEP_SUMMARY + echo "### Links" >> $GITHUB_STEP_SUMMARY + echo "" >> $GITHUB_STEP_SUMMARY + if [ "${{ steps.upload-artifact.outcome }}" == "success" ]; then + echo "- [Artifact (this run)](https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}#artifacts)" >> $GITHUB_STEP_SUMMARY + fi + if [ "${{ steps.push-github.outcome }}" == "success" ]; then + echo "- [GitHub Packages](https://github.com/${{ github.repository }}/pkgs/nuget/EasyOpenVR)" >> $GITHUB_STEP_SUMMARY + fi + if [ "${{ steps.upload-release.outcome }}" == "success" ]; then + echo "- [GitHub Release](https://github.com/${{ github.repository }}/releases/tag/${{ github.event.release.tag_name }})" >> $GITHUB_STEP_SUMMARY + fi + if [ "${{ steps.push-nuget.outcome }}" == "success" ]; then + echo "- [NuGet.org](https://www.nuget.org/packages/EasyOpenVR/${{ steps.version.outputs.version }})" >> $GITHUB_STEP_SUMMARY + fi diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 0000000..16f8cfb --- /dev/null +++ b/.gitmodules @@ -0,0 +1,3 @@ +[submodule "EasyUtils"] + path = EasyUtils + url = https://github.com/BOLL7708/EasyUtils.git \ No newline at end of file diff --git a/EasyOpenVR.csproj b/EasyOpenVR.csproj index 5932b67..c0d21d3 100644 --- a/EasyOpenVR.csproj +++ b/EasyOpenVR.csproj @@ -5,6 +5,16 @@ disable enable 14 + + EasyOpenVR + BOLL7708 + This is a Class Library to make it easier to talk to the OpenVR API using the official C# headers + openvr steamvr openvr-api + https://github.com/BOLL7708/EasyOpenVR + https://github.com/BOLL7708/EasyOpenVR + git + LICENSE.md + README.md @@ -18,4 +28,9 @@ + + + + +