Skip to content
37 changes: 37 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
name: Release package

on:
push:
tags:
- "v*.*.*"

jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v6

- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v6
with:
node-version: 22.x
cache: 'npm'

- run: npm version ${{ github.ref_name }} --no-git-tag-version

- run: npm install

- run: npm test

- run: npm pack

- run: npm publish

- name: Release
if: ${{ always() }}
Copy link

Copilot AI Dec 28, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using always() will create a GitHub release even if tests fail or npm publish fails. Consider using success() or removing the condition to only create releases when the build succeeds.

Suggested change
if: ${{ always() }}
if: ${{ success() }}

Copilot uses AI. Check for mistakes.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems like a valid point, why would we publish the notes when the publish fails?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because the github release contain the artifact's which could be manually uploaded to npm.

uses: softprops/action-gh-release@v2
with:
generate_release_notes: true
files: |
./doctoc-*.tgz
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"author": "Thorsten Lorenz <[email protected]> (thlorenz.com)",
"name": "doctoc",
"description": "Generates TOC for markdown files of local git repo.",
"version": "2.2.0",
"version": "0.0.0-development",
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure if this is a good idea, as based on my limited experience with Node.js app development, it doesn't appear to be a common practice.

Copy link
Contributor Author

@thompson-tomo thompson-tomo Dec 28, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For me it is better and more efficient to use a clear placeholder value rather than having to either manually maintain the version value or adding more advanced ci pipelines given low volume of releases. Note this value is used purely for informational purposes as the git tag value is used to ensure they are aligned.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't love this either. It's standard practice for the "version" tag to accurately reflect the npm and git tags. Not having that can break standard expectations.

What would it take to include bumping the version tag here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That is still the case that the package version & git tags all match because at build time the value of the tag is set as the value. This means as a user they see no difference.

The difficulty is if we have the trigger of a release being that a tag is added, how can we get that value to be set in the source code so that it matches. It would mean the tag is 1 commit behind.

The common way to do it would be to raise a pr which bumps the version and when merged the release occurs. That would be a big change for such infrequent releases.

"repository": {
"type": "git",
"url": "git://github.com/thlorenz/doctoc.git"
Expand Down