Skip to content

Commit

Permalink
chore: Clean up some docs and packages
Browse files Browse the repository at this point in the history
  • Loading branch information
WillsonHaw committed Jan 10, 2025
1 parent d7a8a21 commit 2f8bd0b
Show file tree
Hide file tree
Showing 8 changed files with 191 additions and 7 deletions.
17 changes: 17 additions & 0 deletions .github/actions/setup/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# https://docs.github.com/en/actions/creating-actions/creating-a-composite-action

name: Set up environment
description: Runs setup actions and installs packages

runs:
using: 'composite'
steps:
- uses: pnpm/action-setup@v4

- uses: buildjet/setup-node@v4
with:
node-version: '20'
cache: 'pnpm'

- run: pnpm install --frozen-lockfile
shell: bash
51 changes: 51 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
name: Release

on:
push:
branches:
- main

concurrency: ${{ github.workflow }}-${{ github.ref }}

env:
TURBO_TOKEN: ${{ secrets.TURBO_TOKEN }}
TURBO_TEAM: ${{ secrets.TURBO_TEAM }}

jobs:
release:
name: Release
runs-on: buildjet-2vcpu-ubuntu-2204
steps:
- uses: actions/checkout@v4
with:
# Fetch all commit history for generating the changelog.
fetch-depth: 0
# Avoid configuring the token with the local git config in favor of
# our own environment token (see below).
persist-credentials: false

- uses: pnpm/action-setup@v4

- uses: buildjet/setup-node@v4
with:
node-version: "20"
cache: "pnpm"

- name: Set up environment
uses: ./.github/actions/setup
timeout-minutes: 5

- name: Create release pull request or publish
id: changesets
uses: changesets/action@v1
with:
version: pnpm run ci:version
commit: "chore: Update versions"
title: "chore: Update versions"
publish: pnpm run ci:publish
env:
# When you use the repository's GITHUB_TOKEN to perform tasks, events
# triggered by the GITHUB_TOKEN will not create a new workflow run.
# This means that checks won't run on the release PRs. We work around
# this by using our own GH_TOKEN_REPO_ACCESS organization secret.
GITHUB_TOKEN: ${{ secrets.GH_TOKEN_REPO_ACCESS }}
70 changes: 70 additions & 0 deletions .github/workflows/snapshot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
name: Snapshot Release

on:
issue_comment:
types:
- created

concurrency: ${{ github.workflow }}-${{ github.ref }}

env:
TURBO_TOKEN: ${{ secrets.TURBO_TOKEN }}
TURBO_TEAM: ${{ secrets.TURBO_TEAM }}

jobs:
snapshot:
name: Snapshot Release
runs-on: buildjet-2vcpu-ubuntu-2204
if: github.event.issue.pull_request && github.event.comment.body == '/snapshot'
steps:
- name: Add initial comment
uses: peter-evans/create-or-update-comment@v3
with:
comment-id: ${{ github.event.comment.id }}
body: |
Follow snapshot progress [here](${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }})
reactions: eyes

- uses: actions/checkout@v4

# issue_comment requires us to checkout the branch
# https://github.com/actions/checkout/issues/331#issuecomment-1120113003
- name: Checkout pull request branch
run: hub pr checkout ${{ github.event.issue.number }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Set up environment
uses: ./.github/actions/setup
timeout-minutes: 5

- name: Check if changeset exists
run: |
pnpm exec changeset status --since main
- name: Add final comment (failure)
if: failure()
uses: peter-evans/create-or-update-comment@v3
with:
comment-id: ${{ github.event.comment.id }}
body: |
:x: A changeset is required to build a snapshot.
reactions: confused

- name: Publish snapshot release
run: |
pnpm exec changeset version --snapshot ${{ github.event.issue.number }} && pnpm install
pnpm run ci:publish --no-git-tag --snapshot
- name: Retrieve snapshot version
run: |
echo "SNAPSHOT_VERSION=$(npm view @plex/core-logging versions --json | grep 0.0.0-${{ github.event.issue.number }} | sort -r | head -n 1 | cut -d'"' -f 2)" >> $GITHUB_OUTPUT
id: snapshotVersion

- name: Add final comment
uses: peter-evans/create-or-update-comment@v3
with:
comment-id: ${{ github.event.comment.id }}
body: |
${{steps.snapshotVersion.outputs.SNAPSHOT_VERSION}} has been published.
reactions: rocket
48 changes: 48 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
name: Run tests

on:
pull_request:
push:
branches:
- main

concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.ref }}
cancel-in-progress: true

env:
TURBO_TOKEN: ${{ secrets.TURBO_TOKEN }}
TURBO_TEAM: ${{ secrets.TURBO_TEAM }}

jobs:
test:
name: Run tests
runs-on: buildjet-2vcpu-ubuntu-2204
steps:
- uses: actions/checkout@v4
if: ${{ github.event_name != 'pull_request' }}

- uses: actions/checkout@v4
if: ${{ github.event_name == 'pull_request' }}
with:
ref: ${{ github.event.pull_request.head.sha }}

- uses: pnpm/action-setup@v4

- uses: buildjet/setup-node@v4
with:
node-version: "20"
cache: "pnpm"

- name: Set up environment
uses: ./.github/actions/setup
timeout-minutes: 5

- name: Lint
run: pnpm run lint

# - name: Check types
# run: pnpm run tsc

- name: Run unit tests
run: pnpm run test
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ using React and React Native.
You can scaffold a new project using degit:

```bash
npx degit plexinc/react-lightning/apps
npx degit plexinc/react-lightning/apps/template my-lightning-app
```

See the docs in [/apps/storybook](./apps/storybook) for usage and examples.
2 changes: 1 addition & 1 deletion apps/storybook/src/getting-started/QuickStart.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ The quickest way to get up and running is to use the template app.
dark
language="bash"
code={`
npx degit plexinc/react-lightning/apps/template
npx degit plexinc/react-lightning/apps/template my-lightning-app
`}
/>

Expand Down
4 changes: 2 additions & 2 deletions apps/template/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,12 @@
},
"dependencies": {
"@lightningjs/renderer": "2.8.0",
"@plexinc/react-lightning": "workspace:*",
"@plexinc/react-lightning": "*",
"react": "18.3.1",
"react-router-dom": "7.0.2"
},
"devDependencies": {
"@plexinc/vite-plugin-msdf-fontgen": "workspace:*",
"@plexinc/vite-plugin-msdf-fontgen": "*",
"@tsconfig/vite-react": "3.4.0",
"@types/react": "18.3.14",
"@vitejs/plugin-react": "4.3.4",
Expand Down
4 changes: 1 addition & 3 deletions renovate.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
{
"$schema": "https://docs.renovatebot.com/renovate-schema.json",
"extends": [
"local>plexinc/renovate-config"
]
"extends": ["local>plexinc/renovate-config"]
}

0 comments on commit 2f8bd0b

Please sign in to comment.