Repository: JoshuaKGoldberg/create-typescript-app
Pull request #1666 (2024-10-18 00:04:02)

fix: reset post-release back to npm pkg get again
## PR Checklist

- [x] Addresses an existing open issue: fixes broken post-release after #1663 and #1665
- [x] That issue was marked as [`status: accepting prs`](https://github.com/JoshuaKGoldberg/create-typescript-app/issues?q=is%3Aopen+is%3Aissue+label%3A%22status%3A+accepting+prs%22)
- [x] Steps in [CONTRIBUTING.md](https://github.com/JoshuaKGoldberg/create-typescript-app/blob/main/.github/CONTRIBUTING.md) were taken

## Overview

Sigh.

💖 


Patch:
diff --git a/.github/workflows/post-release.yml b/.github/workflows/post-release.yml
index f898971..4f649c4 100644
--- a/.github/workflows/post-release.yml
+++ b/.github/workflows/post-release.yml
@@ -5,6 +5,7 @@ jobs:
       - uses: actions/checkout@v4
         with:
           fetch-depth: 0
+      - run: echo "npm_version=$(npm pkg get version | tr -d '"')" >> "$GITHUB_ENV"
       - uses: apexskier/github-release-commenter@v1
         with:
           GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
@@ -14,7 +15,7 @@ jobs:
             The release is available on:
 
             * [GitHub releases](https://github.com/JoshuaKGoldberg/create-typescript-app/releases/tag/{release_tag})
-            * [npm package (@latest dist-tag)](https://www.npmjs.com/package/create-typescript-app/v/{${{ payload.release.tag_name }}})
+            * [npm package (@latest dist-tag)](https://www.npmjs.com/package/create-typescript-app/v/${{ env.npm_version }})
 
             Cheers! 📦🚀
 
diff --git a/src/steps/writing/creation/dotGitHub/createWorkflows.ts b/src/steps/writing/creation/dotGitHub/createWorkflows.ts
index e1f9a0a..064a6a1 100644
--- a/src/steps/writing/creation/dotGitHub/createWorkflows.ts
+++ b/src/steps/writing/creation/dotGitHub/createWorkflows.ts
@@ -155,6 +155,9 @@ export function createWorkflows(options: Options) {
 				},
 				steps: [
 					{ uses: "actions/checkout@v4", with: { "fetch-depth": 0 } },
+					{
+						run: `echo "npm_version=$(npm pkg get version | tr -d '"')" >> "$GITHUB_ENV"`,
+					},
 					{
 						uses: "apexskier/github-release-commenter@v1",
 						with: {
@@ -164,7 +167,7 @@ export function createWorkflows(options: Options) {
 							The release is available on:
 
 							* [GitHub releases](https://github.com/${options.owner}/${options.repository}/releases/tag/{release_tag})
-							* [npm package (@latest dist-tag)](https://www.npmjs.com/package/${options.repository}/v/{\${{ payload.release.tag_name }}})
+							* [npm package (@latest dist-tag)](https://www.npmjs.com/package/${options.repository}/v/\${{ env.npm_version }})
 
 							Cheers! 📦🚀
 						`,


Test patch:
diff --git a/src/steps/writing/creation/dotGitHub/createWorkflows.test.ts b/src/steps/writing/creation/dotGitHub/createWorkflows.test.ts
index 27c9413..6eaa1c0 100644
--- a/src/steps/writing/creation/dotGitHub/createWorkflows.test.ts
+++ b/src/steps/writing/creation/dotGitHub/createWorkflows.test.ts
@@ -197,6 +197,7 @@ describe("createWorkflows", () => {
 			      - uses: actions/checkout@v4
 			        with:
 			          fetch-depth: 0
+			      - run: echo "npm_version=$(npm pkg get version | tr -d '"')" >> "$GITHUB_ENV"
 			      - uses: apexskier/github-release-commenter@v1
 			        with:
 			          GITHUB_TOKEN: \${{ secrets.GITHUB_TOKEN }}
@@ -206,7 +207,7 @@ describe("createWorkflows", () => {
 			              The release is available on:
 
 			              * [GitHub releases](https://github.com/StubOwner/stub-repository/releases/tag/{release_tag})
-			              * [npm package (@latest dist-tag)](https://www.npmjs.com/package/stub-repository/v/{\${{ payload.release.tag_name }}})
+			              * [npm package (@latest dist-tag)](https://www.npmjs.com/package/stub-repository/v/\${{ env.npm_version }})
 
 			              Cheers! 📦🚀