Skip to content

Commit c73b035

Browse files
authored
Merge pull request #82 from IShix-g/release
feat: add support for custom Unity package naming
2 parents cbed6b4 + c113585 commit c73b035

File tree

3 files changed

+36
-7
lines changed

3 files changed

+36
-7
lines changed

.github/workflows/reusable-build-package.yaml

Lines changed: 31 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,10 @@ on:
77
description: 'Git tag you want to create (e.g., 1.0.0).'
88
required: true
99
type: string
10+
package-name:
11+
description: 'Specify the Unity package name without an extension.'
12+
required: true
13+
type: string
1014
commit-id:
1115
description: 'Commit ID for release and tag.'
1216
required: false
@@ -78,13 +82,38 @@ jobs:
7882
UNITY_PASSWORD: ${{ secrets.UNITY_PASSWORD }}
7983
with:
8084
targetPlatform: StandaloneLinux64
81-
customParameters: -tag ${{ inputs.tag }} ${{ inputs.custom-parameters }}
85+
buildName: ${{ inputs.package-name }}_${{ inputs.tag }}.unitypackage
8286
unityVersion: ${{ inputs.unity-version }}
8387
projectPath: ${{ inputs.project-path }}
8488
buildsPath: ${{ inputs.builds-path }}
8589
buildMethod: ${{ inputs.build-method }}
90+
customParameters: -tag ${{ inputs.tag }} ${{ inputs.custom-parameters }}
91+
92+
- name: Normalize Path
93+
id: path-normalizer
94+
run: |
95+
project_path="${{ inputs.project-path }}"
96+
builds_path="${{ inputs.builds-path }}"
97+
package_name="${{ inputs.package-name }}"
98+
tag="${{ inputs.tag }}"
99+
100+
builds_path="${builds_path%/}"
101+
project_path="${project_path%/}"
102+
builds_path="${builds_path%/}"
103+
104+
if [ -z "$project_path" ]; then
105+
final_path="./$builds_path/StandaloneLinux64/${package_name}_${tag}.unitypackage"
106+
else
107+
final_path="./$project_path/$builds_path/StandaloneLinux64/${package_name}_${tag}.unitypackage"
108+
fi
109+
110+
normalized_path=$(echo "$final_path" | sed 's://*:/:g')
111+
112+
echo "path=$normalized_path" >> "$GITHUB_OUTPUT"
113+
echo "::notice title=Export Path:: $normalized_path"
114+
shell: bash
86115

87116
- uses: actions/upload-artifact@v4
88117
with:
89118
name: Build-StandaloneLinux64
90-
path: /github/workspace/${{ inputs.builds-path }}/StandaloneLinux64
119+
path: ${{ steps.path-normalizer.outputs.path }}

.github/workflows/test-build-package.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,5 +34,6 @@ jobs:
3434
UNITY_EMAIL: ${{ secrets.UNITY_EMAIL }}
3535
UNITY_PASSWORD: ${{ secrets.UNITY_PASSWORD }}
3636
with:
37+
package-name: 'Test'
3738
tag: '1.0.0'
3839
unity-version: ${{ inputs.unity-version }}

Assets/Editor/PackageExporter.cs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,17 +10,16 @@
1010
public sealed class PackageExporter
1111
{
1212
const string _folderPath = "Assets/Plugins/TestExportPackage";
13-
const string _exportPath = "TestExportPackage_{version}.unitypackage";
14-
static string _eol = Environment.NewLine;
1513

1614
[MenuItem("Tools/Export Unitypackage")]
17-
public static void ExportTest() => Export(_folderPath, ToExportPath(_exportPath, "1.0.0"));
15+
public static void ExportTest() => Export(_folderPath, "Test.unitypackage");
1816

1917
public static void Export()
2018
{
2119
var options = ArgumentsParser.GetValidatedOptions();
2220
var buildPath = options.GetValueOrDefault("customBuildPath")?.TrimEnd('/');
23-
var exportPath = (!string.IsNullOrEmpty(buildPath) ? buildPath + "/" : "") + ToExportPath(_exportPath, options.GetValueOrDefault("tag"));
21+
var buildName = options.GetValueOrDefault("buildName");
22+
var exportPath = (!string.IsNullOrEmpty(buildPath) ? buildPath + "/" : "") + buildName;
2423
Export(_folderPath, exportPath);
2524
}
2625

@@ -30,7 +29,7 @@ public static void Export(string folderPath, string exportPath)
3029
.Select(AssetDatabase.GUIDToAssetPath)
3130
.ToArray();
3231

33-
PrintLog("Export below files" + _eol + string.Join(_eol, assets));
32+
PrintLog("Export below files" + Environment.NewLine + string.Join(Environment.NewLine, assets));
3433

3534
AssetDatabase.ExportPackage(
3635
assets,

0 commit comments

Comments
 (0)