diff --git a/.github/workflows/pr.yml b/.github/workflows/pr.yml index 77fb6698..98950a96 100644 --- a/.github/workflows/pr.yml +++ b/.github/workflows/pr.yml @@ -29,7 +29,7 @@ jobs: run: yarn install - name: Derive appropriate SHAs for base and head for `nx affected` commands - uses: nrwl/nx-set-shas@v1 + uses: tripss/nx-extend/actions/set-shas@improvements with: main-branch-name: master diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 6bbd908c..c2637008 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -33,10 +33,6 @@ jobs: if: steps.cache.outputs.cache-hit != 'true' run: yarn install - - name: Set correct env vars - id: script - uses: ./tools/actions/set-master-vars - release: needs: [ prepare-env ] runs-on: ubuntu-latest @@ -52,23 +48,33 @@ jobs: **/node_modules key: ${{ env.DEPENDENCIES_CACHE }}-${{ hashFiles('yarn.lock') }} - - name: GIT config + - name: GIT/NPM config run: | git config user.name "${GITHUB_ACTOR}" git config user.email "${GITHUB_ACTOR}@users.noreply.github.com" + echo "//registry.npmjs.org/:_authToken=${NPM_TOKEN}" > .npmrc + env: + NPM_TOKEN: ${{ secrets.NPM_TOKEN }} + + - name: Derive appropriate SHAs for base and head for `nx affected` commands + uses: tripss/nx-extend/actions/set-shas@improvements + with: + main-branch-name: master - name: nx affected:version - run: node ./tools/scripts/run-many.js version origin/${{ needs.prepare-env.outputs.GITHUB_HEAD_REF }} ${{ needs.prepare-env.outputs.GITHUB_BASE_REF }} + uses: ./actions/run-many + with: + target: version - name: nx affected:build - run: node ./tools/scripts/run-many.js build origin/${{ needs.prepare-env.outputs.GITHUB_HEAD_REF }} ${{ needs.prepare-env.outputs.GITHUB_BASE_REF }} + uses: ./actions/run-many + with: + target: build - name: nx affected:publish - run: | - echo "//registry.npmjs.org/:_authToken=${NPM_TOKEN}" > .npmrc - node ./tools/scripts/run-many.js publish origin/${{ needs.prepare-env.outputs.GITHUB_HEAD_REF }} ${{ needs.prepare-env.outputs.GITHUB_BASE_REF }} - env: - NPM_TOKEN: ${{ secrets.NPM_TOKEN }} + uses: ./actions/run-many + with: + target: publish - name: Push GIT run: git push --follow-tags origin ${{ needs.prepare-env.outputs.GITHUB_HEAD_REF }} diff --git a/packages/changelog-notify/project.json b/packages/changelog-notify/project.json index 35813a83..d0fe34b1 100644 --- a/packages/changelog-notify/project.json +++ b/packages/changelog-notify/project.json @@ -52,6 +52,12 @@ "options": { "versionTagPrefix": "${target}@" } + }, + "publish": { + "executor": "nx:run-commands", + "options": { + "command": "npm publish ./dist/packages/changelog-notify --access public" + } } }, "tags": [] diff --git a/packages/core/project.json b/packages/core/project.json index 4d3bb37d..a7380b26 100644 --- a/packages/core/project.json +++ b/packages/core/project.json @@ -51,6 +51,12 @@ "options": { "versionTagPrefix": "${target}@" } + }, + "publish": { + "executor": "nx:run-commands", + "options": { + "command": "npm publish ./dist/packages/core --access public" + } } }, "tags": [] diff --git a/packages/e2e-runner/project.json b/packages/e2e-runner/project.json index 6ae2459e..5051d63a 100644 --- a/packages/e2e-runner/project.json +++ b/packages/e2e-runner/project.json @@ -58,6 +58,12 @@ "options": { "versionTagPrefix": "${target}@" } + }, + "publish": { + "executor": "nx:run-commands", + "options": { + "command": "npm publish ./dist/packages/e2e-runner --access public" + } } }, "tags": [] diff --git a/packages/firebase-hosting/project.json b/packages/firebase-hosting/project.json index ed9411a4..8c98bd85 100644 --- a/packages/firebase-hosting/project.json +++ b/packages/firebase-hosting/project.json @@ -57,6 +57,12 @@ "options": { "versionTagPrefix": "${target}@" } + }, + "publish": { + "executor": "nx:run-commands", + "options": { + "command": "npm publish ./dist/packages/firebase-hosting --access public" + } } }, "tags": [] diff --git a/packages/gcp-cloud-run/project.json b/packages/gcp-cloud-run/project.json index dbd12d18..70131be3 100644 --- a/packages/gcp-cloud-run/project.json +++ b/packages/gcp-cloud-run/project.json @@ -52,6 +52,12 @@ "options": { "versionTagPrefix": "${target}@" } + }, + "publish": { + "executor": "nx:run-commands", + "options": { + "command": "npm publish ./dist/packages/gcp-cloud-run --access public" + } } }, "tags": [] diff --git a/packages/gcp-deployment-manager/project.json b/packages/gcp-deployment-manager/project.json index 39e25e8d..0c99a6c4 100644 --- a/packages/gcp-deployment-manager/project.json +++ b/packages/gcp-deployment-manager/project.json @@ -52,6 +52,12 @@ "options": { "versionTagPrefix": "${target}@" } + }, + "publish": { + "executor": "nx:run-commands", + "options": { + "command": "npm publish ./dist/packages/gcp-deployment-manager --access public" + } } }, "tags": [] diff --git a/packages/gcp-functions/project.json b/packages/gcp-functions/project.json index 8c9c476e..ac5c87f0 100644 --- a/packages/gcp-functions/project.json +++ b/packages/gcp-functions/project.json @@ -59,6 +59,12 @@ "options": { "versionTagPrefix": "${target}@" } + }, + "publish": { + "executor": "nx:run-commands", + "options": { + "command": "npm publish ./dist/packages/gcp-functions --access public" + } } }, "tags": [] diff --git a/packages/gcp-secrets/project.json b/packages/gcp-secrets/project.json index c7966a5d..c33f5a08 100644 --- a/packages/gcp-secrets/project.json +++ b/packages/gcp-secrets/project.json @@ -52,6 +52,12 @@ "options": { "versionTagPrefix": "${target}@" } + }, + "publish": { + "executor": "nx:run-commands", + "options": { + "command": "npm publish ./dist/packages/gcp-secrets --access public" + } } }, "tags": [] diff --git a/packages/gcp-storage/project.json b/packages/gcp-storage/project.json index c3b90979..ab51ad8a 100644 --- a/packages/gcp-storage/project.json +++ b/packages/gcp-storage/project.json @@ -52,6 +52,12 @@ "options": { "versionTagPrefix": "${target}@" } + }, + "publish": { + "executor": "nx:run-commands", + "options": { + "command": "npm publish ./dist/packages/gcp-storage --access public" + } } }, "tags": [] diff --git a/packages/gcp-task-runner/project.json b/packages/gcp-task-runner/project.json index 11c63fa2..67497c11 100644 --- a/packages/gcp-task-runner/project.json +++ b/packages/gcp-task-runner/project.json @@ -56,6 +56,12 @@ "options": { "versionTagPrefix": "${target}@" } + }, + "publish": { + "executor": "nx:run-commands", + "options": { + "command": "npm publish ./dist/packages/gcp-task-runner --access public" + } } }, "tags": [] diff --git a/packages/github-pages/project.json b/packages/github-pages/project.json index 7dbee93e..8bce5c4a 100644 --- a/packages/github-pages/project.json +++ b/packages/github-pages/project.json @@ -56,6 +56,12 @@ "options": { "versionTagPrefix": "${target}@" } + }, + "publish": { + "executor": "nx:run-commands", + "options": { + "command": "npm publish ./dist/packages/github-pages --access public" + } } }, "tags": [] diff --git a/packages/playwright/project.json b/packages/playwright/project.json index 2048c079..668d471c 100644 --- a/packages/playwright/project.json +++ b/packages/playwright/project.json @@ -52,6 +52,12 @@ "options": { "versionTagPrefix": "${target}@" } + }, + "publish": { + "executor": "nx:run-commands", + "options": { + "command": "npm publish ./dist/packages/playwright --access public" + } } }, "tags": [] diff --git a/packages/pulumi/project.json b/packages/pulumi/project.json index 6c6049e4..b59a47d2 100644 --- a/packages/pulumi/project.json +++ b/packages/pulumi/project.json @@ -52,6 +52,12 @@ "options": { "versionTagPrefix": "${target}@" } + }, + "publish": { + "executor": "nx:run-commands", + "options": { + "command": "npm publish ./dist/packages/pulumi --access public" + } } }, "tags": [] diff --git a/packages/strapi/project.json b/packages/strapi/project.json index 2c8397eb..34b4c906 100644 --- a/packages/strapi/project.json +++ b/packages/strapi/project.json @@ -52,6 +52,12 @@ "options": { "versionTagPrefix": "${target}@" } + }, + "publish": { + "executor": "nx:run-commands", + "options": { + "command": "npm publish ./dist/packages/strapi --access public" + } } }, "tags": [] diff --git a/packages/terraform/project.json b/packages/terraform/project.json index 735350e8..bc99fb25 100644 --- a/packages/terraform/project.json +++ b/packages/terraform/project.json @@ -52,6 +52,12 @@ "options": { "versionTagPrefix": "${target}@" } + }, + "publish": { + "executor": "nx:run-commands", + "options": { + "command": "npm publish ./dist/packages/terraform --access public" + } } }, "tags": [] diff --git a/packages/translations/project.json b/packages/translations/project.json index e90eab2a..ea22ed02 100644 --- a/packages/translations/project.json +++ b/packages/translations/project.json @@ -52,6 +52,12 @@ "options": { "versionTagPrefix": "${target}@" } + }, + "publish": { + "executor": "nx:run-commands", + "options": { + "command": "npm publish ./dist/packages/translations --access public" + } } }, "tags": [] diff --git a/packages/vercel/project.json b/packages/vercel/project.json index 823691d3..bfc5ad26 100644 --- a/packages/vercel/project.json +++ b/packages/vercel/project.json @@ -52,6 +52,12 @@ "options": { "versionTagPrefix": "${target}@" } + }, + "publish": { + "executor": "nx:run-commands", + "options": { + "command": "npm publish ./dist/packages/vercel --access public" + } } }, "tags": [] diff --git a/tools/actions/pr-log-changed-projects/action.yml b/tools/actions/pr-log-changed-projects/action.yml deleted file mode 100644 index b3afab10..00000000 --- a/tools/actions/pr-log-changed-projects/action.yml +++ /dev/null @@ -1,6 +0,0 @@ -name: 'Log changed projects' -description: 'Logs all changed projects' -author: 'Tycho Bokdam' -runs: - using: 'node12' - main: 'src/index.js' diff --git a/tools/actions/pr-log-changed-projects/src/index.js b/tools/actions/pr-log-changed-projects/src/index.js deleted file mode 100644 index 89d53e72..00000000 --- a/tools/actions/pr-log-changed-projects/src/index.js +++ /dev/null @@ -1,27 +0,0 @@ -const core = require('@actions/core') -const { execSync } = require('child_process') - -const { GITHUB_HEAD_REF } = process.env - -const latestTag = execSync(`git describe --tags $(git rev-list --tags --max-count=1)`) - .toString('utf8') - .trim() - -const tagSha = execSync(`git rev-list -n 1 ${latestTag}`) - .toString('utf8') - .trim() - -core.info(`"${latestTag}" is the latest tag with "${tagSha}" sha`) -core.info(`"${GITHUB_HEAD_REF}" is the current head`) - -core.info(`Fetching changed projects between https://github.com/tripss/nx-extend/compare/${latestTag}...${GITHUB_HEAD_REF}`) - -const affected = execSync(`npx nx print-affected --target=version --head=origin/${GITHUB_HEAD_REF} --base=${tagSha}`) - .toString('utf8') - .trim() - -const affectedProjects = JSON.parse(affected) - .tasks.map((task) => task.target.project) - .sort() - -execSync(`npx nx run-many --target=version --projects=${affectedProjects.join(',')} --baseBranch="${latestTag}" --dryRun`, { stdio: 'inherit' }) diff --git a/tools/actions/set-master-vars/action.yml b/tools/actions/set-master-vars/action.yml deleted file mode 100644 index 8ac84d53..00000000 --- a/tools/actions/set-master-vars/action.yml +++ /dev/null @@ -1,14 +0,0 @@ -name: 'Set the correct master variables' -description: 'Sets the correct master environment variables' -author: 'Tycho Bokdam' -runs: - using: 'node12' - main: 'src/index.js' - -outputs: - tag: - description: 'The latest tag' - tagHash: - description: 'The hash of the latest tag' - headRef: - description: 'The correct head ref to use' diff --git a/tools/actions/set-master-vars/src/index.js b/tools/actions/set-master-vars/src/index.js deleted file mode 100644 index dcf91726..00000000 --- a/tools/actions/set-master-vars/src/index.js +++ /dev/null @@ -1,22 +0,0 @@ -const core = require('@actions/core') -const { execSync } = require('child_process') - -const { GITHUB_REF } = process.env - -core.info('Fetching latest tag...') -const latestTag = execSync(`git describe --tags $(git rev-list --tags --max-count=1)`) - .toString('utf8') - .trim() - -const tagSha = execSync(`git rev-list -n 1 ${latestTag}`) - .toString('utf8') - .trim() - -const headRef = GITHUB_REF.replace('refs/heads/', '') - -core.info(`"${latestTag}" is the latest tag with "${tagSha}" sha`) -core.info(`"${headRef}" is the head ref`) - -core.setOutput('tag', latestTag) -core.setOutput('tagHash', tagSha) -core.setOutput('headRef', headRef) diff --git a/tools/scripts/run-many.js b/tools/scripts/run-many.js deleted file mode 100644 index c80d1ae3..00000000 --- a/tools/scripts/run-many.js +++ /dev/null @@ -1,63 +0,0 @@ -const { logger } = require('@nx/devkit') -const { execSync } = require('child_process') -const core = require('@actions/core') - -const target = process.argv[2] -const headRef = process.argv[5] -const baseRef = process.argv[6] - -const nxArgs = - headRef !== baseRef && baseRef !== 'empty' - ? `--head=${headRef} --base=${baseRef}` - : '--all' - -const buildAffectedCommand = [ - 'npx nx print-affected', - `--target=${target !== 'publish' ? target : 'version'}`, - nxArgs -] - -const affectedCommand = buildAffectedCommand.join(' ') - -logger.info(`Running: ${affectedCommand}`) - -const affected = execSync(affectedCommand).toString('utf-8') - -const affectedProjects = JSON.parse(affected) - .tasks.map((task) => task.target.project) - .slice() - .sort() - -if (affectedProjects.length > 0) { - if (target === 'publish') { - while (affectedProjects.length > 0) { - const project = affectedProjects.shift() - - // Try to Publish the package - try { - execSync(`npm publish ./dist/packages/${project} --access public`, { - stdio: 'inherit' - }) - } catch (err) { - core.warning(`Error publishing ${project}`, err) - } - } - } else { - const execCommand = [ - 'npx nx run-many', - `--target=${target}`, - `--projects=${affectedProjects.join(',')}` - ] - - if (target === 'version') { - execCommand.push('--baseBranch="master"') - execCommand.push('--changelogHeader=" "') - } - - const command = execCommand.join(' ') - - logger.info(`Running: ${command}`) - - execSync(command, { stdio: 'inherit' }) - } -}