diff --git a/.github/workflows/cli-release.yml b/.github/workflows/cli-release.yml new file mode 100644 index 0000000..7de38f1 --- /dev/null +++ b/.github/workflows/cli-release.yml @@ -0,0 +1,80 @@ +name: CLI Release + +on: + workflow_dispatch: + +jobs: + build: + name: Build ${{ matrix.target }} + runs-on: ${{ matrix.os }} + permissions: + contents: read + strategy: + matrix: + include: + - target: bun-darwin-arm64 + os: macos-latest + artifact: chp-darwin-arm64 + - target: bun-darwin-x64 + os: macos-latest + artifact: chp-darwin-x64 + - target: bun-linux-x64 + os: ubuntu-latest + artifact: chp-linux-x64 + - target: bun-linux-arm64 + os: ubuntu-latest + artifact: chp-linux-arm64 + + steps: + - name: Checkout code + uses: actions/checkout@v6 + + - name: Setup Bun + uses: oven-sh/setup-bun@v2 + + - name: Install dependencies + run: cd packages/cli && bun install + + - name: Build binary + run: | + cd packages/cli + VERSION=$(jq -r .version package.json) + bun build --compile --target=${{ matrix.target }} --define "__CLI_VERSION__=\"${VERSION}\"" ./src/index.ts --outfile ${{ matrix.artifact }} + + - name: Upload artifact + uses: actions/upload-artifact@v6 + with: + name: ${{ matrix.artifact }} + path: packages/cli/${{ matrix.artifact }} + + release: + name: Create Release + needs: build + runs-on: ubuntu-latest + permissions: + contents: write + + steps: + - name: Checkout code + uses: actions/checkout@v6 + + - name: Read version + id: version + run: echo "version=$(jq -r .version packages/cli/package.json)" >> "$GITHUB_OUTPUT" + + - name: Download all artifacts + uses: actions/download-artifact@v6 + with: + path: artifacts + + - name: Create GitHub Release + uses: softprops/action-gh-release@v2 + with: + tag_name: cli-v${{ steps.version.outputs.version }} + name: CLI v${{ steps.version.outputs.version }} + generate_release_notes: true + files: | + artifacts/chp-darwin-arm64/chp-darwin-arm64 + artifacts/chp-darwin-x64/chp-darwin-x64 + artifacts/chp-linux-x64/chp-linux-x64 + artifacts/chp-linux-arm64/chp-linux-arm64 diff --git a/apps/web/pages/login.tsx b/apps/web/pages/login.tsx index 0d69071..4d3675e 100644 --- a/apps/web/pages/login.tsx +++ b/apps/web/pages/login.tsx @@ -5,6 +5,12 @@ import Head from "next/head"; import Image from "next/image"; import Link from "next/link"; import { useRouter } from "next/router"; +import { useState } from "react"; +import { + createToastWrapper, + notifyError, + notifySuccess, +} from "../components/core/toast.component"; import { DEFAULT_TITLE, SUBTITLE } from "../data/marketing.data"; import { ROUTES } from "../data/routes.data"; import logoImage from "../public/images/logo.png"; @@ -19,6 +25,39 @@ export default function Login() { const { supabase } = useUserData(); const prefersColorScheme = usePrefersColorScheme(); + const [email, setEmail] = useState(""); + const [sending, setSending] = useState(false); + const [submitted, setSubmitted] = useState(false); + + const redirectTo = + getAppBaseURL() + + ROUTES.LOGIN_CALLBACK + + (redirectedFrom ? `?redirectedFrom=${redirectedFrom}` : ""); + + async function handleEmailLogin(e: React.FormEvent) { + e.preventDefault(); + if (!email || sending) return; + setSending(true); + const { error } = await supabase.auth.signInWithOtp({ + email, + options: { shouldCreateUser: false, emailRedirectTo: redirectTo }, + }); + setSending(false); + if (error) { + const msg = error.message.toLowerCase(); + if (msg.includes("signups not allowed") || msg.includes("not found")) { + notifyError( + "No account found for this email. Sign up with Google or GitHub." + ); + } else { + notifyError(error.message); + } + return; + } + setSubmitted(true); + notifySuccess("Check your email for the login link."); + } + const fontFamily = "system-ui, -apple-system, BlinkMacSystemFont, Segoe UI, Roboto, Oxygen, Ubuntu, Cantarell, Fira Sans, Droid Sans, Helvetica Neue, sans-serif"; @@ -53,6 +92,8 @@ export default function Login() { }} /> + {createToastWrapper(prefersColorScheme)} +