chore(template): remove dead viewports-manager/diagnostics setups (un… #55
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: Release | |
| on: | |
| push: | |
| branches: [main] | |
| concurrency: ${{ github.workflow }}-${{ github.ref }} | |
| jobs: | |
| release: | |
| name: Version & Publish | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: write | |
| outputs: | |
| published: ${{ steps.publish.outputs.published }} | |
| new_version: ${{ steps.version-info.outputs.new_version }} | |
| bump_type: ${{ steps.version-info.outputs.bump_type }} | |
| changelog: ${{ steps.version-info.outputs.changelog }} | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - uses: actions/setup-node@v4 | |
| with: | |
| node-version: 20 | |
| registry-url: https://registry.npmjs.org | |
| - run: yarn install --frozen-lockfile | |
| # Check if any changeset files exist (ignore README.md) | |
| - name: Check for changesets | |
| id: changesets | |
| run: | | |
| COUNT=$(find .changeset -name '*.md' ! -name 'README.md' | wc -l | tr -d ' ') | |
| echo "count=$COUNT" >> "$GITHUB_OUTPUT" | |
| if [ "$COUNT" != "0" ]; then | |
| echo "Found $COUNT changeset(s) — will version and publish." | |
| else | |
| echo "No changesets found — skipping." | |
| fi | |
| # Save current version before bumping | |
| - name: Save previous version | |
| if: steps.changesets.outputs.count != '0' | |
| id: prev-version | |
| run: | | |
| OLD_VERSION=$(node -p "require('./package.json').version") | |
| echo "version=$OLD_VERSION" >> "$GITHUB_OUTPUT" | |
| # Consume changesets: bump version, write CHANGELOG, remove changeset files | |
| - name: Version packages | |
| if: steps.changesets.outputs.count != '0' | |
| run: | | |
| yarn changeset version | |
| git config user.name "github-actions[bot]" | |
| git config user.email "github-actions[bot]@users.noreply.github.com" | |
| git add . | |
| git commit -m "chore: version packages [skip ci]" | |
| git push | |
| # Extract version info and changelog for the notification | |
| - name: Extract version info | |
| if: steps.changesets.outputs.count != '0' | |
| id: version-info | |
| run: | | |
| NEW_VERSION=$(node -p "require('./package.json').version") | |
| OLD_VERSION="${{ steps.prev-version.outputs.version }}" | |
| echo "new_version=$NEW_VERSION" >> "$GITHUB_OUTPUT" | |
| # Determine bump type by comparing semver components | |
| OLD_MAJOR=$(echo "$OLD_VERSION" | cut -d. -f1) | |
| OLD_MINOR=$(echo "$OLD_VERSION" | cut -d. -f2) | |
| NEW_MAJOR=$(echo "$NEW_VERSION" | cut -d. -f1) | |
| NEW_MINOR=$(echo "$NEW_VERSION" | cut -d. -f2) | |
| if [ "$NEW_MAJOR" != "$OLD_MAJOR" ]; then | |
| echo "bump_type=major" >> "$GITHUB_OUTPUT" | |
| elif [ "$NEW_MINOR" != "$OLD_MINOR" ]; then | |
| echo "bump_type=minor" >> "$GITHUB_OUTPUT" | |
| else | |
| echo "bump_type=patch" >> "$GITHUB_OUTPUT" | |
| fi | |
| # Extract the latest changelog section (between the first two ## headings) | |
| CHANGELOG=$(awk '/^## /{if(found) exit; found=1; next} found' CHANGELOG.md) | |
| # Store as multiline output | |
| { | |
| echo "changelog<<CHANGELOG_EOF" | |
| echo "$CHANGELOG" | |
| echo "CHANGELOG_EOF" | |
| } >> "$GITHUB_OUTPUT" | |
| # Build with the bumped version and publish | |
| - name: Build & Publish | |
| if: steps.changesets.outputs.count != '0' | |
| id: publish | |
| run: | | |
| yarn build | |
| yarn changeset publish | |
| echo "published=true" >> "$GITHUB_OUTPUT" | |
| env: | |
| NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} | |
| notify: | |
| name: Discord Notification | |
| runs-on: ubuntu-latest | |
| needs: release | |
| if: needs.release.outputs.published == 'true' | |
| steps: | |
| - name: Get PR details | |
| id: pr-info | |
| uses: actions/github-script@v7 | |
| with: | |
| script: | | |
| const { data: prs } = await github.rest.repos.listPullRequestsAssociatedWithCommit({ | |
| owner: context.repo.owner, | |
| repo: context.repo.repo, | |
| commit_sha: context.sha, | |
| }); | |
| const pr = prs.find(p => p.merge_commit_sha === context.sha) || prs[0]; | |
| if (pr) { | |
| core.setOutput('pr_title', pr.title); | |
| core.setOutput('pr_number', pr.number); | |
| core.setOutput('pr_url', pr.html_url); | |
| core.setOutput('pr_author', pr.user.login); | |
| core.setOutput('has_pr', 'true'); | |
| } else { | |
| core.setOutput('has_pr', 'false'); | |
| } | |
| - name: Send Discord notification | |
| env: | |
| WEBHOOK_URL: ${{ secrets.THAT_OPEN_BOT_WEBHOOK }} | |
| NEW_VERSION: ${{ needs.release.outputs.new_version }} | |
| BUMP_TYPE: ${{ needs.release.outputs.bump_type }} | |
| CHANGELOG: ${{ needs.release.outputs.changelog }} | |
| HAS_PR: ${{ steps.pr-info.outputs.has_pr }} | |
| PR_TITLE: ${{ steps.pr-info.outputs.pr_title }} | |
| PR_NUMBER: ${{ steps.pr-info.outputs.pr_number }} | |
| PR_URL: ${{ steps.pr-info.outputs.pr_url }} | |
| PR_AUTHOR: ${{ steps.pr-info.outputs.pr_author }} | |
| run: | | |
| RUN_URL="https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}" | |
| escape_json() { | |
| echo "$1" | sed 's/\\/\\\\/g; s/"/\\"/g; s/\t/\\t/g; s/\[//g; s/\]//g' | tr '\n' ' ' | |
| } | |
| TITLE="New ${BUMP_TYPE} version published (v${NEW_VERSION}) for Engine Services" | |
| # Build changelog description | |
| SAFE_CHANGELOG=$(escape_json "$CHANGELOG") | |
| DESCRIPTION="${SAFE_CHANGELOG}" | |
| # Build link field | |
| if [ "$HAS_PR" = "true" ]; then | |
| SAFE_TITLE=$(escape_json "$PR_TITLE") | |
| LINK="[${SAFE_TITLE} (#${PR_NUMBER})](${PR_URL}) (${PR_AUTHOR})" | |
| else | |
| COMMIT_MSG=$(escape_json "$(echo '${{ github.event.head_commit.message }}' | head -1)") | |
| COMMIT_URL="https://github.com/${{ github.repository }}/commit/${{ github.sha }}" | |
| LINK="[${COMMIT_MSG}](${COMMIT_URL}) (${{ github.actor }})" | |
| fi | |
| curl -s -X POST "$WEBHOOK_URL" \ | |
| -H "Content-Type: application/json" \ | |
| -d "{ | |
| \"embeds\": [{ | |
| \"title\": \"${TITLE}\", | |
| \"description\": \"${DESCRIPTION}\", | |
| \"color\": 3066993, | |
| \"fields\": [ | |
| { \"name\": \"Source\", \"value\": \"${LINK}\", \"inline\": false }, | |
| { \"name\": \"Workflow\", \"value\": \"[View logs](${RUN_URL})\", \"inline\": true } | |
| ], | |
| \"timestamp\": \"$(date -u +%Y-%m-%dT%H:%M:%SZ)\" | |
| }] | |
| }" |