diff --git a/.github/workflows/publish-nuget.yml b/.github/workflows/publish-nuget.yml index 53a5ac0..e252141 100644 --- a/.github/workflows/publish-nuget.yml +++ b/.github/workflows/publish-nuget.yml @@ -1,8 +1,9 @@ name: Publish to NuGet on: - release: - types: [published, created, edited, prereleased] + push: + tags: # v1.0, v1.1, etc.. + - v* jobs: publish: @@ -13,16 +14,15 @@ jobs: uses: actions/setup-dotnet@v1 with: dotnet-version: 3.1.301 - source-url: https://nuget.pkg.github.com/cathei/index.json - env: - NUGET_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }} - name: Install dependencies run: dotnet restore - name: Generate packages run: | - $env:RELEASE_VERSION = $env:RELEASE_TAG.substring(1) # Remove 'v' + $env:RELEASE_VERSION = $env:GITHUB_REF.substring(11) # Remove 'refs/tags/v' dotnet pack -c Release -p:PackageVersion=$env:RELEASE_VERSION -o out --no-restore + - name: Setup NuGet Source + run: dotnet nuget add source https://nuget.pkg.github.com/cathei/index.json --name github --username cathei --password $env:NUGET_TOKEN env: - RELEASE_TAG: ${{ github.event.release.tag_name }} + NUGET_TOKEN: ${{ secrets.NUGET_TOKEN }} - name: Publish packages - run: dotnet nuget push out\*.nupkg --skip-duplicate + run: dotnet nuget push out\*.nupkg -s github --skip-duplicate diff --git a/.github/workflows/publish-unity.yml b/.github/workflows/publish-unity.yml index b4cd3cb..c5b796f 100644 --- a/.github/workflows/publish-unity.yml +++ b/.github/workflows/publish-unity.yml @@ -1,40 +1,34 @@ name: Publish UnityPackage on: - release: - types: [published, created, edited, prereleased] + push: + tags: # v1.0, v1.1, etc.. + - v* jobs: generate-pacakge: runs-on: ubuntu-latest strategy: fail-fast: false - matrix: - projectPath: - - UnityProject - unityVersion: - - 2020.1.5f1 - targetPlatform: - - StandaloneLinux64 steps: - uses: actions/checkout@v2 - uses: actions/cache@v1.1.0 with: - path: ${{ matrix.projectPath }}/Library - key: Library-${{ matrix.projectPath }} - restore-keys: | - Library- + path: UnityProject/Library + key: Library - name: Generate package uses: webbertakken/unity-builder@v1.4 + env: + UNITY_LICENSE: ${{ secrets.UNITY_LICENSE }} with: - projectPath: ${{ matrix.projectPath }} - unityVersion: ${{ matrix.unityVersion }} - targetPlatform: ${{ matrix.targetPlatform }} + projectPath: UnityProject + unityVersion: 2020.1.5f1 + targetPlatform: StandaloneLinux64 + buildsPath: Build + versioning: None buildMethod: Cathei.BakingSheet.Editor.PackageGenerationTools.GeneratePackage - env: - RELEASE_TAG: ${{ github.event.release.tag_name }} - name: Upload Unity package uses: actions/upload-artifact@v2 with: - name: Unity package - path: BakingSheet.*.unitypackage + name: Unity Package + path: Build/*.unitypackage diff --git a/UnityProject/Assets/PackageGeneration/PackageGenerationTools.cs b/UnityProject/Assets/PackageGeneration/PackageGenerationTools.cs index b7a4bbe..fef0e64 100644 --- a/UnityProject/Assets/PackageGeneration/PackageGenerationTools.cs +++ b/UnityProject/Assets/PackageGeneration/PackageGenerationTools.cs @@ -1,6 +1,7 @@ using System; using System.Collections; using System.Collections.Generic; +using System.IO; using UnityEditor; using UnityEngine; @@ -11,16 +12,19 @@ public static class PackageGenerationTools [MenuItem("Tools/Generate Package")] public static void GeneratePackage() { - var releaseTag = Environment.GetEnvironmentVariable("RELEASE_TAG"); + var githubRef = Environment.GetEnvironmentVariable("GITHUB_REF"); - // RELEASE_TAG = v1.X.X - // remove 'v' from tag - if (releaseTag != null) - PlayerSettings.bundleVersion = releaseTag.Substring(1); + // GITHUB_REF = refs/heads/v1.X.X + if (githubRef != null) + PlayerSettings.bundleVersion = githubRef.Substring(11); + + var outputPath = Path.Combine( + Path.GetDirectoryName(Directory.GetCurrentDirectory()), "Build", + $"BakingSheet.{PlayerSettings.bundleVersion}.unitypackage"); AssetDatabase.ExportPackage(new string [] { "Assets/Plugins/BakingSheet" - }, $"BakingSheet.{PlayerSettings.bundleVersion}.unitypackage", ExportPackageOptions.Recurse); + }, outputPath, ExportPackageOptions.Recurse); Debug.Log("Generating Unity Package Completed"); }