Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 32 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,35 @@ jobs:
run: |
npm run test
npm run build

release:
needs: build
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Check for version bump
id: version
run: |
PACKAGE_VERSION=$(node -p "require('./package.json').version")
if git rev-parse "${PACKAGE_VERSION}" >/dev/null 2>&1; then
echo "Tag ${PACKAGE_VERSION} already exists, skipping release."
echo "changed=false" >> "$GITHUB_OUTPUT"
else
echo "New version detected: ${PACKAGE_VERSION}"
echo "changed=true" >> "$GITHUB_OUTPUT"
echo "version=${PACKAGE_VERSION}" >> "$GITHUB_OUTPUT"
fi
- name: Create tag and GitHub Release
if: steps.version.outputs.changed == 'true'
env:
GH_TOKEN: ${{ github.token }}
run: |
VERSION=${{ steps.version.outputs.version }}
git tag "${VERSION}"
git push origin "${VERSION}"
gh release create "${VERSION}" --title "${VERSION}" --generate-notes
10 changes: 6 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -219,12 +219,14 @@ parser.parse('COUNTIF(A1:E2, ">5")'); // returns `5`

To publish a new version of the package:

1. **Create a release** by running:
1. **Bump the version** on a feature branch:
```sh
$ npm run release
$ npm run release patch # or minor, or major
```
This uses [`generate-release`](https://www.npmjs.com/package/generate-release) to bump the version in `package.json`, create a git tag, and push changes.
This updates the version in `package.json` without committing or tagging.

2. **Publish to GitHub Packages** happens automatically — the `.github/workflows/publish.yml` workflow triggers when a GitHub Release is published, building and publishing the package to the GitHub Packages registry.
2. **Commit and open a PR** to `main`.

3. **After the PR is merged**, CI will automatically detect the version bump, create a git tag and a GitHub Release, which triggers the publish workflow to build and publish the package to the GitHub Packages registry.

Before publishing, the `prepublishOnly` hook automatically runs linting, tests, and the build to ensure the package is in a good state.
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.

5 changes: 2 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@time-loop/hot-formula-parser",
"version": "4.3.1",
"version": "4.3.2",
"description": "Formula parser",
"type": "commonjs",
"main": "dist/index.js",
Expand All @@ -19,7 +19,7 @@
"test:generate": "ts-node test/scripts/generatePerfTestData.ts",
"build": "tsc",
"generate-parser": "cd src/grammar-parser && jison grammar-parser.jison",
"release": "generate-release",
"release": "npm version --no-git-tag-version",
"prepublishOnly": "npm run clean && npm run check && npm run build"
},
"repository": {
Expand Down Expand Up @@ -48,7 +48,6 @@
"@types/jest": "^29.5.12",
"eslint": "^9.9.0",
"eslint-plugin-jest": "^28.8.0",
"generate-release": "^1.1.1",
"globals": "^15.9.0",
"jest": "^29.7.0",
"jest-cli": "^29.7.0",
Expand Down
Loading