Skip to content

Conversation

@jkone27
Copy link
Collaborator

@jkone27 jkone27 commented May 23, 2025

add publish.yml gh action and publication workflow, and slightly modify manual npm publish package.json comands


on:
workflow_run:
workflows: ["Main"]
Copy link
Collaborator Author

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' }}
Copy link
Collaborator Author

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

- run: bun install
- name : update changelog
id: update-changelog
run: bun run update-changelog
Copy link
Collaborator Author

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

- name : update changelog
id: update-changelog
run: bun run update-changelog
continue-on-error: true
Copy link
Collaborator Author

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

Copy link
Member

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.

Copy link
Collaborator Author

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
Copy link
Collaborator Author

@jkone27 jkone27 May 23, 2025

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);
Copy link
Collaborator Author

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()}`;
Copy link
Collaborator Author

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"
Copy link
Collaborator Author

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

Copy link
Member

@nojaf nojaf left a 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.

- name : update changelog
id: update-changelog
run: bun run update-changelog
continue-on-error: true
Copy link
Member

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.

@nojaf
Copy link
Member

nojaf commented Oct 31, 2025

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 gh cli to make release (and thus git tag)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants