From 509c1d8378548f4a850da8183112fa04291fe839 Mon Sep 17 00:00:00 2001 From: "John-Mason P. Shackelford" Date: Thu, 13 Mar 2025 15:38:07 -0400 Subject: [PATCH 01/16] feat: support npm for oclif readme generation --- .../actions/generateOclifReadme/action.yml | 32 ++++++++++++++----- .github/workflows/create-github-release.yml | 8 ++++- 2 files changed, 31 insertions(+), 9 deletions(-) diff --git a/.github/actions/generateOclifReadme/action.yml b/.github/actions/generateOclifReadme/action.yml index 3a9fa9a..7258a68 100644 --- a/.github/actions/generateOclifReadme/action.yml +++ b/.github/actions/generateOclifReadme/action.yml @@ -12,6 +12,10 @@ inputs: description: The name of the prerelease channel (e.g. dev, beta) multi: description: Create a different markdown page for each topic. + package-manager: + description: Package manager to use (npm or yarn) + required: false + default: "yarn" runs: using: composite @@ -42,13 +46,25 @@ runs: if: ${{ steps.is-oclif-plugin.outputs.bool == 'true' && steps.next-version.outputs.skipped == 'false' }} shell: bash run: | - yarn install - yarn tsc - yarn oclif readme \ - --no-aliases \ - --version "$STEPS_NEXT_VERSION_TAG" \ - ${{ inputs.multi == 'true' && '--multi' || '' }} \ - --repository-prefix "<%- repo %>/blob/<%- version %>/<%- commandPath %>" \ - || echo "::warning::'oclif readme' failed. Check the logs." + if [ "$INPUTS_PACKAGE_MANAGER" = "npm" ]; then + npm install + npm run tsc + npm run oclif readme \ + --no-aliases \ + --version "$STEPS_NEXT_VERSION_TAG" \ + ${{ inputs.multi == 'true' && '--multi' || '' }} \ + --repository-prefix "<%- repo %>/blob/<%- version %>/<%- commandPath %>" \ + || echo "::warning::'oclif readme' failed. Check the logs." + else + yarn install + yarn tsc + yarn oclif readme \ + --no-aliases \ + --version "$STEPS_NEXT_VERSION_TAG" \ + ${{ inputs.multi == 'true' && '--multi' || '' }} \ + --repository-prefix "<%- repo %>/blob/<%- version %>/<%- commandPath %>" \ + || echo "::warning::'oclif readme' failed. Check the logs." + fi env: STEPS_NEXT_VERSION_TAG: ${{ steps.next-version.outputs.tag }} + INPUTS_PACKAGE_MANAGER: ${{ inputs.package-manager }} diff --git a/.github/workflows/create-github-release.yml b/.github/workflows/create-github-release.yml index e7d0395..637ed1f 100644 --- a/.github/workflows/create-github-release.yml +++ b/.github/workflows/create-github-release.yml @@ -22,6 +22,11 @@ on: type: boolean description: "Create a different markdown page for each topic." default: false + package-manager: + type: string + description: "Package manager to use (npm or yarn)" + default: "yarn" + required: false jobs: release: @@ -40,7 +45,7 @@ jobs: - uses: salesforcecli/github-workflows/.github/actions/getPreReleaseTag@main id: distTag - - name: Validate prerelease + - name: Fail if prerelease on main if: github.ref_name == 'main' && inputs.prerelease uses: actions/github-script@v7 with: @@ -75,6 +80,7 @@ jobs: pre-release: ${{ steps.prereleaseTag.outputs.tag && 'true' || 'false' }} pre-release-identifier: ${{ steps.prereleaseTag.outputs.tag }} multi: ${{ inputs.readme-multi }} + package-manager: ${{ inputs.package-manager }} - name: Conventional Changelog Action id: changelog From ef845d48e1b3d3f7a3888037a5f363c71a15ba70 Mon Sep 17 00:00:00 2001 From: "John-Mason P. Shackelford" Date: Thu, 13 Mar 2025 15:38:18 -0400 Subject: [PATCH 02/16] feat: add GitHub Packages publishing support --- .github/workflows/npmPublish.yml | 65 +++++++++++++++++++++++++++++--- 1 file changed, 59 insertions(+), 6 deletions(-) diff --git a/.github/workflows/npmPublish.yml b/.github/workflows/npmPublish.yml index 386b7a7..bb4c2a3 100644 --- a/.github/workflows/npmPublish.yml +++ b/.github/workflows/npmPublish.yml @@ -7,6 +7,9 @@ on: description: AWS access key id. Only required if sign = true AWS_SECRET_ACCESS_KEY: description: AWS secret access key. Only required if sign = true + SVC_CLI_BOT_GITHUB_TOKEN: + description: GitHub token for package publishing. Required if publishToGithubPackages is true + required: false inputs: tag: @@ -50,11 +53,28 @@ on: description: the github release tag that you want to publish as an npm package required: true type: string + package-manager: + type: string + description: "Package manager to use (npm or yarn)" + default: "yarn" + required: false + publishToGithubPackages: + type: boolean + description: "If true, publish to GitHub Packages instead of npm" + default: false + required: false + scope: + type: string + description: "Scope for the package (e.g., @organization). Required if publishToGithubPackages is true" + required: false jobs: check-publish: outputs: published: ${{ steps.is-published.outputs.published }} runs-on: ubuntu-latest + permissions: + contents: read + packages: read steps: - uses: actions/checkout@v4 with: @@ -63,11 +83,19 @@ jobs: - uses: actions/setup-node@v4 with: node-version: ${{ inputs.nodeVersion }} + registry-url: ${{ inputs.publishToGithubPackages && 'https://npm.pkg.github.com' || '' }} + scope: ${{ inputs.scope }} - name: Is published id: is-published run: | - RESPONSE=$(npm view .@$INPUTS_GITHUB_TAG version --json --silent || echo "Not published") + if [ "$INPUTS_PUBLISH_TO_GITHUB_PACKAGES" = "true" ]; then + # For GitHub Packages, check if the package exists in the registry + RESPONSE=$(npm view $INPUTS_SCOPE/$GITHUB_REPOSITORY_NAME@$INPUTS_GITHUB_TAG version --json --silent || echo "Not published") + else + # For npm, check if the package exists in the npm registry + RESPONSE=$(npm view .@$INPUTS_GITHUB_TAG version --json --silent || echo "Not published") + fi # The response is wrapped in double quotes, so we need to compare it with (escaped) quotes if [ "$RESPONSE" = "\"$INPUTS_GITHUB_TAG\"" ]; then @@ -77,7 +105,10 @@ jobs: fi env: INPUTS_GITHUB_TAG: ${{ inputs.githubTag }} - NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} + INPUTS_PUBLISH_TO_GITHUB_PACKAGES: ${{ inputs.publishToGithubPackages }} + INPUTS_SCOPE: ${{ inputs.scope }} + GITHUB_REPOSITORY_NAME: ${{ github.event.repository.name }} + NODE_AUTH_TOKEN: ${{ inputs.publishToGithubPackages && secrets.SVC_CLI_BOT_GITHUB_TOKEN || secrets.NPM_TOKEN }} - run: echo "[INFO] Is package published:\ $STEPS_IS_PUBLISHED_PUBLISHED" env: @@ -87,9 +118,10 @@ jobs: if: steps.is-published.outputs.published == 'true' uses: actions/github-script@v7 with: - script: core.setFailed(`The version '${process.env.INPUTS_GITHUB_TAG}' has already been published to npm`) + script: core.setFailed(`The version '${process.env.INPUTS_GITHUB_TAG}' has already been published to ${process.env.INPUTS_PUBLISH_TO_GITHUB_PACKAGES === 'true' ? 'GitHub Packages' : 'npm'}`) env: INPUTS_GITHUB_TAG: ${{ inputs.githubTag }} + INPUTS_PUBLISH_TO_GITHUB_PACKAGES: ${{ inputs.publishToGithubPackages }} ctc-open: needs: [check-publish] @@ -101,7 +133,20 @@ jobs: needs: [check-publish, ctc-open] if: ${{ always() && needs.check-publish.outputs.published == 'false' && (!inputs.ctc || (inputs.ctc && needs.ctc-open.outputs.changeCaseId)) }} runs-on: ${{ inputs.runsOn }} + permissions: + contents: read + packages: write steps: + - name: Validate inputs + if: inputs.publishToGithubPackages == 'true' + run: | + if [ -z "$INPUTS_SCOPE" ]; then + echo "Error: scope is required when publishing to GitHub Packages" + exit 1 + fi + env: + INPUTS_SCOPE: ${{ inputs.scope }} + - uses: actions/checkout@v4 with: ref: ${{ inputs.githubTag }} @@ -109,11 +154,19 @@ jobs: - uses: actions/setup-node@v4 with: node-version: ${{ inputs.nodeVersion }} - cache: yarn + cache: ${{ inputs.package-manager }} + registry-url: ${{ inputs.publishToGithubPackages && 'https://npm.pkg.github.com' || '' }} + scope: ${{ inputs.scope }} - uses: salesforcecli/github-workflows/.github/actions/yarnInstallWithRetries@main + if: inputs.package-manager == 'yarn' + + - name: npm install + if: inputs.package-manager == 'npm' + run: npm ci - - run: yarn build + - name: Build + run: ${{ inputs.package-manager }} build - run: npm install -g @salesforce/plugin-release-management @@ -129,7 +182,7 @@ jobs: env: INPUTS_GITHUB_TAG: ${{ inputs.githubTag }} INPUTS_TAG: ${{ inputs.tag }} - NPM_TOKEN: ${{secrets.NPM_TOKEN}} + NPM_TOKEN: ${{ inputs.publishToGithubPackages && secrets.SVC_CLI_BOT_GITHUB_TOKEN || secrets.NPM_TOKEN }} AWS_ACCESS_KEY_ID: ${{secrets.AWS_ACCESS_KEY_ID}} AWS_SECRET_ACCESS_KEY: ${{secrets.AWS_SECRET_ACCESS_KEY}} From 3bd04b8028b2672f3e634a0f00e946151cdcba0b Mon Sep 17 00:00:00 2001 From: "John-Mason P. Shackelford" Date: Thu, 13 Mar 2025 16:21:52 -0400 Subject: [PATCH 03/16] feat: Made the packages permission conditional: only requests write access when publishToGithubPackages is true --- .github/workflows/npmPublish.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/npmPublish.yml b/.github/workflows/npmPublish.yml index bb4c2a3..a2cf77d 100644 --- a/.github/workflows/npmPublish.yml +++ b/.github/workflows/npmPublish.yml @@ -135,7 +135,7 @@ jobs: runs-on: ${{ inputs.runsOn }} permissions: contents: read - packages: write + packages: ${{ inputs.publishToGithubPackages && 'write' || 'none' }} steps: - name: Validate inputs if: inputs.publishToGithubPackages == 'true' From d9f93634e41fa06f372d4df4d81d87a5d9d6eab3 Mon Sep 17 00:00:00 2001 From: "John-Mason P. Shackelford" Date: Thu, 13 Mar 2025 18:32:25 -0400 Subject: [PATCH 04/16] chore: fixed a syntax error in the npmPublish.yml --- .github/workflows/npmPublish.yml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.github/workflows/npmPublish.yml b/.github/workflows/npmPublish.yml index a2cf77d..f55ed2e 100644 --- a/.github/workflows/npmPublish.yml +++ b/.github/workflows/npmPublish.yml @@ -118,7 +118,10 @@ jobs: if: steps.is-published.outputs.published == 'true' uses: actions/github-script@v7 with: - script: core.setFailed(`The version '${process.env.INPUTS_GITHUB_TAG}' has already been published to ${process.env.INPUTS_PUBLISH_TO_GITHUB_PACKAGES === 'true' ? 'GitHub Packages' : 'npm'}`) + script: | + const message = 'The version \'' + process.env.INPUTS_GITHUB_TAG + '\' has already been published to ' + + (process.env.INPUTS_PUBLISH_TO_GITHUB_PACKAGES === 'true' ? 'GitHub Packages' : 'npm'); + core.setFailed(message); env: INPUTS_GITHUB_TAG: ${{ inputs.githubTag }} INPUTS_PUBLISH_TO_GITHUB_PACKAGES: ${{ inputs.publishToGithubPackages }} From 5389cd71091cdd9c7d9a04952b8cec470e832f82 Mon Sep 17 00:00:00 2001 From: "John-Mason P. Shackelford" Date: Thu, 13 Mar 2025 19:01:59 -0400 Subject: [PATCH 05/16] chore: fix a syntexa error in github workflow --- .github/workflows/npmPublish.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/npmPublish.yml b/.github/workflows/npmPublish.yml index f55ed2e..1e9fdc2 100644 --- a/.github/workflows/npmPublish.yml +++ b/.github/workflows/npmPublish.yml @@ -138,7 +138,7 @@ jobs: runs-on: ${{ inputs.runsOn }} permissions: contents: read - packages: ${{ inputs.publishToGithubPackages && 'write' || 'none' }} + packages: ${{ if(inputs.publishToGithubPackages, 'write', 'none') }} steps: - name: Validate inputs if: inputs.publishToGithubPackages == 'true' From 15eb422cc642d7b14a9d94e490930ed2cb0ce296 Mon Sep 17 00:00:00 2001 From: "John-Mason P. Shackelford" Date: Thu, 13 Mar 2025 19:18:27 -0400 Subject: [PATCH 06/16] chore: correcting, the previous fix was wrong --- .github/workflows/npmPublish.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/npmPublish.yml b/.github/workflows/npmPublish.yml index 1e9fdc2..b97a347 100644 --- a/.github/workflows/npmPublish.yml +++ b/.github/workflows/npmPublish.yml @@ -138,7 +138,7 @@ jobs: runs-on: ${{ inputs.runsOn }} permissions: contents: read - packages: ${{ if(inputs.publishToGithubPackages, 'write', 'none') }} + packages: ${{ inputs.publishToGithubPackages == true && 'write' || 'none' }} steps: - name: Validate inputs if: inputs.publishToGithubPackages == 'true' From 2a7626d7cf610aad79caa1ee67145850040c75cd Mon Sep 17 00:00:00 2001 From: "John-Mason P. Shackelford" Date: Thu, 13 Mar 2025 19:20:20 -0400 Subject: [PATCH 07/16] chore: correcting, the previous fix was wrong --- .github/workflows/npmPublish.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/npmPublish.yml b/.github/workflows/npmPublish.yml index b97a347..f55ed2e 100644 --- a/.github/workflows/npmPublish.yml +++ b/.github/workflows/npmPublish.yml @@ -138,7 +138,7 @@ jobs: runs-on: ${{ inputs.runsOn }} permissions: contents: read - packages: ${{ inputs.publishToGithubPackages == true && 'write' || 'none' }} + packages: ${{ inputs.publishToGithubPackages && 'write' || 'none' }} steps: - name: Validate inputs if: inputs.publishToGithubPackages == 'true' From a5e872d2769a899b125276390522bbba9ec16ce2 Mon Sep 17 00:00:00 2001 From: "John-Mason P. Shackelford" Date: Thu, 13 Mar 2025 19:24:06 -0400 Subject: [PATCH 08/16] chore: correcting, the previous fix was wrong --- .github/workflows/npmPublish.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/npmPublish.yml b/.github/workflows/npmPublish.yml index f55ed2e..c477e08 100644 --- a/.github/workflows/npmPublish.yml +++ b/.github/workflows/npmPublish.yml @@ -138,7 +138,7 @@ jobs: runs-on: ${{ inputs.runsOn }} permissions: contents: read - packages: ${{ inputs.publishToGithubPackages && 'write' || 'none' }} + packages: write steps: - name: Validate inputs if: inputs.publishToGithubPackages == 'true' From e74fb7779d6b7aa26904f42e3da3b16925a12261 Mon Sep 17 00:00:00 2001 From: "John-Mason P. Shackelford" Date: Thu, 13 Mar 2025 20:09:11 -0400 Subject: [PATCH 09/16] parameter the repo and ref for workflow calls otherwise the calls do not follow the fork --- .github/workflows/create-github-release.yml | 16 ++++++++++--- .github/workflows/ctcClose.yml | 10 +++++++++ .github/workflows/ctcOpen.yml | 11 +++++++++ .github/workflows/npmPublish.yml | 25 +++++++++++++++++---- 4 files changed, 55 insertions(+), 7 deletions(-) diff --git a/.github/workflows/create-github-release.yml b/.github/workflows/create-github-release.yml index 637ed1f..ddccec2 100644 --- a/.github/workflows/create-github-release.yml +++ b/.github/workflows/create-github-release.yml @@ -27,6 +27,16 @@ on: description: "Package manager to use (npm or yarn)" default: "yarn" required: false + actions-repository: + type: string + description: "The repository owner/name to use for actions (format: owner/repo)" + default: "salesforcecli/github-workflows" + required: false + actions-ref: + type: string + description: "The branch, tag or SHA to use for actions" + default: "main" + required: false jobs: release: @@ -34,7 +44,7 @@ jobs: steps: - name: Get Github user info id: github-user-info - uses: salesforcecli/github-workflows/.github/actions/getGithubUserInfo@main + uses: ${{ inputs.actions-repository }}/.github/actions/getGithubUserInfo@${{ inputs.actions-ref }} with: SVC_CLI_BOT_GITHUB_TOKEN: ${{ secrets.SVC_CLI_BOT_GITHUB_TOKEN }} @@ -42,7 +52,7 @@ jobs: with: token: ${{ secrets.SVC_CLI_BOT_GITHUB_TOKEN }} - - uses: salesforcecli/github-workflows/.github/actions/getPreReleaseTag@main + - uses: ${{ inputs.actions-repository }}/.github/actions/getPreReleaseTag@${{ inputs.actions-ref }} id: distTag - name: Fail if prerelease on main @@ -74,7 +84,7 @@ jobs: - name: Generate oclif readme if: ${{ inputs.generate-readme }} - uses: salesforcecli/github-workflows/.github/actions/generateOclifReadme@main + uses: ${{ inputs.actions-repository }}/.github/actions/generateOclifReadme@${{ inputs.actions-ref }} with: skip-on-empty: ${{ inputs.skip-on-empty }} pre-release: ${{ steps.prereleaseTag.outputs.tag && 'true' || 'false' }} diff --git a/.github/workflows/ctcClose.yml b/.github/workflows/ctcClose.yml index 871ca33..3b63ecf 100644 --- a/.github/workflows/ctcClose.yml +++ b/.github/workflows/ctcClose.yml @@ -10,6 +10,16 @@ on: description: CTC status, like "Implemented - per plan", "Not Implemented" default: Implemented - per plan type: string + actions-repository: + type: string + description: "The repository owner/name to use for actions (format: owner/repo)" + default: "salesforcecli/github-workflows" + required: false + actions-ref: + type: string + description: "The branch, tag or SHA to use for actions" + default: "main" + required: false jobs: ctcClose: diff --git a/.github/workflows/ctcOpen.yml b/.github/workflows/ctcOpen.yml index b03c218..95334ba 100644 --- a/.github/workflows/ctcOpen.yml +++ b/.github/workflows/ctcOpen.yml @@ -4,6 +4,17 @@ on: changeCaseId: description: Id for the change case created value: ${{ jobs.ctcOpen.outputs.changeCaseId }} + inputs: + actions-repository: + type: string + description: "The repository owner/name to use for actions (format: owner/repo)" + default: "salesforcecli/github-workflows" + required: false + actions-ref: + type: string + description: "The branch, tag or SHA to use for actions" + default: "main" + required: false jobs: ctcOpen: diff --git a/.github/workflows/npmPublish.yml b/.github/workflows/npmPublish.yml index c477e08..f1e8246 100644 --- a/.github/workflows/npmPublish.yml +++ b/.github/workflows/npmPublish.yml @@ -67,6 +67,16 @@ on: type: string description: "Scope for the package (e.g., @organization). Required if publishToGithubPackages is true" required: false + actions-repository: + type: string + description: "The repository owner/name to use for actions (format: owner/repo)" + default: "salesforcecli/github-workflows" + required: false + actions-ref: + type: string + description: "The branch, tag or SHA to use for actions" + default: "main" + required: false jobs: check-publish: outputs: @@ -129,8 +139,11 @@ jobs: ctc-open: needs: [check-publish] if: inputs.ctc && needs.check-publish.outputs.published == 'false' - uses: salesforcecli/github-workflows/.github/workflows/ctcOpen.yml@main + uses: ${{ inputs.actions-repository }}/.github/workflows/ctcOpen.yml@${{ inputs.actions-ref }} secrets: inherit + with: + actions-repository: ${{ inputs.actions-repository }} + actions-ref: ${{ inputs.actions-ref }} npm-publish: needs: [check-publish, ctc-open] @@ -161,7 +174,7 @@ jobs: registry-url: ${{ inputs.publishToGithubPackages && 'https://npm.pkg.github.com' || '' }} scope: ${{ inputs.scope }} - - uses: salesforcecli/github-workflows/.github/actions/yarnInstallWithRetries@main + - uses: ${{ inputs.actions-repository }}/.github/actions/yarnInstallWithRetries@${{ inputs.actions-ref }} if: inputs.package-manager == 'yarn' - name: npm install @@ -192,16 +205,20 @@ jobs: ctcCloseSuccess: needs: [ctc-open, npm-publish] if: needs.ctc-open.result == 'success' && needs.npm-publish.result == 'success' && needs.ctc-open.outputs.changeCaseId - uses: salesforcecli/github-workflows/.github/workflows/ctcClose.yml@main + uses: ${{ inputs.actions-repository }}/.github/workflows/ctcClose.yml@${{ inputs.actions-ref }} secrets: inherit with: changeCaseId: ${{needs.ctc-open.outputs.changeCaseId}} + actions-repository: ${{ inputs.actions-repository }} + actions-ref: ${{ inputs.actions-ref }} ctcCloseFail: needs: [ctc-open, npm-publish] if: always() && inputs.ctc && needs.ctc-open.outputs.changeCaseId && (needs.ctc-open.result != 'success' || needs.npm-publish.result != 'success') - uses: salesforcecli/github-workflows/.github/workflows/ctcClose.yml@main + uses: ${{ inputs.actions-repository }}/.github/workflows/ctcClose.yml@${{ inputs.actions-ref }} secrets: inherit with: changeCaseId: ${{ needs.ctc-open.outputs.changeCaseId }} status: Not Implemented + actions-repository: ${{ inputs.actions-repository }} + actions-ref: ${{ inputs.actions-ref }} From 14c9d67bf4c97928953243a225a10528cd092028 Mon Sep 17 00:00:00 2001 From: "John-Mason P. Shackelford" Date: Thu, 13 Mar 2025 20:42:01 -0400 Subject: [PATCH 10/16] chore: passing parameters as part of version ref is not supported by GitHub, hardcoding main as before --- .github/workflows/create-github-release.yml | 11 +++-------- .github/workflows/ctcClose.yml | 10 ---------- .github/workflows/ctcOpen.yml | 11 ----------- .github/workflows/npmPublish.yml | 20 ++++---------------- 4 files changed, 7 insertions(+), 45 deletions(-) diff --git a/.github/workflows/create-github-release.yml b/.github/workflows/create-github-release.yml index ddccec2..4d57f74 100644 --- a/.github/workflows/create-github-release.yml +++ b/.github/workflows/create-github-release.yml @@ -32,11 +32,6 @@ on: description: "The repository owner/name to use for actions (format: owner/repo)" default: "salesforcecli/github-workflows" required: false - actions-ref: - type: string - description: "The branch, tag or SHA to use for actions" - default: "main" - required: false jobs: release: @@ -44,7 +39,7 @@ jobs: steps: - name: Get Github user info id: github-user-info - uses: ${{ inputs.actions-repository }}/.github/actions/getGithubUserInfo@${{ inputs.actions-ref }} + uses: ${{ inputs.actions-repository }}/.github/actions/getGithubUserInfo@main with: SVC_CLI_BOT_GITHUB_TOKEN: ${{ secrets.SVC_CLI_BOT_GITHUB_TOKEN }} @@ -52,7 +47,7 @@ jobs: with: token: ${{ secrets.SVC_CLI_BOT_GITHUB_TOKEN }} - - uses: ${{ inputs.actions-repository }}/.github/actions/getPreReleaseTag@${{ inputs.actions-ref }} + - uses: ${{ inputs.actions-repository }}/.github/actions/getPreReleaseTag@main id: distTag - name: Fail if prerelease on main @@ -84,7 +79,7 @@ jobs: - name: Generate oclif readme if: ${{ inputs.generate-readme }} - uses: ${{ inputs.actions-repository }}/.github/actions/generateOclifReadme@${{ inputs.actions-ref }} + uses: ${{ inputs.actions-repository }}/.github/actions/generateOclifReadme@main with: skip-on-empty: ${{ inputs.skip-on-empty }} pre-release: ${{ steps.prereleaseTag.outputs.tag && 'true' || 'false' }} diff --git a/.github/workflows/ctcClose.yml b/.github/workflows/ctcClose.yml index 3b63ecf..871ca33 100644 --- a/.github/workflows/ctcClose.yml +++ b/.github/workflows/ctcClose.yml @@ -10,16 +10,6 @@ on: description: CTC status, like "Implemented - per plan", "Not Implemented" default: Implemented - per plan type: string - actions-repository: - type: string - description: "The repository owner/name to use for actions (format: owner/repo)" - default: "salesforcecli/github-workflows" - required: false - actions-ref: - type: string - description: "The branch, tag or SHA to use for actions" - default: "main" - required: false jobs: ctcClose: diff --git a/.github/workflows/ctcOpen.yml b/.github/workflows/ctcOpen.yml index 95334ba..b03c218 100644 --- a/.github/workflows/ctcOpen.yml +++ b/.github/workflows/ctcOpen.yml @@ -4,17 +4,6 @@ on: changeCaseId: description: Id for the change case created value: ${{ jobs.ctcOpen.outputs.changeCaseId }} - inputs: - actions-repository: - type: string - description: "The repository owner/name to use for actions (format: owner/repo)" - default: "salesforcecli/github-workflows" - required: false - actions-ref: - type: string - description: "The branch, tag or SHA to use for actions" - default: "main" - required: false jobs: ctcOpen: diff --git a/.github/workflows/npmPublish.yml b/.github/workflows/npmPublish.yml index f1e8246..fe0c967 100644 --- a/.github/workflows/npmPublish.yml +++ b/.github/workflows/npmPublish.yml @@ -72,11 +72,6 @@ on: description: "The repository owner/name to use for actions (format: owner/repo)" default: "salesforcecli/github-workflows" required: false - actions-ref: - type: string - description: "The branch, tag or SHA to use for actions" - default: "main" - required: false jobs: check-publish: outputs: @@ -139,11 +134,8 @@ jobs: ctc-open: needs: [check-publish] if: inputs.ctc && needs.check-publish.outputs.published == 'false' - uses: ${{ inputs.actions-repository }}/.github/workflows/ctcOpen.yml@${{ inputs.actions-ref }} + uses: llmzy/salesforcecli-github-workflows/.github/workflows/ctcOpen.yml@jps/npm-not-yarn secrets: inherit - with: - actions-repository: ${{ inputs.actions-repository }} - actions-ref: ${{ inputs.actions-ref }} npm-publish: needs: [check-publish, ctc-open] @@ -174,7 +166,7 @@ jobs: registry-url: ${{ inputs.publishToGithubPackages && 'https://npm.pkg.github.com' || '' }} scope: ${{ inputs.scope }} - - uses: ${{ inputs.actions-repository }}/.github/actions/yarnInstallWithRetries@${{ inputs.actions-ref }} + - uses: ${{ inputs.actions-repository }}/.github/actions/yarnInstallWithRetries@main if: inputs.package-manager == 'yarn' - name: npm install @@ -205,20 +197,16 @@ jobs: ctcCloseSuccess: needs: [ctc-open, npm-publish] if: needs.ctc-open.result == 'success' && needs.npm-publish.result == 'success' && needs.ctc-open.outputs.changeCaseId - uses: ${{ inputs.actions-repository }}/.github/workflows/ctcClose.yml@${{ inputs.actions-ref }} + uses: llmzy/salesforcecli-github-workflows/.github/workflows/ctcClose.yml@jps/npm-not-yarn secrets: inherit with: changeCaseId: ${{needs.ctc-open.outputs.changeCaseId}} - actions-repository: ${{ inputs.actions-repository }} - actions-ref: ${{ inputs.actions-ref }} ctcCloseFail: needs: [ctc-open, npm-publish] if: always() && inputs.ctc && needs.ctc-open.outputs.changeCaseId && (needs.ctc-open.result != 'success' || needs.npm-publish.result != 'success') - uses: ${{ inputs.actions-repository }}/.github/workflows/ctcClose.yml@${{ inputs.actions-ref }} + uses: llmzy/salesforcecli-github-workflows/.github/workflows/ctcClose.yml@jps/npm-not-yarn secrets: inherit with: changeCaseId: ${{ needs.ctc-open.outputs.changeCaseId }} status: Not Implemented - actions-repository: ${{ inputs.actions-repository }} - actions-ref: ${{ inputs.actions-ref }} From e3ca6a864a866b204324b22ff7a1d7f98f39e241 Mon Sep 17 00:00:00 2001 From: "John-Mason P. Shackelford" Date: Thu, 13 Mar 2025 20:57:42 -0400 Subject: [PATCH 11/16] chore: github doesn't allow dynamic uses --- .github/workflows/create-github-release.yml | 11 +++-------- .github/workflows/npmPublish.yml | 7 +------ 2 files changed, 4 insertions(+), 14 deletions(-) diff --git a/.github/workflows/create-github-release.yml b/.github/workflows/create-github-release.yml index 4d57f74..5ab2146 100644 --- a/.github/workflows/create-github-release.yml +++ b/.github/workflows/create-github-release.yml @@ -27,11 +27,6 @@ on: description: "Package manager to use (npm or yarn)" default: "yarn" required: false - actions-repository: - type: string - description: "The repository owner/name to use for actions (format: owner/repo)" - default: "salesforcecli/github-workflows" - required: false jobs: release: @@ -39,7 +34,7 @@ jobs: steps: - name: Get Github user info id: github-user-info - uses: ${{ inputs.actions-repository }}/.github/actions/getGithubUserInfo@main + uses: llmzy/salesforcecli-github-workflows/.github/actions/getGithubUserInfo@jps/npm-not-yarn with: SVC_CLI_BOT_GITHUB_TOKEN: ${{ secrets.SVC_CLI_BOT_GITHUB_TOKEN }} @@ -47,7 +42,7 @@ jobs: with: token: ${{ secrets.SVC_CLI_BOT_GITHUB_TOKEN }} - - uses: ${{ inputs.actions-repository }}/.github/actions/getPreReleaseTag@main + - uses: llmzy/salesforcecli-github-workflows/.github/actions/getPreReleaseTag@jps/npm-not-yarn id: distTag - name: Fail if prerelease on main @@ -79,7 +74,7 @@ jobs: - name: Generate oclif readme if: ${{ inputs.generate-readme }} - uses: ${{ inputs.actions-repository }}/.github/actions/generateOclifReadme@main + uses: llmzy/salesforcecli-github-workflows/.github/actions/generateOclifReadme@jps/npm-not-yarn with: skip-on-empty: ${{ inputs.skip-on-empty }} pre-release: ${{ steps.prereleaseTag.outputs.tag && 'true' || 'false' }} diff --git a/.github/workflows/npmPublish.yml b/.github/workflows/npmPublish.yml index fe0c967..e0bb281 100644 --- a/.github/workflows/npmPublish.yml +++ b/.github/workflows/npmPublish.yml @@ -67,11 +67,6 @@ on: type: string description: "Scope for the package (e.g., @organization). Required if publishToGithubPackages is true" required: false - actions-repository: - type: string - description: "The repository owner/name to use for actions (format: owner/repo)" - default: "salesforcecli/github-workflows" - required: false jobs: check-publish: outputs: @@ -166,7 +161,7 @@ jobs: registry-url: ${{ inputs.publishToGithubPackages && 'https://npm.pkg.github.com' || '' }} scope: ${{ inputs.scope }} - - uses: ${{ inputs.actions-repository }}/.github/actions/yarnInstallWithRetries@main + - uses: llmzy/salesforcecli-github-workflows/.github/actions/yarnInstallWithRetries@jps/npm-not-yarn if: inputs.package-manager == 'yarn' - name: npm install From 194ec8adafdcc38b709f278b867e2997507ed20c Mon Sep 17 00:00:00 2001 From: "John-Mason P. Shackelford" Date: Fri, 14 Mar 2025 07:57:45 -0400 Subject: [PATCH 12/16] chore: fixed npm build to correctly invoke tsc --- .github/actions/generateOclifReadme/action.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/actions/generateOclifReadme/action.yml b/.github/actions/generateOclifReadme/action.yml index 7258a68..cd9270a 100644 --- a/.github/actions/generateOclifReadme/action.yml +++ b/.github/actions/generateOclifReadme/action.yml @@ -47,8 +47,8 @@ runs: shell: bash run: | if [ "$INPUTS_PACKAGE_MANAGER" = "npm" ]; then - npm install - npm run tsc + npm ci + npx tsc -b --verbose npm run oclif readme \ --no-aliases \ --version "$STEPS_NEXT_VERSION_TAG" \ From 37307e5a4cc82914d0726d1e012df19ccb229ff3 Mon Sep 17 00:00:00 2001 From: "John-Mason P. Shackelford" Date: Fri, 14 Mar 2025 08:14:08 -0400 Subject: [PATCH 13/16] chore: fixed build step in npmPublish.yml --- .github/workflows/npmPublish.yml | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/.github/workflows/npmPublish.yml b/.github/workflows/npmPublish.yml index e0bb281..a13fcb6 100644 --- a/.github/workflows/npmPublish.yml +++ b/.github/workflows/npmPublish.yml @@ -168,8 +168,13 @@ jobs: if: inputs.package-manager == 'npm' run: npm ci - - name: Build - run: ${{ inputs.package-manager }} build + - name: Build with yarn + if: inputs.package-manager == 'yarn' + run: yarn build + + - name: Build with npm + if: inputs.package-manager == 'npm' + run: npm run build - run: npm install -g @salesforce/plugin-release-management From c58f96834336d8906d55566bc8489f6578b9af6c Mon Sep 17 00:00:00 2001 From: "John-Mason P. Shackelford" Date: Fri, 14 Mar 2025 08:49:33 -0400 Subject: [PATCH 14/16] chore: setup .npmrc with auth token for publish --- .github/workflows/npmPublish.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/npmPublish.yml b/.github/workflows/npmPublish.yml index a13fcb6..5945f1a 100644 --- a/.github/workflows/npmPublish.yml +++ b/.github/workflows/npmPublish.yml @@ -155,6 +155,8 @@ jobs: ref: ${{ inputs.githubTag }} - uses: actions/setup-node@v4 + env: + NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }} with: node-version: ${{ inputs.nodeVersion }} cache: ${{ inputs.package-manager }} From 76af45c8a6f15a14d1dcc68fe950c5363996dee6 Mon Sep 17 00:00:00 2001 From: "John-Mason P. Shackelford" Date: Sat, 15 Mar 2025 18:37:39 -0400 Subject: [PATCH 15/16] added an extra check in check-publish to be sure that we have a good github tag to work with and bail if we don't --- .github/workflows/npmPublish.yml | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/.github/workflows/npmPublish.yml b/.github/workflows/npmPublish.yml index 5945f1a..9d62b97 100644 --- a/.github/workflows/npmPublish.yml +++ b/.github/workflows/npmPublish.yml @@ -76,6 +76,13 @@ jobs: contents: read packages: read steps: + - name: Validate GitHub Tag + if: inputs.githubTag == '' + run: | + echo "Error: No GitHub tag provided. This usually happens when the release step was skipped due to empty changelog." + echo "No changes to publish - workflow completed successfully." + exit 0 # Exit with success to indicate this is expected behavior + - uses: actions/checkout@v4 with: ref: ${{ inputs.githubTag }} From 5d544d7247153bc01ab2dd771bb7168a2375bd15 Mon Sep 17 00:00:00 2001 From: "John-Mason P. Shackelford" Date: Sat, 15 Mar 2025 19:02:02 -0400 Subject: [PATCH 16/16] check-publish now will not run and allow the npm-publish step to proceed if we don't have a github tag --- .github/workflows/npmPublish.yml | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/.github/workflows/npmPublish.yml b/.github/workflows/npmPublish.yml index 9d62b97..b7b7cde 100644 --- a/.github/workflows/npmPublish.yml +++ b/.github/workflows/npmPublish.yml @@ -69,6 +69,7 @@ on: required: false jobs: check-publish: + if: inputs.githubTag != '' outputs: published: ${{ steps.is-published.outputs.published }} runs-on: ubuntu-latest @@ -76,13 +77,6 @@ jobs: contents: read packages: read steps: - - name: Validate GitHub Tag - if: inputs.githubTag == '' - run: | - echo "Error: No GitHub tag provided. This usually happens when the release step was skipped due to empty changelog." - echo "No changes to publish - workflow completed successfully." - exit 0 # Exit with success to indicate this is expected behavior - - uses: actions/checkout@v4 with: ref: ${{ inputs.githubTag }}