|
| 1 | +name: Update Unity UPM semantic versioning |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: |
| 6 | + - master |
| 7 | + |
| 8 | +jobs: |
| 9 | + checkSemver: |
| 10 | + name: Check for Semver Change |
| 11 | + runs-on: ubuntu-latest |
| 12 | + outputs: |
| 13 | + semver-updated: ${{ steps.check.outputs.changed }} |
| 14 | + steps: |
| 15 | + - name: Checkout Code |
| 16 | + uses: actions/checkout@v2 |
| 17 | + - uses: EndBug/version-check@v1 |
| 18 | + id: check |
| 19 | + with: |
| 20 | + file-name: NativeWebSocket/Assets/package.json |
| 21 | + diff-search: true |
| 22 | + token: ${{ secrets.GITHUB_TOKEN }} |
| 23 | + - name: Log when changed |
| 24 | + if: steps.check.outputs.changed == 'true' |
| 25 | + run: 'echo "Version change found in commit ${{ steps.check.outputs.commit }}! New version: ${{ steps.check.outputs.version }} (${{ steps.check.outputs.type }})"' |
| 26 | + updateUPM: |
| 27 | + name: Update UPM branch |
| 28 | + runs-on: ubuntu-latest |
| 29 | + needs: [checkSemver] |
| 30 | + if: needs.checkSemver.outputs.semver-updated == 'true' |
| 31 | + steps: |
| 32 | + # Copy correct directory into upm branch |
| 33 | + - uses: actions/checkout@v2 |
| 34 | + |
| 35 | + - name: Push package directory to subtree |
| 36 | + uses: s0/git-publish-subdir-action@develop |
| 37 | + env: |
| 38 | + REPO: self |
| 39 | + BRANCH: upm |
| 40 | + FOLDER: NativeWebSocket/Assets/ |
| 41 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 42 | + createPackage: |
| 43 | + name: Create Unity Package and Release |
| 44 | + runs-on: ubuntu-latest |
| 45 | + needs: [checkSemver] |
| 46 | + if: needs.checkSemver.outputs.semver-updated == 'true' |
| 47 | + steps: |
| 48 | + - name: Checkout Code |
| 49 | + uses: actions/checkout@v2 |
| 50 | + - name: Gather files |
| 51 | + run: | |
| 52 | + echo "NativeWebSocket/Assets/WebSocket.meta" > metaList |
| 53 | + find NativeWebSocket/Assets/WebSocket/ -name \*.meta >> metaList |
| 54 | + - name: Extract Version |
| 55 | + id: version |
| 56 | + uses: notiz-dev/github-action-json-property@release |
| 57 | + with: |
| 58 | + path: 'NativeWebSocket/Assets/package.json' |
| 59 | + prop_path: 'version' |
| 60 | + - run: echo ${{steps.version.outputs.prop}} |
| 61 | + - name: Create Directory |
| 62 | + run: mkdir Release |
| 63 | + - name: Generate Unity Package |
| 64 | + id: build-package |
| 65 | + uses: pCYSl5EDgo/create-unitypackage@master |
| 66 | + with: |
| 67 | + package-path: 'NativeWebSocket.unitypackage' |
| 68 | + include-files: metaList |
| 69 | + - name: Upload Package |
| 70 | + uses: actions/upload-artifact@master |
| 71 | + with: |
| 72 | + path: ./NativeWebSocket.unitypackage |
| 73 | + name: NativeWebSocket |
| 74 | + - name: Changelog |
| 75 | + uses: scottbrenner/generate-changelog-action@master |
| 76 | + id: Changelog |
| 77 | + - name: Create Release |
| 78 | + id: create_release |
| 79 | + uses: actions/create-release@v1 |
| 80 | + env: |
| 81 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 82 | + with: |
| 83 | + tag_name: ${{ steps.version.outputs.prop }} |
| 84 | + release_name: ${{ steps.version.outputs.prop }} |
| 85 | + body: | |
| 86 | + ${{ steps.Changelog.outputs.changelog }} |
| 87 | + draft: false |
| 88 | + prerelease: true |
| 89 | + - name: Upload Release Asset |
| 90 | + id: upload-release-asset |
| 91 | + uses: actions/upload-release-asset@v1 |
| 92 | + env: |
| 93 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 94 | + with: |
| 95 | + upload_url: ${{ steps.create_release.outputs.upload_url }} # This pulls from the CREATE RELEASE step above, referencing it's ID to get its outputs object, which include a `upload_url`. See this blog post for more info: https://jasonet.co/posts/new-features-of-github-actions/#passing-data-to-future-steps |
| 96 | + asset_path: ./NativeWebSocket.unitypackage |
| 97 | + asset_name: NativeWebSocket.unitypackage |
| 98 | + asset_content_type: application/x-gzip |
0 commit comments