Skip to content

Commit

Permalink
Update publish scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
cathei committed Oct 7, 2020
1 parent 2a2cd61 commit 398b5c8
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 34 deletions.
16 changes: 8 additions & 8 deletions .github/workflows/publish-nuget.yml
Original file line number Diff line number Diff line change
@@ -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:
Expand All @@ -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
34 changes: 14 additions & 20 deletions .github/workflows/publish-unity.yml
Original file line number Diff line number Diff line change
@@ -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
16 changes: 10 additions & 6 deletions UnityProject/Assets/PackageGeneration/PackageGenerationTools.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using UnityEditor;
using UnityEngine;

Expand All @@ -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");
}
Expand Down

0 comments on commit 398b5c8

Please sign in to comment.