Add WebGL showcase site and Pages deployment pipeline #9
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Publish UPM Package | |
| on: | |
| push: | |
| branches: | |
| - main | |
| workflow_dispatch: | |
| permissions: | |
| contents: write | |
| jobs: | |
| publish: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| token: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Get current version | |
| id: current | |
| run: | | |
| VERSION=$(cat Packages/com.orkunmanap.runtime-transform-handles/package.json | jq -r '.version') | |
| echo "version=$VERSION" >> $GITHUB_OUTPUT | |
| echo "Current version: $VERSION" | |
| - name: Determine version bump | |
| id: bump | |
| run: | | |
| # Get the latest tag | |
| LATEST_TAG=$(git describe --tags --abbrev=0 2>/dev/null || echo "v0.0.0") | |
| echo "Latest tag: $LATEST_TAG" | |
| # Get commits since last tag | |
| COMMITS=$(git log $LATEST_TAG..HEAD --pretty=format:"%s" 2>/dev/null || git log --pretty=format:"%s") | |
| echo "Commits since $LATEST_TAG:" | |
| echo "$COMMITS" | |
| # Determine bump type based on conventional commits | |
| BUMP="none" | |
| if echo "$COMMITS" | grep -qiE "^.*(BREAKING CHANGE|!):|^break"; then | |
| BUMP="major" | |
| elif echo "$COMMITS" | grep -qiE "^feat(\(.+\))?:|^feature"; then | |
| BUMP="minor" | |
| elif echo "$COMMITS" | grep -qiE "^fix(\(.+\))?:|^bugfix|^perf(\(.+\))?:|^refactor(\(.+\))?:"; then | |
| BUMP="patch" | |
| elif echo "$COMMITS" | grep -qiE "^docs(\(.+\))?:|^style(\(.+\))?:|^chore(\(.+\))?:|^ci(\(.+\))?:|^test(\(.+\))?:"; then | |
| # For docs/style/chore commits, only bump if there are actual code changes | |
| if git diff $LATEST_TAG..HEAD --name-only 2>/dev/null | grep -qE "\.cs$|package\.json$"; then | |
| BUMP="patch" | |
| fi | |
| fi | |
| # If no conventional commits but there are changes, default to patch | |
| if [ "$BUMP" = "none" ]; then | |
| CHANGES=$(git diff $LATEST_TAG..HEAD --name-only 2>/dev/null | grep -E "Packages/com.orkunmanap.runtime-transform-handles/" | wc -l) | |
| if [ "$CHANGES" -gt 0 ]; then | |
| BUMP="patch" | |
| fi | |
| fi | |
| echo "bump=$BUMP" >> $GITHUB_OUTPUT | |
| echo "Bump type: $BUMP" | |
| - name: Calculate new version | |
| id: version | |
| run: | | |
| CURRENT="${{ steps.current.outputs.version }}" | |
| BUMP="${{ steps.bump.outputs.bump }}" | |
| if [ "$BUMP" = "none" ]; then | |
| echo "version=$CURRENT" >> $GITHUB_OUTPUT | |
| echo "skip=true" >> $GITHUB_OUTPUT | |
| echo "No version bump needed" | |
| exit 0 | |
| fi | |
| # Parse version | |
| IFS='.' read -r MAJOR MINOR PATCH <<< "$CURRENT" | |
| case $BUMP in | |
| major) | |
| MAJOR=$((MAJOR + 1)) | |
| MINOR=0 | |
| PATCH=0 | |
| ;; | |
| minor) | |
| MINOR=$((MINOR + 1)) | |
| PATCH=0 | |
| ;; | |
| patch) | |
| PATCH=$((PATCH + 1)) | |
| ;; | |
| esac | |
| NEW_VERSION="$MAJOR.$MINOR.$PATCH" | |
| echo "version=$NEW_VERSION" >> $GITHUB_OUTPUT | |
| echo "skip=false" >> $GITHUB_OUTPUT | |
| echo "New version: $NEW_VERSION" | |
| - name: Update package.json version | |
| if: steps.version.outputs.skip != 'true' | |
| run: | | |
| NEW_VERSION="${{ steps.version.outputs.version }}" | |
| PACKAGE_FILE="Packages/com.orkunmanap.runtime-transform-handles/package.json" | |
| # Update version in package.json | |
| jq ".version = \"$NEW_VERSION\"" $PACKAGE_FILE > tmp.json && mv tmp.json $PACKAGE_FILE | |
| echo "Updated package.json to version $NEW_VERSION" | |
| cat $PACKAGE_FILE | |
| - name: Configure Git | |
| run: | | |
| git config --global user.name "github-actions[bot]" | |
| git config --global user.email "github-actions[bot]@users.noreply.github.com" | |
| - name: Commit version bump | |
| if: steps.version.outputs.skip != 'true' | |
| run: | | |
| NEW_VERSION="${{ steps.version.outputs.version }}" | |
| git add Packages/com.orkunmanap.runtime-transform-handles/package.json | |
| git commit -m "chore: bump version to $NEW_VERSION [skip ci]" || echo "No changes to commit" | |
| git push origin main | |
| - name: Create/Update UPM branch | |
| if: steps.version.outputs.skip != 'true' | |
| run: | | |
| PACKAGE_PATH="Packages/com.orkunmanap.runtime-transform-handles" | |
| UPM_BRANCH="upm" | |
| # Check if upm branch exists | |
| if git ls-remote --heads origin $UPM_BRANCH | grep -q $UPM_BRANCH; then | |
| echo "UPM branch exists, updating..." | |
| git checkout $UPM_BRANCH | |
| git pull origin $UPM_BRANCH | |
| # Remove old files (except .git) | |
| find . -maxdepth 1 ! -name '.git' ! -name '.' -exec rm -rf {} + | |
| # Copy package contents | |
| git checkout main -- "$PACKAGE_PATH" | |
| mv "$PACKAGE_PATH"/* . | |
| rm -rf Packages | |
| else | |
| echo "Creating new UPM branch..." | |
| git checkout --orphan $UPM_BRANCH | |
| # Remove all files | |
| git rm -rf . || true | |
| git clean -fd | |
| # Copy package contents from main | |
| git checkout main -- "$PACKAGE_PATH" | |
| mv "$PACKAGE_PATH"/* . | |
| rm -rf Packages | |
| fi | |
| # Stage and commit | |
| git add -A | |
| if git diff --cached --quiet; then | |
| echo "No changes to commit" | |
| else | |
| git commit -m "Release v${{ steps.version.outputs.version }}" | |
| git push origin $UPM_BRANCH --force | |
| echo "UPM branch updated successfully!" | |
| fi | |
| - name: Create version tag | |
| if: steps.version.outputs.skip != 'true' | |
| run: | | |
| VERSION="v${{ steps.version.outputs.version }}" | |
| git checkout upm | |
| # Create and push tag | |
| git tag -a $VERSION -m "Release $VERSION" | |
| git push origin $VERSION | |
| echo "Tagged version: $VERSION" | |
| - name: Generate changelog | |
| if: steps.version.outputs.skip != 'true' | |
| id: changelog | |
| run: | | |
| LATEST_TAG=$(git describe --tags --abbrev=0 HEAD^ 2>/dev/null || echo "") | |
| if [ -z "$LATEST_TAG" ]; then | |
| COMMITS=$(git log --pretty=format:"- %s" HEAD) | |
| else | |
| COMMITS=$(git log $LATEST_TAG..HEAD --pretty=format:"- %s") | |
| fi | |
| # Create changelog | |
| echo "changelog<<EOF" >> $GITHUB_OUTPUT | |
| echo "$COMMITS" >> $GITHUB_OUTPUT | |
| echo "EOF" >> $GITHUB_OUTPUT | |
| - name: Create GitHub Release | |
| if: steps.version.outputs.skip != 'true' | |
| uses: softprops/action-gh-release@v1 | |
| with: | |
| tag_name: v${{ steps.version.outputs.version }} | |
| name: v${{ steps.version.outputs.version }} | |
| body: | | |
| ## Changes | |
| ${{ steps.changelog.outputs.changelog }} | |
| ## Installation | |
| Add to your `manifest.json`: | |
| ```json | |
| "com.orkunmanap.runtime-transform-handles": "https://github.com/${{ github.repository }}.git#v${{ steps.version.outputs.version }}" | |
| ``` | |
| Or use the latest: | |
| ```json | |
| "com.orkunmanap.runtime-transform-handles": "https://github.com/${{ github.repository }}.git#upm" | |
| ``` | |
| draft: false | |
| prerelease: false | |
| - name: Summary | |
| run: | | |
| if [ "${{ steps.version.outputs.skip }}" = "true" ]; then | |
| echo "## No Release Needed" >> $GITHUB_STEP_SUMMARY | |
| echo "No version bump was triggered by the commits." >> $GITHUB_STEP_SUMMARY | |
| else | |
| echo "## UPM Package Released 🎉" >> $GITHUB_STEP_SUMMARY | |
| echo "" >> $GITHUB_STEP_SUMMARY | |
| echo "**Version:** v${{ steps.version.outputs.version }}" >> $GITHUB_STEP_SUMMARY | |
| echo "**Bump Type:** ${{ steps.bump.outputs.bump }}" >> $GITHUB_STEP_SUMMARY | |
| echo "" >> $GITHUB_STEP_SUMMARY | |
| echo "### Installation" >> $GITHUB_STEP_SUMMARY | |
| echo "\`\`\`json" >> $GITHUB_STEP_SUMMARY | |
| echo "\"com.orkunmanap.runtime-transform-handles\": \"https://github.com/${{ github.repository }}.git#upm\"" >> $GITHUB_STEP_SUMMARY | |
| echo "\`\`\`" >> $GITHUB_STEP_SUMMARY | |
| fi |