release.yml 8.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287
  1. name: Release
  2. on:
  3. push:
  4. tags:
  5. - "v*"
  6. permissions:
  7. contents: write
  8. jobs:
  9. test:
  10. runs-on: ubuntu-latest
  11. strategy:
  12. matrix:
  13. node-version: [20, 22]
  14. steps:
  15. - uses: actions/checkout@v4
  16. - uses: pnpm/action-setup@v4
  17. with:
  18. version: 9
  19. - uses: actions/setup-node@v4
  20. with:
  21. node-version: ${{ matrix.node-version }}
  22. cache: pnpm
  23. - run: pnpm install --frozen-lockfile
  24. - run: pnpm build
  25. - run: pnpm --filter @actalk/inkos-core typecheck
  26. - run: pnpm --filter @actalk/inkos typecheck
  27. - run: pnpm test
  28. smoke-test:
  29. runs-on: ubuntu-latest
  30. needs: test
  31. steps:
  32. - uses: actions/checkout@v4
  33. - uses: pnpm/action-setup@v4
  34. with:
  35. version: 9
  36. - uses: actions/setup-node@v4
  37. with:
  38. node-version: 22
  39. cache: pnpm
  40. - run: pnpm install --frozen-lockfile
  41. - run: pnpm build
  42. - name: Smoke test — CLI help and version
  43. run: |
  44. node packages/cli/dist/index.js --help
  45. node packages/cli/dist/index.js --version
  46. - name: Smoke test — core import
  47. run: node -e "import('./packages/core/dist/index.js').then(m => { if (!m.PipelineRunner) throw new Error('missing PipelineRunner'); console.log('core import OK') })"
  48. - name: Smoke test — verify no workspace:* in tarballs
  49. run: |
  50. set -euo pipefail
  51. for pkg in packages/core packages/cli; do
  52. echo "--- Checking $pkg ---"
  53. cd "$pkg"
  54. PACKDIR=$(mktemp -d)
  55. npm pack --pack-destination "$PACKDIR" 2>/dev/null
  56. TGZ=$(ls "$PACKDIR"/*.tgz)
  57. PACKED_PKG=$(tar -xOf "$TGZ" package/package.json)
  58. if echo "$PACKED_PKG" | grep -q '"workspace:'; then
  59. echo "FAIL: $pkg tarball still contains workspace: protocol"
  60. echo "$PACKED_PKG" | grep 'workspace:'
  61. exit 1
  62. fi
  63. echo "OK: $pkg tarball is clean"
  64. rm -rf "$PACKDIR"
  65. cd - >/dev/null
  66. done
  67. publish-canary:
  68. runs-on: ubuntu-latest
  69. needs: smoke-test
  70. outputs:
  71. release_version: ${{ steps.versions.outputs.release_version }}
  72. canary_version: ${{ steps.versions.outputs.canary_version }}
  73. steps:
  74. - uses: actions/checkout@v4
  75. - uses: pnpm/action-setup@v4
  76. with:
  77. version: 9
  78. - uses: actions/setup-node@v4
  79. with:
  80. node-version: 22
  81. cache: pnpm
  82. registry-url: https://registry.npmjs.org
  83. - run: pnpm install --frozen-lockfile
  84. - run: pnpm build
  85. - name: Derive release versions
  86. id: versions
  87. run: |
  88. RELEASE_VERSION="${GITHUB_REF_NAME#v}"
  89. CANARY_VERSION="${RELEASE_VERSION}-canary.${GITHUB_RUN_NUMBER}.${GITHUB_RUN_ATTEMPT}"
  90. echo "release_version=$RELEASE_VERSION" >> "$GITHUB_OUTPUT"
  91. echo "canary_version=$CANARY_VERSION" >> "$GITHUB_OUTPUT"
  92. - name: Rewrite package versions for canary publish
  93. run: |
  94. node scripts/set-package-versions.mjs "${{ steps.versions.outputs.canary_version }}" --root .
  95. pnpm verify:publish-manifests
  96. - name: Publish core canary
  97. working-directory: packages/core
  98. run: pnpm publish --tag canary --access public --no-git-checks
  99. env:
  100. NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
  101. - name: Publish CLI canary
  102. working-directory: packages/cli
  103. run: pnpm publish --tag canary --access public --no-git-checks
  104. env:
  105. NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
  106. verify-canary:
  107. runs-on: ubuntu-latest
  108. needs: publish-canary
  109. steps:
  110. - uses: actions/setup-node@v4
  111. with:
  112. node-version: 22
  113. registry-url: https://registry.npmjs.org
  114. - name: Verify canary dist-tag and installation
  115. run: |
  116. set -euo pipefail
  117. EXPECTED_CANARY="${{ needs.publish-canary.outputs.canary_version }}"
  118. ACTUAL_CANARY=""
  119. for _ in 1 2 3 4 5 6; do
  120. ACTUAL_CANARY=$(npm view @actalk/inkos@canary version 2>/dev/null || true)
  121. if [ "$ACTUAL_CANARY" = "$EXPECTED_CANARY" ]; then
  122. break
  123. fi
  124. sleep 10
  125. done
  126. if [ "$ACTUAL_CANARY" != "$EXPECTED_CANARY" ]; then
  127. echo "FATAL: canary dist-tag mismatch: expected $EXPECTED_CANARY got ${ACTUAL_CANARY:-<empty>}"
  128. exit 1
  129. fi
  130. TMPDIR=$(mktemp -d)
  131. cd "$TMPDIR"
  132. npm init -y
  133. npm install "@actalk/inkos@$EXPECTED_CANARY"
  134. if grep -q '"workspace:' node_modules/@actalk/inkos/package.json; then
  135. echo "FATAL: canary CLI package still contains workspace: protocol"
  136. cat node_modules/@actalk/inkos/package.json | grep workspace
  137. exit 1
  138. fi
  139. if grep -q '"workspace:' node_modules/@actalk/inkos-core/package.json; then
  140. echo "FATAL: canary core package still contains workspace: protocol"
  141. cat node_modules/@actalk/inkos-core/package.json | grep workspace
  142. exit 1
  143. fi
  144. npx inkos --version
  145. echo "Canary verification passed"
  146. rm -rf "$TMPDIR"
  147. publish-release:
  148. runs-on: ubuntu-latest
  149. needs: [publish-canary, verify-canary]
  150. steps:
  151. - uses: actions/checkout@v4
  152. - uses: pnpm/action-setup@v4
  153. with:
  154. version: 9
  155. - uses: actions/setup-node@v4
  156. with:
  157. node-version: 22
  158. cache: pnpm
  159. registry-url: https://registry.npmjs.org
  160. - run: pnpm install --frozen-lockfile
  161. - run: pnpm build
  162. - name: Rewrite package versions for final publish
  163. run: |
  164. node scripts/set-package-versions.mjs "${{ needs.publish-canary.outputs.release_version }}" --root .
  165. pnpm verify:publish-manifests
  166. - name: Publish core latest
  167. working-directory: packages/core
  168. run: pnpm publish --access public --no-git-checks
  169. env:
  170. NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
  171. - name: Publish CLI latest
  172. working-directory: packages/cli
  173. run: pnpm publish --access public --no-git-checks
  174. env:
  175. NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
  176. verify-release:
  177. runs-on: ubuntu-latest
  178. needs: [publish-canary, publish-release]
  179. steps:
  180. - uses: actions/setup-node@v4
  181. with:
  182. node-version: 22
  183. registry-url: https://registry.npmjs.org
  184. - name: Verify latest dist-tag and installation
  185. run: |
  186. set -euo pipefail
  187. EXPECTED_RELEASE="${{ needs.publish-canary.outputs.release_version }}"
  188. ACTUAL_LATEST=""
  189. for _ in 1 2 3 4 5 6; do
  190. ACTUAL_LATEST=$(npm view @actalk/inkos@latest version 2>/dev/null || true)
  191. if [ "$ACTUAL_LATEST" = "$EXPECTED_RELEASE" ]; then
  192. break
  193. fi
  194. sleep 10
  195. done
  196. if [ "$ACTUAL_LATEST" != "$EXPECTED_RELEASE" ]; then
  197. echo "FATAL: latest dist-tag mismatch: expected $EXPECTED_RELEASE got ${ACTUAL_LATEST:-<empty>}"
  198. exit 1
  199. fi
  200. TMPDIR=$(mktemp -d)
  201. cd "$TMPDIR"
  202. npm init -y
  203. npm install "@actalk/inkos@$EXPECTED_RELEASE"
  204. if grep -q '"workspace:' node_modules/@actalk/inkos/package.json; then
  205. echo "FATAL: released CLI package still contains workspace: protocol"
  206. cat node_modules/@actalk/inkos/package.json | grep workspace
  207. exit 1
  208. fi
  209. if grep -q '"workspace:' node_modules/@actalk/inkos-core/package.json; then
  210. echo "FATAL: released core package still contains workspace: protocol"
  211. cat node_modules/@actalk/inkos-core/package.json | grep workspace
  212. exit 1
  213. fi
  214. npx inkos --version
  215. echo "Release verification passed"
  216. rm -rf "$TMPDIR"
  217. github-release:
  218. runs-on: ubuntu-latest
  219. needs: verify-release
  220. steps:
  221. - uses: actions/checkout@v4
  222. with:
  223. fetch-depth: 0
  224. - name: Generate release notes
  225. id: notes
  226. run: |
  227. PREV_TAG=$(git tag --sort=-creatordate | sed -n '2p' || echo "")
  228. if [ -n "$PREV_TAG" ]; then
  229. echo "notes<<EOF" >> "$GITHUB_OUTPUT"
  230. git log --pretty=format:"- %s (%h)" "$PREV_TAG"..HEAD >> "$GITHUB_OUTPUT"
  231. echo "" >> "$GITHUB_OUTPUT"
  232. echo "EOF" >> "$GITHUB_OUTPUT"
  233. else
  234. echo "notes=Initial release" >> "$GITHUB_OUTPUT"
  235. fi
  236. - uses: softprops/action-gh-release@v2
  237. with:
  238. body: ${{ steps.notes.outputs.notes }}
  239. generate_release_notes: true