Skip to content

Build Release

Build Release #18

Workflow file for this run

name: Build Release
on:
workflow_dispatch:
jobs:
config:
runs-on: ubuntu-latest
outputs:
config_package: ${{ steps.config_package.outputs.configPackage }}
steps:
- name: Ensure that required repository variable has been created for the Package
id: config_package
run: |
if [ "${{ vars.PACKAGE_NAME }}" != "" ]; then
echo "configPackage=true" >> $GITHUB_OUTPUT;
else
echo "configPackage=false" >> $GITHUB_OUTPUT;
fi
build:
needs: config
runs-on: ubuntu-latest
permissions:
contents: write
env:
packagePath: Packages/${{ vars.PACKAGE_NAME }}
if: needs.config.outputs.config_package == 'true'
steps:
- name: Checkout Local Repository
uses: actions/checkout@v4
- name: copy the README and LICENSE files to the Package folder
run: cp README.md LICENSE "${{ env.packagePath }}"
- name: Get the Package version based on the package.json file
id: version
uses: sergeysova/jq-action@v2
with:
cmd: jq -r '.version' "${{ env.packagePath }}/package.json"
- name: Configure the Environment Variables needed for releasing the Package
run: |
echo "zipFile=${{ vars.PACKAGE_NAME }}-${{ steps.version.outputs.value }}".zip >> $GITHUB_ENV
echo "unityPackage=${{ vars.PACKAGE_NAME }}-${{ steps.version.outputs.value }}.unitypackage" >> $GITHUB_ENV
echo "version=${{ steps.version.outputs.value }}" >> $GITHUB_ENV
- name: Zip the Package for release
working-directory: "${{ env.packagePath }}"
run: zip -r -9 "${{ github.workspace }}/${{ env.zipFile }}" .
- name: Build a list of .meta files for future use
run: find "${{ env.packagePath }}/" -name \*.meta >> metaList
- name: Make a UnityPackage version of the Package for release
uses: pCYSl5EDgo/create-unitypackage@v1
with:
package-path: ${{ env.unityPackage }}
include-files: metaList
- name: Zip the UnityPackage for release
run: zip -r -9 "${{ env.unityPackage }}.zip" ${{ env.unityPackage }} LICENSE README.md
- name: Make a release tag of the version from the package.json file
id: tag_version
uses: rickstaa/action-create-tag@v1
with:
tag: "${{ env.version }}"
- name: Publish the Release to GitHub
uses: softprops/action-gh-release@v2
with:
files: |
${{ env.zipFile }}
${{ env.unityPackage }}
${{ env.unityPackage }}.zip
${{ env.packagePath }}/package.json
tag_name: ${{ env.version }}