diff --git a/.github/workflows/build-upm-from-project-folder.yml b/.github/workflows/build-upm-from-project-folder.yml new file mode 100644 index 0000000..6594ab3 --- /dev/null +++ b/.github/workflows/build-upm-from-project-folder.yml @@ -0,0 +1,51 @@ +# Based on https://github.com/UCL-VR/ubiq/blob/master/.github/workflows/build-upm-from-project-folder.yml +on: + workflow_call: + inputs: + project-folder: + required: true + type: string + upm-branch: + required: true + type: string +jobs: + build: + runs-on: ubuntu-latest + steps: + - name: Checkout release + uses: actions/checkout@v3 + with: + ref: ${{ github.ref }} + - name: Remove everything except for our project + run: | + git rm -rf . + git checkout HEAD -- ${{ inputs.project-folder }}/* + git mv ${{ inputs.project-folder }}/* . + rm -rf ${{ inputs.project-folder }} + - name: Fetch branch + run: git fetch origin ${{ inputs.upm-branch }}:${{ inputs.upm-branch }} || true + - name: Create upm branch if it does not yet exist + run: git branch ${{ inputs.upm-branch }} || true + - name: Move to upm branch without changing working copy + run: | + git checkout --detach + git reset --soft ${{ inputs.upm-branch }} + git checkout ${{ inputs.upm-branch }} + - name: Rename samples to prevent Unity auto-import + run: git mv Samples Samples~ + - name: Remove samples .meta file to stop empty folder import + run: git rm -f Samples.meta + - name: Print folder contents (for debug) + run: ls -R | grep ":$" | sed -e 's/:$//' -e 's/[^-][^\/]*\// /g' -e 's/^/ /' + - name: Config user name + run: git config --global user.name "github-actions[bot]" + - name: Config user email + run: git config --global user.email "41898282+github-actions[bot]@users.noreply.github.com" + - name: Add + run: git add * + - name: Commit + run: git commit -m "Add upm package for ${GITHUB_REF#refs/*/}" + - name: Tag + run: git tag -a upm-${GITHUB_REF#refs/*/} -m "" + - name: Push + run: git push --follow-tags --set-upstream origin ${{ inputs.upm-branch }} diff --git a/.github/workflows/upm.yml b/.github/workflows/upm.yml index 0657cce..91b3c21 100644 --- a/.github/workflows/upm.yml +++ b/.github/workflows/upm.yml @@ -1,54 +1,10 @@ name: Update upm branch on release on: - release: - types: [published] + push: + tags: [ 'unity-v*.*.*' ] jobs: - build: - name: Build and commit to upm branch - runs-on: ubuntu-latest - steps: - - name: Checkout release - uses: actions/checkout@v3 - with: - ref: ${{ github.ref }} - - name: Fetch branch - run: git fetch origin upm:upm || true - - name: Create upm branch if it does not yet exist - run: git branch upm || true - - name: Move to upm branch without changing working copy P0 - run: git checkout --detach - - name: Move to upm branch without changing working copy P1 - run: git reset --soft upm - - name: Move to upm branch without changing working copy P2 - run: git checkout upm - - name: Create upm package - run: | - git rm -rf rest - git rm -rf rest_python - git rm -rf aiohttp_mjpeg - git rm -rf .github - git rm -rf Packages - git rm -rf ProjectSettings - git rm -f README.md - git rm -f LICENSE - git rm -rf ./Assets/Local - git rm -rf ./Assets/Local.meta - git mv ./Assets/* . - rm -rf Assets - git mv Samples Samples~ - git rm -f Samples.meta - git rm -f .gitignore - git rm -f Unity.gitignore - ls -R | grep ":$" | sed -e 's/:$//' -e 's/[^-][^\/]*\// /g' -e 's/^/ /' - - name: Config user name - run: git config --global user.name "github-actions[bot]" - - name: Config user email - run: git config --global user.email "41898281+github-actions[bot]@users.noreply.github.com" - - name: Add - run: git add * - - name: Commit - run: git commit -m "Add upm package for ${GITHUB_REF#refs/*/}" - - name: Tag - run: git tag -a ${GITHUB_REF#refs/*/}-upm -m "" - - name: Push - run: git push --follow-tags --set-upstream origin upm + build-upm: + uses: ./.github/workflows/build-upm-from-project-folder.yml + with: + project-folder: Assets/Lab/Core + upm-branch: upm \ No newline at end of file