release-subpackages.yml 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  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. echo "CHANGESETS_LENGTH=$(yarn changeset status --output status.json && jq -r '.changesets | length' status.json && rm status.json)" >> $GITHUB_OUTPUT
  54. - name: Snapshot release to npm
  55. if: ${{ steps.changesets-status.outputs.CHANGESETS_LENGTH }} > 0
  56. run: |
  57. yarn release-subpackages:snapshot
  58. env:
  59. GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
  60. NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
  61. release-subpackages:
  62. runs-on: ubuntu-latest
  63. steps:
  64. - uses: actions/checkout@v4
  65. - uses: actions/setup-node@v4
  66. with:
  67. node-version: '20'
  68. cache: 'yarn'
  69. cache-dependency-path: '**/yarn.lock'
  70. - name: Cache/Restore node_modules
  71. id: cache-dependencies
  72. uses: actions/cache@v4
  73. with:
  74. path: |
  75. **/node_modules
  76. key: node_modules-release-subpackages-${{ runner.OS }}-node${{ inputs.node-version }}-${{ hashFiles('**/yarn.lock') }}
  77. restore-keys: |
  78. node_modules-release-subpackages-${{ runner.OS }}-node${{ inputs.node-version }}-
  79. - name: Install dependencies
  80. run: |
  81. yarn global add turbo
  82. yarn global add node-gyp
  83. yarn --frozen-lockfile
  84. - name: Create Release Pull Request or Publish to npm
  85. id: changesets
  86. uses: changesets/action@v1
  87. with:
  88. title: Release Subpackages
  89. publish: yarn release-subpackages
  90. env:
  91. GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
  92. NPM_TOKEN: ${{ secrets.NPM_TOKEN }}