From 18ab469e09dcc930b77db06dcf36adc1129b95d4 Mon Sep 17 00:00:00 2001 From: jack shelton Date: Thu, 22 Aug 2024 17:48:17 -0500 Subject: [PATCH] feat: try reading files directly in script --- .changeset/README.md | 8 ------ ...reate-linear-issue.ts => manage-linear.ts} | 25 ++++++++++++++++--- .github/workflows/release.yml | 9 ------- 3 files changed, 22 insertions(+), 20 deletions(-) delete mode 100644 .changeset/README.md rename .github/scripts/{create-linear-issue.ts => manage-linear.ts} (74%) diff --git a/.changeset/README.md b/.changeset/README.md deleted file mode 100644 index e5b6d8d6..00000000 --- a/.changeset/README.md +++ /dev/null @@ -1,8 +0,0 @@ -# Changesets - -Hello and welcome! This folder has been automatically generated by `@changesets/cli`, a build tool that works -with multi-package repos, or single-package repos to help you version and publish your code. You can -find the full documentation for it [in our repository](https://github.com/changesets/changesets) - -We have a quick list of common questions to get you started engaging with this project in -[our documentation](https://github.com/changesets/changesets/blob/main/docs/common-questions.md) diff --git a/.github/scripts/create-linear-issue.ts b/.github/scripts/manage-linear.ts similarity index 74% rename from .github/scripts/create-linear-issue.ts rename to .github/scripts/manage-linear.ts index e5cc7029..8b839eb7 100644 --- a/.github/scripts/create-linear-issue.ts +++ b/.github/scripts/manage-linear.ts @@ -1,4 +1,6 @@ import { LinearClient } from "@linear/sdk"; +import path from "node:path"; +import fs from "node:fs"; const linearClient = new LinearClient({ apiKey: process.env.LINEAR_API_KEY }); @@ -6,7 +8,24 @@ const team = await linearClient.team("QWIK"); const project = await linearClient.project("af4d86af8e3f"); const prTitle = process.env.PR_TITLE || "No PR Title"; -const prDescription = process.env.PR_DESCRIPTION || "No PR Description"; +let prDescription: string; + +// Read contents of .changeset directory +function readChangesetFiles() { + const changesetDir = path.join(process.cwd(), ".changeset"); + if (fs.existsSync(changesetDir)) { + const files = fs.readdirSync(changesetDir); + + for (const file of files) { + if (path.extname(file) === ".md") { + const content = fs.readFileSync(path.join(changesetDir, file), "utf-8"); + prDescription += content; + } + } + } +} + +readChangesetFiles(); const existingIssues = await linearClient.issues({ filter: { @@ -57,9 +76,9 @@ async function updateLinearReleaseIssue() { try { if (existingIssue) { - await createLinearReleaseIssue(); - } else { await updateLinearReleaseIssue(); + } else { + await createLinearReleaseIssue(); } } catch (e) { console.error("Error from creating linear ticket script: ", e); diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 366d231e..0230cb61 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -81,18 +81,9 @@ jobs: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} NPM_TOKEN: ${{ secrets.NPM_TOKEN }} - - name: 📜 Generate Changelog - id: generate-changelog - run: | - pnpm changeset status --output=verbose > changelog.txt - echo "PR_DESCRIPTION<> $GITHUB_ENV - cat changelog.txt >> $GITHUB_ENV - echo "EOF" >> $GITHUB_ENV - - name: 💥 Create Linear Release Issue if: steps.changesets.outputs.pullRequestNumber env: LINEAR_API_KEY: ${{ secrets.LINEAR_API_KEY }} PR_TITLE: "Release QDS v${{ env.NEW_VERSION }}" - PR_DESCRIPTION: ${{ steps.generate-changelog.outputs.PR_DESCRIPTION }} run: pnpm vite-node .github/scripts/create-linear-issue.ts