release.yml 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147
  1. # Pack and publish the dsh release sequence: every package under packages/ plus
  2. # the apps/ entries, all on one version. The vendored framework and the native
  3. # packages are separate sequences with their own workflows and version lines.
  4. #
  5. # Pack runs without credentials on every pull request and master push, so a
  6. # pull request proves the whole publish set still packs. Publication is a
  7. # manual dispatch from a dsh-v* tag and consumes exactly the packed bytes.
  8. name: Release (dsh)
  9. on:
  10. pull_request:
  11. push:
  12. branches: [master]
  13. workflow_dispatch:
  14. inputs:
  15. publish:
  16. description: Publish the packed tarballs to npm. Must run from a dsh-v* tag.
  17. required: true
  18. type: boolean
  19. default: false
  20. permissions:
  21. contents: read
  22. concurrency:
  23. # Pack runs per ref so concurrent pull requests never displace each
  24. # other; the publish job below serializes the shared dist-tag state.
  25. group: ${{ github.workflow }}-${{ github.ref }}
  26. cancel-in-progress: false
  27. env:
  28. PRIMARY_NODE_VERSION: '24'
  29. DSH_TELEMETRY_DISABLED: '1'
  30. jobs:
  31. pack:
  32. name: Pack npm tarballs
  33. runs-on: ubuntu-24.04
  34. steps:
  35. # Complete history: the release scripts read tags.
  36. - uses: actions/checkout@v6
  37. with:
  38. fetch-depth: 0
  39. persist-credentials: false
  40. - uses: pnpm/action-setup@v4
  41. with:
  42. dest: ${{ runner.temp }}/setup-pnpm
  43. - uses: actions/setup-node@v6
  44. with:
  45. node-version: ${{ env.PRIMARY_NODE_VERSION }}
  46. - name: Configure pnpm store path
  47. id: pnpm-store
  48. run: |
  49. store_root="$HOME/.local/share/pnpm/store"
  50. echo "PNPM_CONFIG_STORE_DIR=$store_root" >> "$GITHUB_ENV"
  51. store_path=$(PNPM_CONFIG_STORE_DIR="$store_root" pnpm store path --silent)
  52. echo "path=$store_path" >> "$GITHUB_OUTPUT"
  53. - uses: actions/cache/restore@v4
  54. with:
  55. path: ${{ steps.pnpm-store.outputs.path }}
  56. key: ${{ runner.os }}-node-${{ env.PRIMARY_NODE_VERSION }}-pnpm-${{ hashFiles('pnpm-lock.yaml') }}
  57. restore-keys: |
  58. ${{ runner.os }}-node-${{ env.PRIMARY_NODE_VERSION }}-pnpm-
  59. - name: Install (immutable)
  60. run: pnpm install --frozen-lockfile
  61. - name: Verify release version
  62. env:
  63. RELEASE_PUBLISH: ${{ inputs.publish }}
  64. run: pnpm run release:verify --family dsh
  65. - name: Build
  66. run: pnpm run build
  67. - name: Pack release tarballs
  68. run: pnpm run release:pack --family dsh --out dist/npm
  69. # The harness packages declare the vendored framework as a peer, and this
  70. # job has no credentials for the private registry, so the verification
  71. # installs that family's pack output too. Only dist/npm is published.
  72. - name: Pack the vendored framework for verification
  73. run: pnpm run release:pack --family vendor --out dist/npm-vendor
  74. # dsh-sandbox-local declares the Landlock entry as a runtime dependency, so
  75. # the verification needs its tarball. Its platform packages stay out: they
  76. # are optional, and building them needs a musl toolchain per architecture.
  77. - name: Pack the Landlock entry for verification
  78. run: |
  79. pnpm --dir native/landlock-run run build:ts
  80. pnpm --dir native/landlock-run/packages/entry pack --pack-destination "$PWD/dist/npm-landlock"
  81. - name: Verify packed install
  82. run: pnpm run release:verify-packed-install --family dsh --from dist/npm --from dist/npm-vendor --from dist/npm-landlock
  83. - uses: actions/upload-artifact@v4
  84. with:
  85. name: dsh-npm-tarballs
  86. path: dist/npm/*
  87. if-no-files-found: error
  88. retention-days: 7
  89. publish:
  90. name: Publish to npm
  91. if: inputs.publish
  92. needs: pack
  93. runs-on: ubuntu-24.04
  94. # Required reviewers and the allowed tags live on the environment; this is
  95. # the only step in the sequence that can write to the registry.
  96. environment: npm-publish
  97. concurrency:
  98. group: Release-publish
  99. cancel-in-progress: false
  100. permissions:
  101. contents: read
  102. steps:
  103. # Checkout and install carry the release scripts only. There is no build
  104. # step: publication uploads the bytes the pack job produced.
  105. - uses: actions/checkout@v6
  106. with:
  107. persist-credentials: false
  108. - uses: pnpm/action-setup@v4
  109. with:
  110. dest: ${{ runner.temp }}/setup-pnpm
  111. - uses: actions/setup-node@v6
  112. with:
  113. node-version: ${{ env.PRIMARY_NODE_VERSION }}
  114. registry-url: https://registry.npmjs.org
  115. - name: Install (immutable, no package scripts)
  116. run: pnpm install --frozen-lockfile --ignore-scripts
  117. - uses: actions/download-artifact@v4
  118. with:
  119. name: dsh-npm-tarballs
  120. path: dist/npm
  121. - name: Publish tarballs
  122. env:
  123. NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
  124. run: pnpm run release:publish --family dsh --from dist/npm