-
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?
Changes from all commits
80df3a7
2def9fd
acd47d0
7d86133
e99610b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,38 @@ | ||
| name: Publish to npm | ||
|
|
||
| on: | ||
| workflow_run: | ||
| workflows: ["Main"] | ||
| types: | ||
| - completed | ||
| branches: [ "main" ] | ||
|
|
||
| jobs: | ||
| publish: | ||
| if: ${{ github.event.workflow_run.conclusion == 'success' }} | ||
|
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. runs only on succesful completion of main.yml |
||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - uses: actions/checkout@v4 | ||
| - uses: actions/setup-node@v4 | ||
| with: | ||
| node-version: '20' | ||
| registry-url: 'https://registry.npmjs.org/' | ||
| - uses: oven-sh/setup-bun@v1 | ||
| - run: bun install | ||
| - name: update changelog | ||
| run: | | ||
| if bun run update-changelog; then | ||
| echo "changelog updated" | ||
| else | ||
| echo "skipping publish because no changes were detected" | ||
| exit 1 | ||
| fi | ||
| - name: Publish to npm | ||
| run: npm publish | ||
jkone27 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| env: | ||
| NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} | ||
| - name: Push tags | ||
| run: | | ||
| git config --local user.name "github-actions" | ||
| git config --local user.email "[email protected]" | ||
| git push origin main --tags | ||
|
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 |
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -8,7 +8,11 @@ const version = await $`bunx changelog --latest-release`.text(); | |
| const packageVersion = await $`npm info vite-plugin-fable version`.text(); | ||
|
|
||
| if (version === packageVersion) { | ||
| process.exit(0); | ||
| console.log("version is already up to date, do not publish"); | ||
| process.exit(1); | ||
|
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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()}`; | ||
|
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. else |
||
|
|
||
| console.log(`Updated package.json version to ${version.trim()}`); | ||
| console.log(`Run 'git push origin main --tags' after publishing to push the new version tag.`); | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -10,7 +10,8 @@ | |
| "format": "bunx --bun prettier ./package.json ./index.js ./types.d.ts ./sample-project/vite.config.js ./docs/*.md ./docs/content/*.css ./docs/scripts/*.js ./docs/*.html ./.devcontainer/devcontainer.json --write && dotnet fantomas .", | ||
| "postinstall": "dotnet publish Fable.Daemon/Fable.Daemon.fsproj --nologo -c Release --ucr -p:PublishReadyToRun=true -o ./bin", | ||
| "lint": "bunx tsc", | ||
| "prepublishOnly": "bun changelog-updater.js" | ||
| "update-changelog": "bun changelog-updater.js", | ||
| "manualPublish": "bun run update-changelog && npm publish" | ||
|
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 |
||
| }, | ||
| "files": [ | ||
| "index.js", | ||
|
|
||
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