diff --git a/.github/workflows/bump-version.yml b/.github/workflows/bump-version.yml new file mode 100644 index 000000000..00f397491 --- /dev/null +++ b/.github/workflows/bump-version.yml @@ -0,0 +1,50 @@ +name: Bump Version Tag + +on: + push: + branches: [main] + +jobs: + bump-version: + runs-on: ubuntu-latest + permissions: + contents: write + steps: + - uses: actions/checkout@v5 + with: + fetch-depth: 0 + + - uses: actions/setup-node@v6 + with: + node-version: '24' + + - name: Get latest version tag + id: get_version + run: | + git fetch --tags + LATEST_TAG=$(git tag -l "v*" | sort -V | tail -n 1) + if [ -z "$LATEST_TAG" ]; then + echo "latest=v0.0.0" >> $GITHUB_OUTPUT + else + echo "latest=$LATEST_TAG" >> $GITHUB_OUTPUT + fi + + - name: Bump prerelease version + id: bump_version + run: | + LATEST_VERSION="${{ steps.get_version.outputs.latest }}" + VERSION_NUMBER="${LATEST_VERSION#v}" + + echo "$VERSION_NUMBER" > VERSION_TEMP + npm version --no-git-tag-version $VERSION_NUMBER + npm version --no-git-tag-version prerelease --preid=dev + + NEW_VERSION=$(node -p "require('./package.json').version") + echo "new_version=v$NEW_VERSION" >> $GITHUB_OUTPUT + + - name: Create and push tag + run: | + git config user.name "github-actions[bot]" + git config user.email "github-actions[bot]@users.noreply.github.com" + git tag ${{ steps.bump_version.outputs.new_version }} + git push origin ${{ steps.bump_version.outputs.new_version }} diff --git a/.github/workflows/publish-npm.yml b/.github/workflows/publish-npm.yml new file mode 100644 index 000000000..364824793 --- /dev/null +++ b/.github/workflows/publish-npm.yml @@ -0,0 +1,43 @@ +name: Publish to NPM + +on: + push: + tags: + - 'v[0-9]+.[0-9]+.[0-9]+-dev.[0-9]+' + - 'v[0-9]+.[0-9]+.[0-9]+' + +jobs: + publish: + runs-on: ubuntu-latest + permissions: + contents: read + id-token: write + steps: + - uses: actions/checkout@v5 + + - uses: actions/setup-node@v6 + with: + node-version: '24' + registry-url: 'https://registry.npmjs.org' + + - name: Extract version from tag + id: get_version + run: | + VERSION="${GITHUB_REF#refs/tags/v}" + echo "version=$VERSION" >> $GITHUB_OUTPUT + if [[ "$VERSION" == *"-dev."* ]]; then + echo "tag=dev" >> $GITHUB_OUTPUT + else + echo "tag=latest" >> $GITHUB_OUTPUT + fi + + - name: Update package.json version + run: npm version --no-git-tag-version ${{ steps.get_version.outputs.version }} + + - run: npm ci + - run: npm run postinstall + + - name: Build with remote save enabled + run: VITE_REMOTE_SERVER_URL= VITE_ENABLE_REMOTE_SAVE=true npm run build + + - run: npm publish --provenance --access public --tag ${{ steps.get_version.outputs.tag }} diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index f8f37f59f..f23b0ef9b 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -4,7 +4,7 @@ Before you begin, make sure your environment matches the following versions: -- **Node.js**: >= 18.20.0 (20.x LTS recommended) +- **Node.js**: >= 18.20.0 (20.x LTS recommended) - **npm**: >= 9.x (npm 10+ works with Node 20) Check your versions: @@ -22,7 +22,6 @@ For reproducible installs, use: npm ci ``` - --- ## Dependencies @@ -97,6 +96,33 @@ npm run test:e2e:dev -- -- --spec ./tests/specs/remote-manifest.e2e.ts --- +## Versioning + +Merging to `main` automatically publishes dev versions to NPM: + +1. Merge creates a prerelease tag (v4.4.0-dev.1, v4.4.0-dev.2, etc.) +2. Tag triggers automatic NPM publish with `@dev` dist-tag + +Users install stable versions by default: + +```bash +npm install volview # Gets latest stable (e.g., 4.4.0) +npm install volview@dev # Gets latest dev (e.g., 4.4.0-dev.5) +``` + +For stable releases, manually create a tag: + +```bash +git tag v4.5.0 # or v5.0.0 +git push origin v4.5.0 +``` + +### Update demo site + +To update https://volview.kitware.app/, merge to the `stable` branch. + +--- + ## Developing with VTK.js Follow these steps to develop against a custom development branch of VTK.js: diff --git a/package.json b/package.json index 56d14665d..72f4c68e9 100644 --- a/package.json +++ b/package.json @@ -2,6 +2,10 @@ "name": "volview", "version": "4.4.0", "type": "module", + "files": [ + "dist", + "src" + ], "scripts": { "dev": "cross-env VITE_SHOW_SAMPLE_DATA=true vite", "preview": "vite preview",