|
| 1 | +name: Update Package Version |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + tags: |
| 6 | + - 'v*.*.*' # v1.0.0, v1.0.1 등의 태그가 푸시될 때 실행 |
| 7 | + |
| 8 | +jobs: |
| 9 | + update-version: |
| 10 | + runs-on: ubuntu-latest |
| 11 | + |
| 12 | + steps: |
| 13 | + - name: Checkout repository |
| 14 | + uses: actions/checkout@v4 |
| 15 | + with: |
| 16 | + fetch-depth: 0 |
| 17 | + token: ${{ secrets.GITHUB_TOKEN }} |
| 18 | + |
| 19 | + - name: Extract version from tag |
| 20 | + id: get_version |
| 21 | + run: | |
| 22 | + # 태그 이름에서 'v' 제거하여 버전 추출 (예: v1.0.2 -> 1.0.2) |
| 23 | + VERSION=${GITHUB_REF#refs/tags/v} |
| 24 | + echo "version=$VERSION" >> $GITHUB_OUTPUT |
| 25 | + echo "📦 Extracted version: $VERSION" |
| 26 | + |
| 27 | + - name: Update package.json version |
| 28 | + run: | |
| 29 | + VERSION=${{ steps.get_version.outputs.version }} |
| 30 | + PACKAGE_FILE="src/UniFP/Assets/Plugins/UniFP/package.json" |
| 31 | + |
| 32 | + # jq를 사용하여 package.json의 version 필드 업데이트 |
| 33 | + jq --arg ver "$VERSION" '.version = $ver' "$PACKAGE_FILE" > tmp.json |
| 34 | + mv tmp.json "$PACKAGE_FILE" |
| 35 | + |
| 36 | + echo "✅ Updated package.json to version $VERSION" |
| 37 | + cat "$PACKAGE_FILE" |
| 38 | + |
| 39 | + - name: Check for changes |
| 40 | + id: check_changes |
| 41 | + run: | |
| 42 | + if git diff --quiet; then |
| 43 | + echo "changed=false" >> $GITHUB_OUTPUT |
| 44 | + echo "ℹ️ No changes detected" |
| 45 | + else |
| 46 | + echo "changed=true" >> $GITHUB_OUTPUT |
| 47 | + echo "📝 Changes detected" |
| 48 | + fi |
| 49 | + |
| 50 | + - name: Commit and push changes |
| 51 | + if: steps.check_changes.outputs.changed == 'true' |
| 52 | + run: | |
| 53 | + VERSION=${{ steps.get_version.outputs.version }} |
| 54 | + |
| 55 | + git config user.name "github-actions[bot]" |
| 56 | + git config user.email "github-actions[bot]@users.noreply.github.com" |
| 57 | + |
| 58 | + git add src/UniFP/Assets/Plugins/UniFP/package.json |
| 59 | + git commit -m "chore: update package.json version to $VERSION [skip ci]" |
| 60 | + |
| 61 | + # 태그가 생성된 커밋에 변경사항 추가 (force push) |
| 62 | + git push origin HEAD:main |
| 63 | + |
| 64 | + echo "✅ Changes committed and pushed" |
| 65 | + |
| 66 | + - name: Update tag to include version change |
| 67 | + if: steps.check_changes.outputs.changed == 'true' |
| 68 | + run: | |
| 69 | + VERSION=${{ steps.get_version.outputs.version }} |
| 70 | + TAG_NAME="v$VERSION" |
| 71 | + |
| 72 | + # 기존 태그 삭제 |
| 73 | + git tag -d "$TAG_NAME" || true |
| 74 | + git push origin ":refs/tags/$TAG_NAME" || true |
| 75 | + |
| 76 | + # 새로운 태그 생성 (업데이트된 커밋에) |
| 77 | + git tag -a "$TAG_NAME" -m "Release $TAG_NAME" |
| 78 | + git push origin "$TAG_NAME" |
| 79 | + |
| 80 | + echo "✅ Tag $TAG_NAME updated" |
| 81 | + |
| 82 | + - name: Create Release |
| 83 | + if: steps.check_changes.outputs.changed == 'true' |
| 84 | + uses: softprops/action-gh-release@v1 |
| 85 | + with: |
| 86 | + tag_name: v${{ steps.get_version.outputs.version }} |
| 87 | + name: Release v${{ steps.get_version.outputs.version }} |
| 88 | + body: | |
| 89 | + ## UniFP v${{ steps.get_version.outputs.version }} |
| 90 | + |
| 91 | + ### 변경사항 |
| 92 | + 자세한 변경사항은 [커밋 히스토리](https://github.com/${{ github.repository }}/commits/v${{ steps.get_version.outputs.version }})를 확인해주세요. |
| 93 | + |
| 94 | + ### 설치 방법 |
| 95 | + |
| 96 | + Unity Package Manager에서 다음 URL을 사용하여 설치: |
| 97 | + ``` |
| 98 | + https://github.com/${{ github.repository }}.git?path=src/UniFP/Assets/Plugins/UniFP#v${{ steps.get_version.outputs.version }} |
| 99 | + ``` |
| 100 | + draft: false |
| 101 | + prerelease: false |
| 102 | + env: |
| 103 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
0 commit comments