diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 0000000..c3905fa --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,59 @@ +name: Build + +on: + workflow_call: + outputs: + version: + value: ${{ jobs.build.outputs.version }} + +env: + PACKAGE_NAME: dev.paltee.avatar-aid + +jobs: + build: + runs-on: ubuntu-latest + outputs: + version: ${{ steps.version.outputs.value }} + steps: + - name: Setup package path + run: echo "PACKAGE_PATH=Packages/${{ env.PACKAGE_NAME }}" >> $GITHUB_ENV + + - name: Checkout repository + uses: actions/checkout@v4 + with: + path: "${{ env.PACKAGE_PATH }}" + + - name: Read package version + id: version + run: echo "value=$(cat "${{ env.PACKAGE_PATH }}/package.json" | jq -r '.version')" >> $GITHUB_OUTPUT + + - name: Setup environment variables + run: | + echo "ZIP_FILE_PATH=${{ env.PACKAGE_NAME }}-${{ steps.version.outputs.value }}.zip" >> $GITHUB_ENV + echo "UNITY_PACKAGE_PATH=${{ env.PACKAGE_NAME }}-${{ steps.version.outputs.value }}.unitypackage" >> $GITHUB_ENV + echo "VERSION=${{ steps.version.outputs.value }}" >> $GITHUB_ENV + + - name: Create ZIP file + working-directory: ${{ env.PACKAGE_PATH }} + run: zip -r "${{ github.workspace }}/${{ env.ZIP_FILE_PATH }}" . -x '.*' 'Tests/*' Tests.meta + + - name: Create meta files list + run: find "${{ env.PACKAGE_PATH }}" -type f -name "*.meta" | grep -Ev "^${{ env.PACKAGE_PATH }}/Tests" > metaList + + - name: Create Unity package + uses: pCYSl5EDgo/create-unitypackage@master + with: + package-path: ${{ env.UNITY_PACKAGE_PATH }} + include-files: metaList + + - name: Copy package.json + run: cp ${{ env.PACKAGE_PATH }}/package.json package.json + + - name: Upload artifacts + uses: actions/upload-artifact@v4 + with: + name: Artifacts + path: | + ${{ env.UNITY_PACKAGE_PATH }} + ${{ env.ZIP_FILE_PATH }} + package.json diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..d624f93 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,32 @@ +name: Build and Release + +on: + workflow_dispatch: + +jobs: + build: + uses: ./.github/workflows/build.yml + + release: + runs-on: ubuntu-latest + needs: build + steps: + - name: Download artifacts + uses: actions/download-artifact@v4 + + - name: Check existing release + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: | + if [ "$(gh release view --repo ${{ github.repository }} ${{ needs.build.outputs.version }} 2>&1)" != 'release not found' ]; then + echo "Release already exists" + exit 1 + fi + + - name: Create release + uses: softprops/action-gh-release@v2 + with: + tag_name: ${{ needs.build.outputs.version }} + draft: true + files: | + Artifacts/* diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index a0e2ae2..b5c2690 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -10,6 +10,9 @@ on: - reopened jobs: + build: + uses: ./.github/workflows/build.yml + test: name: Test runs-on: ubuntu-latest