-
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Try new workflow to publish @mockline/ui
- Loading branch information
Showing
3 changed files
with
113 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
name: UI CI/CD | ||
|
||
on: | ||
push: | ||
branches: | ||
- main | ||
workflow_dispatch: | ||
|
||
permissions: | ||
contents: write | ||
id-token: write | ||
|
||
jobs: | ||
ci: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4 | ||
with: | ||
fetch-depth: 0 | ||
|
||
- uses: oven-sh/setup-bun@v2 | ||
with: | ||
bun-version: latest | ||
|
||
- name: 📦 Install dependencies | ||
run: bun install | ||
|
||
- name: 🚀 Prepare UI | ||
run: bun run dev:prepare | ||
|
||
- name: 🎨 Run Tailwind | ||
run: bun run tailwind | ||
|
||
- name: 💅 Lint code | ||
run: bun run lint | ||
|
||
- name: 🛠️ Build | ||
run: bun run build | ||
|
||
- uses: dorny/paths-filter@v3 | ||
id: changes | ||
with: | ||
filters: | | ||
src: | ||
- 'packages/mockline/src/**' | ||
- 'packages/mockline/package.json' | ||
- 'packages/mockline/bun.lockb' | ||
- 'packages/utils/src/**' | ||
- 'packages/utils/package.json' | ||
- 'packages/utils/bun.lockb' | ||
- 'package.json' | ||
- 'bun.lockb' | ||
- name: 🚀 Release UI | ||
if: github.event_name == 'workflow_dispatch' || (github.event_name == 'push' && steps.changes.outputs.src == 'true') | ||
run: ./scripts/release-ui.sh | ||
env: | ||
NPM_TOKEN: ${{secrets.NPM_TOKEN}} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import { promises as fsp } from 'fs' | ||
import { resolve } from 'path' | ||
import { execSync } from 'child_process' | ||
import { join } from 'pathe' | ||
|
||
async function loadPackage(dir: string) { | ||
const pkgPath = resolve(dir, 'package.json') | ||
|
||
const data = JSON.parse(await fsp.readFile(pkgPath, 'utf-8').catch(() => '{}')) | ||
|
||
const save = () => fsp.writeFile(pkgPath, JSON.stringify(data, null, 2) + '\n') | ||
|
||
return { | ||
dir, | ||
data, | ||
save | ||
} | ||
} | ||
|
||
async function main() { | ||
const rootDir = resolve(__dirname, '..') | ||
const pkg = await loadPackage(join(rootDir, 'packages', 'mockline')) | ||
|
||
pkg.data.name = `@mockline/ui` | ||
|
||
pkg.data.version = `${pkg.data.version}` | ||
|
||
await pkg.save() | ||
} | ||
|
||
main().catch((err) => { | ||
console.error(err) | ||
process.exit(1) | ||
}) |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
#!/bin/bash | ||
|
||
# Restore all git changes | ||
git restore -s@ -SW -- . | ||
|
||
# Bump versions to edge | ||
bunx jiti ./scripts/bump-ui | ||
|
||
# Update token | ||
if [[ ! -z ${NPM_TOKEN} ]] ; then | ||
echo "//registry.npmjs.org/:_authToken=${NPM_TOKEN}" >> ~/.npmrc | ||
echo "registry=https://registry.npmjs.org/" >> ~/.npmrc | ||
echo "always-auth=true" >> ~/.npmrc | ||
npm whoami | ||
fi | ||
|
||
# Release package | ||
echo "Publishing @mockline/ui" | ||
cd packages/mockline | ||
npm publish -q --access public |