2626 - minor
2727 - major
2828
29+ workflow_call :
30+ inputs :
31+ package :
32+ description : " The package to publish (must be one of: express-boilerplate, integration-boilerplate-node, logger, mint-components, program-boilerplate, program-test-suite, publish-helper)"
33+ required : true
34+ type : string
35+ npm-tag :
36+ description : The npm dist-tag to publish with
37+ required : false
38+ type : string
39+ default : latest
40+
2941jobs :
3042 publish :
3143 runs-on : ubuntu-latest
@@ -34,22 +46,38 @@ jobs:
3446 contents : write
3547 id-token : write
3648
49+ env :
50+ VERSIONING : ${{ github.event_name == 'workflow_dispatch' }}
51+
3752 steps :
3853 - name : Enforce mint-components prerelease-only policy
39- if : inputs.package == 'mint-components' && inputs.increment-type != 'prerelease'
54+ if : github.event_name == 'workflow_dispatch' && inputs.package == 'mint-components' && inputs.increment-type != 'prerelease'
4055 run : |
4156 echo "::error::Stable releases of @saasquatch/mint-components must go through the 'Mint Components Release' workflow (Changesets). This workflow only supports 'prerelease' for mint-components."
4257 exit 1
4358
59+ - name : Validate package input
60+ env :
61+ PACKAGE : ${{ inputs.package }}
62+ run : |
63+ case "$PACKAGE" in
64+ express-boilerplate|integration-boilerplate-node|logger|mint-components|program-boilerplate|program-test-suite|publish-helper) ;;
65+ *) echo "::error::Invalid package '${PACKAGE}'."; exit 1 ;;
66+ esac
67+
4468 - name : Generate Variables
4569 id : vars
70+ env :
71+ PACKAGE : ${{ inputs.package }}
72+ NPM_TAG : ${{ inputs.npm-tag || (inputs.increment-type == 'prerelease' && 'next') || 'latest' }}
4673 run : |
47- echo "dir=packages/${{ inputs.package }}" >> ${GITHUB_OUTPUT}
48- if [ "${{ inputs.increment-type }}" = "prerelease" ]; then
49- echo "npmtag=next" >> ${GITHUB_OUTPUT}
50- else
51- echo "npmtag=latest" >> ${GITHUB_OUTPUT}
74+ # Validate npm-tag is a safe dist-tag value (alphanumeric, hyphens, dots)
75+ if [[ ! "$NPM_TAG" =~ ^[a-zA-Z0-9._-]+$ ]]; then
76+ echo "::error::Invalid npm-tag '${NPM_TAG}'. Must be alphanumeric with hyphens/dots only."
77+ exit 1
5278 fi
79+ echo "dir=packages/${PACKAGE}" >> ${GITHUB_OUTPUT}
80+ echo "npmtag=${NPM_TAG}" >> ${GITHUB_OUTPUT}
5381
5482 - name : Checkout
5583 id : checkout
@@ -65,16 +93,18 @@ jobs:
6593 # we could add this to devDependencies but we'd have to do it for every package
6694 # so might as well just install it inside the action
6795 - name : Install semver
96+ if : env.VERSIONING == 'true'
6897 id : npm-i-semver
6998 run : |
70- npm i --no-save semver
99+ npm i --no-save semver@7.8.0
71100
72101 - name : Install dependencies
73102 id : npm-ci
74103 working-directory : ${{ steps.vars.outputs.dir }}
75104 run : npm ci
76105
77106 - name : Compute new version
107+ if : env.VERSIONING == 'true'
78108 id : compute-version
79109 uses : actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # ed597 = v8
80110 with :
@@ -115,6 +145,7 @@ jobs:
115145 return newVersion;
116146
117147 - name : Extract package name
148+ if : env.VERSIONING == 'true'
118149 id : extract-package-name
119150 uses : actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # ed597 = v8
120151 with :
@@ -135,6 +166,7 @@ jobs:
135166 return packageName;
136167
137168 - name : Write new version to file
169+ if : env.VERSIONING == 'true'
138170 working-directory : ${{ steps.vars.outputs.dir }}
139171 run : |
140172 jq '.version = "${{ steps.compute-version.outputs.result }}"' package.json > package.json.tmp
@@ -151,6 +183,7 @@ jobs:
151183 run : npm publish --provenance --access public --tag ${{ steps.vars.outputs.npmtag }}
152184
153185 - name : Commit and push changes
186+ if : env.VERSIONING == 'true'
154187 id : commit-and-push
155188 uses : saasquatch/git-commit-action@v0.0.15
156189 env :
0 commit comments