Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
16 commits
Select commit Hold shift + click to select a range
509c1d8
feat: support npm for oclif readme generation
jpshack-at-palomar Mar 13, 2025
ef845d4
feat: add GitHub Packages publishing support
jpshack-at-palomar Mar 13, 2025
3bd04b8
feat: Made the packages permission conditional: only requests write a…
jpshack-at-palomar Mar 13, 2025
d9f9363
chore: fixed a syntax error in the npmPublish.yml
jpshack-at-palomar Mar 13, 2025
5389cd7
chore: fix a syntexa error in github workflow
jpshack-at-palomar Mar 13, 2025
15eb422
chore: correcting, the previous fix was wrong
jpshack-at-palomar Mar 13, 2025
2a7626d
chore: correcting, the previous fix was wrong
jpshack-at-palomar Mar 13, 2025
a5e872d
chore: correcting, the previous fix was wrong
jpshack-at-palomar Mar 13, 2025
e74fb77
parameter the repo and ref for workflow calls otherwise the calls do …
jpshack-at-palomar Mar 14, 2025
14c9d67
chore: passing parameters as part of version ref is not supported by …
jpshack-at-palomar Mar 14, 2025
e3ca6a8
chore: github doesn't allow dynamic uses
jpshack-at-palomar Mar 14, 2025
194ec8a
chore: fixed npm build to correctly invoke tsc
jpshack-at-palomar Mar 14, 2025
37307e5
chore: fixed build step in npmPublish.yml
jpshack-at-palomar Mar 14, 2025
c58f968
chore: setup .npmrc with auth token for publish
jpshack-at-palomar Mar 14, 2025
76af45c
added an extra check in check-publish to be sure that we have a good …
jpshack-at-palomar Mar 15, 2025
5d544d7
check-publish now will not run and allow the npm-publish step to proc…
jpshack-at-palomar Mar 15, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 24 additions & 8 deletions .github/actions/generateOclifReadme/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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 ci
npx tsc -b --verbose
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 }}
14 changes: 10 additions & 4 deletions .github/workflows/create-github-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,25 +22,30 @@ 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:
runs-on: ubuntu-latest
steps:
- name: Get Github user info
id: github-user-info
uses: salesforcecli/github-workflows/.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 }}

- uses: actions/checkout@v4
with:
token: ${{ secrets.SVC_CLI_BOT_GITHUB_TOKEN }}

- uses: salesforcecli/github-workflows/.github/actions/getPreReleaseTag@main
- uses: llmzy/salesforcecli-github-workflows/.github/actions/getPreReleaseTag@jps/npm-not-yarn
id: distTag

- name: Validate prerelease
- name: Fail if prerelease on main
if: github.ref_name == 'main' && inputs.prerelease
uses: actions/github-script@v7
with:
Expand Down Expand Up @@ -69,12 +74,13 @@ jobs:

- name: Generate oclif readme
if: ${{ inputs.generate-readme }}
uses: salesforcecli/github-workflows/.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' }}
pre-release-identifier: ${{ steps.prereleaseTag.outputs.tag }}
multi: ${{ inputs.readme-multi }}
package-manager: ${{ inputs.package-manager }}

- name: Conventional Changelog Action
id: changelog
Expand Down
84 changes: 74 additions & 10 deletions .github/workflows/npmPublish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -50,11 +53,29 @@ 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:
if: inputs.githubTag != ''
outputs:
published: ${{ steps.is-published.outputs.published }}
runs-on: ubuntu-latest
permissions:
contents: read
packages: read
steps:
- uses: actions/checkout@v4
with:
Expand All @@ -63,11 +84,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
Expand All @@ -77,7 +106,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:
Expand All @@ -87,33 +119,65 @@ 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: |
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 }}

ctc-open:
needs: [check-publish]
if: inputs.ctc && needs.check-publish.outputs.published == 'false'
uses: salesforcecli/github-workflows/.github/workflows/ctcOpen.yml@main
uses: llmzy/salesforcecli-github-workflows/.github/workflows/ctcOpen.yml@jps/npm-not-yarn
secrets: inherit

npm-publish:
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 }}

- uses: actions/setup-node@v4
env:
NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
node-version: ${{ inputs.nodeVersion }}
cache: yarn
cache: ${{ inputs.package-manager }}
registry-url: ${{ inputs.publishToGithubPackages && 'https://npm.pkg.github.com' || '' }}
scope: ${{ inputs.scope }}

- uses: llmzy/salesforcecli-github-workflows/.github/actions/yarnInstallWithRetries@jps/npm-not-yarn
if: inputs.package-manager == 'yarn'

- name: npm install
if: inputs.package-manager == 'npm'
run: npm ci

- uses: salesforcecli/github-workflows/.github/actions/yarnInstallWithRetries@main
- name: Build with yarn
if: inputs.package-manager == 'yarn'
run: yarn build

- run: yarn build
- name: Build with npm
if: inputs.package-manager == 'npm'
run: npm run build

- run: npm install -g @salesforce/plugin-release-management

Expand All @@ -129,22 +193,22 @@ 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}}

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: llmzy/salesforcecli-github-workflows/.github/workflows/ctcClose.yml@jps/npm-not-yarn
secrets: inherit
with:
changeCaseId: ${{needs.ctc-open.outputs.changeCaseId}}

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: llmzy/salesforcecli-github-workflows/.github/workflows/ctcClose.yml@jps/npm-not-yarn
secrets: inherit
with:
changeCaseId: ${{ needs.ctc-open.outputs.changeCaseId }}
Expand Down