This GitHub Action helps edit package json file to add samples from assets
Add this step in your workflow file
- name: Copy Asset Samples to NPM Samples~
uses: unbndgroup/action-npm-unity-samples
with:
packageFolderName: Packages/com.thisisaura.package.example
assetSampleFolder: Assets/Samples
packageFolderName
: Folder name of Package to copy into e.gPackages/com.thisisaura.*
(Optional) default to the first folder in packages.assetSampleFolder
: Samples Folder in Unity assets folderAssets/Samples
package.Json
file withinPackages/YOUR_PACKAGE_NAME/
Assets/Samples/YOUR_SAMPLE
folder- Optional
Assets/Samples/YOUR_SAMPLE/description.txt
file - No folder or files under the directory
Packages/YOUR_PACKAGE_NAME/Samples~
- Within a unity package repo ensure the assets folder has
Samples
folder. - Create a new folder with the samples name under the
Assets/Samples/
folder. - Add any sample assets and folders into the created folder.
- Optionally Within
Assets/Samples/YOUR_SAMPLE_FOLDER
add a txt file nameddescription.txt
within it place any futher information for this sample within it.
- On merge to a packages main branch before pushing to NPM a copy of the
Assets/Samples
is made and moved toPackages/YOUR_PACKAGE_NAME/Samples~
- The
Packages/YOUR_PACKAGE_NAME/package.json
is edited to include allPackages/YOUR_PACKAGE_NAME/Samples~
subfolder directories. Packages/YOUR_PACKAGE_NAME/Samples~/YOUR_SAMPLE_FOLDER
is checked for adescription.txt
and writes the contents into thePackages/YOUR_PACKAGE_NAME/package.json
.