release-subpackages.yml 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  1. name: Release Subpackages
  2. on:
  3. push:
  4. branches:
  5. - master
  6. paths:
  7. - .changeset/**
  8. - .github/workflows/release-subpackages.yml
  9. workflow_run:
  10. workflows: ["Node CI for app development"]
  11. types:
  12. - completed
  13. branches:
  14. - master
  15. concurrency:
  16. group: ${{ github.workflow }}-${{ github.ref }}
  17. cancel-in-progress: true
  18. jobs:
  19. release-subpackages-snapshot:
  20. if: "!startsWith(github.head_ref, 'changeset-release/')"
  21. runs-on: ubuntu-latest
  22. steps:
  23. - uses: actions/checkout@v4
  24. - uses: actions/setup-node@v4
  25. with:
  26. node-version: '20'
  27. cache: 'yarn'
  28. cache-dependency-path: '**/yarn.lock'
  29. - name: Cache/Restore node_modules
  30. id: cache-dependencies
  31. uses: actions/cache@v4
  32. with:
  33. path: |
  34. **/node_modules
  35. key: node_modules-release-subpackages-${{ runner.OS }}-node${{ inputs.node-version }}-${{ hashFiles('**/yarn.lock') }}
  36. restore-keys: |
  37. node_modules-release-subpackages-${{ runner.OS }}-node${{ inputs.node-version }}-
  38. - name: Install dependencies
  39. run: |
  40. yarn global add turbo
  41. yarn global add node-gyp
  42. yarn --frozen-lockfile
  43. - name: Setup .npmrc
  44. run: |
  45. cat << EOF > "$HOME/.npmrc"
  46. //registry.npmjs.org/:_authToken=$NPM_TOKEN
  47. EOF
  48. env:
  49. NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
  50. - name: Retrieve changesets information
  51. id: changesets-status
  52. run: |
  53. yarn changeset status --output status.json
  54. echo "CHANGESETS_LENGTH=$(jq -r '.changesets | length' status.json)" >> $GITHUB_OUTPUT
  55. rm status.json
  56. - name: Snapshot release to npm
  57. if: steps.changesets-status.outputs.CHANGESETS_LENGTH > 0
  58. run: |
  59. yarn release-subpackages:snapshot
  60. env:
  61. GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
  62. NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
  63. release-subpackages:
  64. runs-on: ubuntu-latest
  65. steps:
  66. - uses: actions/checkout@v4
  67. - uses: actions/setup-node@v4
  68. with:
  69. node-version: '20'
  70. cache: 'yarn'
  71. cache-dependency-path: '**/yarn.lock'
  72. - name: Cache/Restore node_modules
  73. id: cache-dependencies
  74. uses: actions/cache@v4
  75. with:
  76. path: |
  77. **/node_modules
  78. key: node_modules-release-subpackages-${{ runner.OS }}-node${{ inputs.node-version }}-${{ hashFiles('**/yarn.lock') }}
  79. restore-keys: |
  80. node_modules-release-subpackages-${{ runner.OS }}-node${{ inputs.node-version }}-
  81. - name: Install dependencies
  82. run: |
  83. yarn global add turbo
  84. yarn global add node-gyp
  85. yarn --frozen-lockfile
  86. - name: Create Release Pull Request or Publish to npm
  87. id: changesets
  88. uses: changesets/action@v1
  89. with:
  90. title: Release Subpackages
  91. publish: yarn release-subpackages
  92. env:
  93. GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
  94. NPM_TOKEN: ${{ secrets.NPM_TOKEN }}