|
1 | 1 | name: Publish UPM Package |
2 | 2 |
|
3 | 3 | on: |
4 | | - push: |
5 | | - branches: [main] |
6 | | - paths: |
7 | | - - 'Assets/CasperSDK/**' |
| 4 | + push: |
| 5 | + branches: [main] |
| 6 | + paths: |
| 7 | + - "Assets/CasperSDK/**" |
8 | 8 |
|
9 | 9 | jobs: |
10 | | - publish: |
11 | | - runs-on: ubuntu-latest |
12 | | - steps: |
13 | | - - name: Checkout source repo |
14 | | - uses: actions/checkout@v4 |
15 | | - with: |
16 | | - fetch-depth: 0 |
17 | | - |
18 | | - - name: Setup Git |
19 | | - run: | |
20 | | - git config --global user.name "GitHub Actions" |
21 | | - git config --global user.email "actions@github.com" |
22 | | -
|
23 | | - - name: Get version from package.json |
24 | | - id: version |
25 | | - run: | |
26 | | - VERSION=$(cat Assets/CasperSDK/package.json | jq -r '.version') |
27 | | - echo "version=$VERSION" >> $GITHUB_OUTPUT |
28 | | -
|
29 | | - - name: Push to UPM repo |
30 | | - env: |
31 | | - UPM_REPO: github.com/SamDreamsMaker/com.caspernetwork.sdk.git |
32 | | - GH_TOKEN: ${{ secrets.UPM_DEPLOY_TOKEN }} |
33 | | - run: | |
34 | | - # Create temp directory |
35 | | - mkdir -p /tmp/upm-package |
36 | | - |
37 | | - # Copy package contents |
38 | | - cp -r Assets/CasperSDK/* /tmp/upm-package/ |
39 | | - |
40 | | - # Initialize git in package folder |
41 | | - cd /tmp/upm-package |
42 | | - git init |
43 | | - git add . |
44 | | - git commit -m "Release v${{ steps.version.outputs.version }}" |
45 | | - |
46 | | - # Push to UPM repo |
47 | | - git remote add upm https://${GH_TOKEN}@${UPM_REPO} |
48 | | - git push upm HEAD:main --force |
49 | | - |
50 | | - # Create version tag |
51 | | - git tag v${{ steps.version.outputs.version }} |
52 | | - git push upm v${{ steps.version.outputs.version }} --force |
53 | | -
|
54 | | - - name: Summary |
55 | | - run: | |
56 | | - echo "## 📦 UPM Package Published" >> $GITHUB_STEP_SUMMARY |
57 | | - echo "Version: v${{ steps.version.outputs.version }}" >> $GITHUB_STEP_SUMMARY |
58 | | - echo "Repo: https://github.com/SamDreamsMaker/com.caspernetwork.sdk" >> $GITHUB_STEP_SUMMARY |
| 10 | + publish: |
| 11 | + runs-on: ubuntu-latest |
| 12 | + steps: |
| 13 | + - name: Checkout source repo |
| 14 | + uses: actions/checkout@v4 |
| 15 | + with: |
| 16 | + fetch-depth: 0 |
| 17 | + |
| 18 | + - name: Setup Git |
| 19 | + run: | |
| 20 | + git config --global user.name "GitHub Actions" |
| 21 | + git config --global user.email "actions@github.com" |
| 22 | +
|
| 23 | + - name: Get version from package.json |
| 24 | + id: version |
| 25 | + run: | |
| 26 | + VERSION=$(cat Assets/CasperSDK/package.json | jq -r '.version') |
| 27 | + echo "version=$VERSION" >> $GITHUB_OUTPUT |
| 28 | +
|
| 29 | + - name: Push to UPM repo |
| 30 | + env: |
| 31 | + UPM_REPO: github.com/SamDreamsMaker/com.caspernetwork.sdk.git |
| 32 | + GH_TOKEN: ${{ secrets.UPM_DEPLOY_TOKEN }} |
| 33 | + run: | |
| 34 | + # Create temp directory |
| 35 | + mkdir -p /tmp/upm-package |
| 36 | +
|
| 37 | + # Copy package contents (excluding Tests and orphan meta files) |
| 38 | + cp -r Assets/CasperSDK/* /tmp/upm-package/ |
| 39 | +
|
| 40 | + # Remove Tests folder (not needed in production package) |
| 41 | + rm -rf /tmp/upm-package/Tests |
| 42 | + rm -f /tmp/upm-package/Tests.meta |
| 43 | +
|
| 44 | + # Remove orphan Samples.meta (folder is Samples~, not Samples) |
| 45 | + rm -f /tmp/upm-package/Samples.meta |
| 46 | +
|
| 47 | + # Initialize git in package folder |
| 48 | + cd /tmp/upm-package |
| 49 | + git init |
| 50 | + git add . |
| 51 | + git commit -m "Release v${{ steps.version.outputs.version }}" |
| 52 | +
|
| 53 | + # Push to UPM repo |
| 54 | + git remote add upm https://${GH_TOKEN}@${UPM_REPO} |
| 55 | + git push upm HEAD:main --force |
| 56 | +
|
| 57 | + # Create version tag |
| 58 | + git tag v${{ steps.version.outputs.version }} |
| 59 | + git push upm v${{ steps.version.outputs.version }} --force |
| 60 | +
|
| 61 | + - name: Summary |
| 62 | + run: | |
| 63 | + echo "## 📦 UPM Package Published" >> $GITHUB_STEP_SUMMARY |
| 64 | + echo "Version: v${{ steps.version.outputs.version }}" >> $GITHUB_STEP_SUMMARY |
| 65 | + echo "Repo: https://github.com/SamDreamsMaker/com.caspernetwork.sdk" >> $GITHUB_STEP_SUMMARY |
0 commit comments