name: Release Subpackages on: push: branches: - master paths: - .changeset/** - .github/workflows/release-subpackages.yml workflow_run: workflows: ["Node CI for app development"] types: - completed branches: - master concurrency: group: ${{ github.workflow }}-${{ github.ref }} cancel-in-progress: true jobs: release-subpackages-snapshot: if: "!startsWith(github.head_ref, 'changeset-release/')" runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - uses: actions/setup-node@v4 with: node-version: '20' cache: 'yarn' cache-dependency-path: '**/yarn.lock' - name: Cache/Restore node_modules id: cache-dependencies uses: actions/cache@v4 with: path: | **/node_modules key: node_modules-release-subpackages-${{ runner.OS }}-node${{ inputs.node-version }}-${{ hashFiles('**/yarn.lock') }} restore-keys: | node_modules-release-subpackages-${{ runner.OS }}-node${{ inputs.node-version }}- - name: Install dependencies run: | yarn global add turbo yarn global add node-gyp yarn --frozen-lockfile - name: Setup .npmrc run: | cat << EOF > "$HOME/.npmrc" //registry.npmjs.org/:_authToken=$NPM_TOKEN EOF env: NPM_TOKEN: ${{ secrets.NPM_TOKEN }} - name: Retrieve changesets information id: changesets-status run: | yarn changeset status --output status.json echo "CHANGESETS_LENGTH=$(jq -r '.changesets | length' status.json)" >> $GITHUB_OUTPUT rm status.json - name: Snapshot release to npm if: steps.changesets-status.outputs.CHANGESETS_LENGTH > 0 run: | yarn release-subpackages:snapshot env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} NPM_TOKEN: ${{ secrets.NPM_TOKEN }} release-subpackages: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - uses: actions/setup-node@v4 with: node-version: '20' cache: 'yarn' cache-dependency-path: '**/yarn.lock' - name: Cache/Restore node_modules id: cache-dependencies uses: actions/cache@v4 with: path: | **/node_modules key: node_modules-release-subpackages-${{ runner.OS }}-node${{ inputs.node-version }}-${{ hashFiles('**/yarn.lock') }} restore-keys: | node_modules-release-subpackages-${{ runner.OS }}-node${{ inputs.node-version }}- - name: Install dependencies run: | yarn global add turbo yarn global add node-gyp yarn --frozen-lockfile - name: Create Release Pull Request or Publish to npm id: changesets uses: changesets/action@v1 with: title: Release Subpackages version: yarn version-subpackages publish: yarn release-subpackages env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} NPM_TOKEN: ${{ secrets.NPM_TOKEN }}