-
Notifications
You must be signed in to change notification settings - Fork 4
Add publish npm package workflow #43
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
|
|
||
| on: | ||
| workflow_run: | ||
| workflows: ["Main"] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
runs only if Main workflow completed
|
|
||
| jobs: | ||
| publish: | ||
| if: ${{ github.event.workflow_run.conclusion == 'success' }} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
runs only on succesful completion of main.yml
.github/workflows/publish.yml
Outdated
| - run: bun install | ||
| - name : update changelog | ||
| id: update-changelog | ||
| run: bun run update-changelog |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
run update changelog script and use exit code 0 or 1 to know how to proceed next
.github/workflows/publish.yml
Outdated
| - name : update changelog | ||
| id: update-changelog | ||
| run: bun run update-changelog | ||
| continue-on-error: true |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
continue on error as i will use exit code
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't like this, I prefer not to do anything versus checking error code of previous github action steps.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
adjusted, now the publish is much simplified i think
| run: | | ||
| git config --local user.name "github-actions" | ||
| git config --local user.email "[email protected]" | ||
| git push origin main --tags No newline at end of file |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
then push origin main as a new commit and git tagging was prev made by npm version x command
| if (version === packageVersion) { | ||
| process.exit(0); | ||
| console.log("version is already up to date, do not publish"); | ||
| process.exit(1); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if same version, return error / false - no need to publish or further actions in publication
| } | ||
|
|
||
| await $`npm version ${version.trim()}`; | ||
| await $`npm version ${version.trim()}`; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
else npm version x (exit code 0 is success by default)
| "lint": "bunx tsc", | ||
| "prepublishOnly": "bun changelog-updater.js" | ||
| "update-changelog": "bun changelog-updater.js", | ||
| "manualPublish": "bun run update-changelog && npm publish" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can still run manually with this command, instead of relying on pre publish npm hook
nojaf
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would prefer a single script where all these tasks are handled together.
You can easily perform actions with the gh CLI, and using the Bun shell should work nicely for that.
Publish and github release could be done if a newer version was detected.
.github/workflows/publish.yml
Outdated
| - name : update changelog | ||
| id: update-changelog | ||
| run: bun run update-changelog | ||
| continue-on-error: true |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't like this, I prefer not to do anything versus checking error code of previous github action steps.
|
Shameless self-promotion but you could consider something more like https://youtu.be/t3R-GnW-r9g?si=ltRVzBC7yy_Ip7Xf Let the changelog be the driver, use |
add publish.yml gh action and publication workflow, and slightly modify manual npm publish package.json comands