diff --git a/.github/workflows/desktop.release.reuse.yml b/.github/workflows/desktop.release.reuse.yml index 4e8907585..3c4260c5f 100644 --- a/.github/workflows/desktop.release.reuse.yml +++ b/.github/workflows/desktop.release.reuse.yml @@ -172,14 +172,20 @@ jobs: uses: martinbeentjes/npm-get-version-action@main with: path: packages/desktop + + - name: Generate Release Notes + run: echo RELEASE_NOTES="$(node ../../scripts/changelog-parser.js web desktop)" >> $GITHUB_ENV + continue-on-error: true + - name: Release uses: softprops/action-gh-release@v1 with: token: ${{ secrets.CI_PAT_TOKEN }} tag_name: "@standardnotes/desktop@${{ steps.package-version.outputs.current-version}}" + name: "Desktop ${{ steps.package-version.outputs.current-version }}" + body: ${{ env.RELEASE_NOTES }} prerelease: true draft: false - name: "Desktop ${{ steps.package-version.outputs.current-version }}" files: packages/desktop/dist/* - name: Publish Snap continue-on-error: true diff --git a/.github/workflows/mobile.release.prod.yml b/.github/workflows/mobile.release.prod.yml index 7f618328e..150eb9b9d 100644 --- a/.github/workflows/mobile.release.prod.yml +++ b/.github/workflows/mobile.release.prod.yml @@ -48,14 +48,20 @@ jobs: uses: martinbeentjes/npm-get-version-action@main with: path: packages/mobile + + - name: Generate Release Notes + run: echo RELEASE_NOTES="$(node ../../scripts/changelog-parser.js mobile)" >> $GITHUB_ENV + continue-on-error: true + - name: Release uses: softprops/action-gh-release@v1 with: token: ${{ secrets.CI_PAT_TOKEN }} tag_name: "@standardnotes/mobile@${{ steps.package-version.outputs.current-version}}" + name: "Mobile ${{ steps.package-version.outputs.current-version }}" + body: ${{ env.RELEASE_NOTES }} prerelease: true draft: false - name: "Mobile ${{ steps.package-version.outputs.current-version }}" files: | packages/mobile/android/app/build/outputs/bundle/prodRelease/app-prod-release.aab packages/mobile/android/app/build/outputs/apk/prod/release/app-prod-release.apk diff --git a/.yarn/cache/changelog-parser-npm-2.8.1-d401bef657-3fc45cdd0c.zip b/.yarn/cache/changelog-parser-npm-2.8.1-d401bef657-3fc45cdd0c.zip new file mode 100644 index 000000000..f9d56f268 Binary files /dev/null and b/.yarn/cache/changelog-parser-npm-2.8.1-d401bef657-3fc45cdd0c.zip differ diff --git a/.yarn/cache/line-reader-npm-0.2.4-c477dde8b9-a7426e5055.zip b/.yarn/cache/line-reader-npm-0.2.4-c477dde8b9-a7426e5055.zip new file mode 100644 index 000000000..5dd0bc06b Binary files /dev/null and b/.yarn/cache/line-reader-npm-0.2.4-c477dde8b9-a7426e5055.zip differ diff --git a/.yarn/cache/remove-markdown-npm-0.2.2-eb8f462ff9-ce645115c0.zip b/.yarn/cache/remove-markdown-npm-0.2.2-eb8f462ff9-ce645115c0.zip new file mode 100644 index 000000000..63091abcf Binary files /dev/null and b/.yarn/cache/remove-markdown-npm-0.2.2-eb8f462ff9-ce645115c0.zip differ diff --git a/package.json b/package.json index 189869f16..992f426c3 100644 --- a/package.json +++ b/package.json @@ -3,6 +3,10 @@ "version": "0.0.1", "private": true, "author": "Standard Notes.", + "repository": { + "type": "git", + "url": "git://github.com/standardnotes/app" + }, "workspaces": { "packages": [ "packages/*", @@ -52,6 +56,7 @@ "@standardnotes/config": "^2.4.2", "@typescript-eslint/eslint-plugin": "^5.20.0", "@typescript-eslint/parser": "^5.20.0", + "changelog-parser": "^2.8.1", "css-loader": "^6.7.1", "eslint": "^8.17.0", "husky": "^8.0.0", diff --git a/scripts/changelog-parser.js b/scripts/changelog-parser.js new file mode 100644 index 000000000..2b1138469 --- /dev/null +++ b/scripts/changelog-parser.js @@ -0,0 +1,66 @@ +const parseChangelog = require('changelog-parser') + +const scopes = ['mobile', 'web', 'desktop', 'components'] + +async function parsePackages(packageNames) { + let result = '' + let index = 0 + for (const package of packageNames) { + const parsed = await parseChangelog(`packages/${package}/CHANGELOG.md`) + const latest = parsed.versions[0] + if (packageNames.length > 1) { + result += `## ${capitalizeFirstLetter(package)} Changes\n` + } + result += `${latest.body}\n` + if (index !== packageNames.length - 1) { + result += '\n' + } + index++ + } + + return cleanOutputString(result) +} + +function capitalizeFirstLetter(string) { + return string.charAt(0).toUpperCase() + string.slice(1) +} + +function formatLine(line) { + for (const scope of scopes) { + const formattedScope = `**${scope}:**` + if (line.includes(formattedScope)) { + const parts = line.split(formattedScope) + const hasBulletAndScope = parts.length === 2 + if (hasBulletAndScope) { + return `${parts[0]}**${capitalizeFirstLetter(scope)}**: ${capitalizeFirstLetter(parts[1].trim())}` + } else { + return line.replace(formattedScope, `**${capitalizeFirstLetter(scope)}:**`) + } + } + } + + const bulletLinePrefix = '* ' + const bulletParts = line.split(bulletLinePrefix) + const hasBulletOnly = bulletParts.length === 2 + if (hasBulletOnly) { + return `${bulletLinePrefix} ${capitalizeFirstLetter(bulletParts[1])}` + } + + return line +} + +function cleanOutputString(string) { + const lines = string.split('\n') + const outLines = [] + for (const line of lines) { + const outLine = formatLine(line) + outLines.push(outLine) + } + + return outLines.join('\n') +} + +const packages = process.argv.slice(2); +parsePackages(packages).then((result) => { + process.stdout.write(result) +}) diff --git a/yarn.lock b/yarn.lock index a34b5f8c3..33fd34d8a 100644 --- a/yarn.lock +++ b/yarn.lock @@ -4962,6 +4962,7 @@ __metadata: "@standardnotes/snjs": ^2.117.8 "@typescript-eslint/eslint-plugin": ^5.20.0 "@typescript-eslint/parser": ^5.20.0 + changelog-parser: ^2.8.1 css-loader: ^6.7.1 eslint: ^8.17.0 husky: ^8.0.0 @@ -10945,6 +10946,18 @@ __metadata: languageName: node linkType: hard +"changelog-parser@npm:^2.8.1": + version: 2.8.1 + resolution: "changelog-parser@npm:2.8.1" + dependencies: + line-reader: ^0.2.4 + remove-markdown: ^0.2.2 + bin: + changelog-parser: bin/cli.js + checksum: 3fc45cdd0c89634a72f7632ef8e80b1ea43e09546c1ae64ecaf68f8e39cbc337d6012401fc3227ad28c2f6c959490ae83e11cb7ecf97358e29478eaea150747a + languageName: node + linkType: hard + "char-regex@npm:^1.0.2": version: 1.0.2 resolution: "char-regex@npm:1.0.2" @@ -21087,6 +21100,13 @@ __metadata: languageName: node linkType: hard +"line-reader@npm:^0.2.4": + version: 0.2.4 + resolution: "line-reader@npm:0.2.4" + checksum: a7426e505526c0db83d4d240a3ee2d2ba7ccb5c7b461d8325b347c963393e3cfb8e67314f8d4c156e0a05e6e4dc49d27a8c61da380745293dd98b5d8123ae192 + languageName: node + linkType: hard + "lines-and-columns@npm:^1.1.6": version: 1.2.4 resolution: "lines-and-columns@npm:1.2.4" @@ -28552,6 +28572,13 @@ __metadata: languageName: node linkType: hard +"remove-markdown@npm:^0.2.2": + version: 0.2.2 + resolution: "remove-markdown@npm:0.2.2" + checksum: ce645115c0456a9b0132d1e6c3022e13a35e6efe8eff96b3da50f709b928379caf6a773e000a10158fb4b3dccd3262ec880c68fbe0a0d23dc30ec881672dbaa6 + languageName: node + linkType: hard + "remove-trailing-separator@npm:^1.0.1": version: 1.1.0 resolution: "remove-trailing-separator@npm:1.1.0"