diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 8691235..e35c0e4 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -14,9 +14,41 @@ on: required: true jobs: + release-check: + name: Check if version is published + runs-on: ubuntu-latest + defaults: + run: + shell: bash + steps: + - uses: actions/checkout@v4 + + - uses: actions/setup-node@v4 + with: + node-version-file: 'package.json' + check-latest: true + cache: 'npm' + + - name: Check if version is published + id: check + run: | + currentVersion="$( node -e "console.log(require('./package.json').version)" )" + isPublished="$( npm view tileserver-gl versions --json | jq -c --arg cv "$currentVersion" 'any(. == $cv)' )" + echo "version=$currentVersion" >> "$GITHUB_OUTPUT" + echo "published=$isPublished" >> "$GITHUB_OUTPUT" + echo "currentVersion: $currentVersion" + echo "isPublished: $isPublished" + outputs: + published: ${{ steps.check.outputs.published }} + version: ${{ steps.check.outputs.version }} + release: + needs: release-check + if: ${{ needs.release-check.outputs.published == 'false' }} name: 'Build, Test, Publish' runs-on: ubuntu-22.04 + env: + PACKAGE_VERSION: ${{ needs.release-check.outputs.version }} steps: - name: Check out repository ✨ uses: actions/checkout@v4 @@ -54,17 +86,23 @@ jobs: - name: Remove Test Data run: rm -R test_data* - - name: Publish to Full Version NPM + - name: Get release type + id: prepare_release + run: | + RELEASE_TYPE="$(node -e "console.log(require('semver').prerelease('${{ needs.release-check.outputs.version }}') ? 'prerelease' : 'regular')")" + if [[ $RELEASE_TYPE == 'regular' ]]; then + echo "prerelease=false" >> "$GITHUB_OUTPUT" + else + echo "prerelease=true" >> "$GITHUB_OUTPUT" + fi + + - name: Publish to NPM run: | npm config set //registry.npmjs.org/:_authToken ${NPM_TOKEN} - npm publish --access public + npm publish --access public --tag ${{ steps.prepare_release.outputs.prerelease == 'true' && 'next' || 'latest' }} env: NPM_TOKEN: ${{ github.event.inputs.npm_token }} - - name: Get version - run: | - echo "PACKAGE_VERSION=$(grep '"version"' package.json | cut -d '"' -f 4 | head -n 1)" >> $GITHUB_ENV - - name: Set up QEMU uses: docker/setup-qemu-action@v3 with: @@ -84,24 +122,42 @@ jobs: with: context: . push: true - tags: maptiler/tileserver-gl:latest, maptiler/tileserver-gl:v${{ env.PACKAGE_VERSION }} + tags: | + maptiler/tileserver-gl:${{ steps.prepare_release.outputs.prerelease == 'true' && 'next' || 'latest' }}, + maptiler/tileserver-gl:v${{ env.PACKAGE_VERSION }} platforms: linux/arm64,linux/amd64 - # experimental: https://github.com/docker/build-push-action/blob/master/docs/advanced/cache.md#cache-backend-api cache-from: type=gha cache-to: type=gha,mode=max + - name: Extract changelog for version + run: | + awk '/^##/ { p = 0 }; p == 1 { print }; $0 == "## ${{ env.PACKAGE_VERSION }}" { p = 1 };' CHANGELOG.md > changelog_for_version.md + cat changelog_for_version.md + + - name: Publish to Github + uses: ncipollo/release-action@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + tag: v${{ env.PACKAGE_VERSION }} + name: v${{ env.PACKAGE_VERSION }} + bodyFile: changelog_for_version.md + allowUpdates: true + draft: false + prerelease: ${{ steps.prepare_release.outputs.prerelease }} + - name: Create Tileserver Light Directory run: node publish.js --no-publish - name: Install node dependencies - run: npm install + run: npm ci --prefer-offline --no-audit working-directory: ./light - name: Publish to Light Version NPM working-directory: ./light run: | npm config set //registry.npmjs.org/:_authToken ${NPM_TOKEN} - npm publish --access public + npm publish --access public --tag ${{ steps.prepare_release.outputs.prerelease == 'true' && 'next' || 'latest' }} env: NPM_TOKEN: ${{ github.event.inputs.npm_token }} @@ -111,8 +167,9 @@ jobs: context: ./light file: ./light/Dockerfile push: true - tags: maptiler/tileserver-gl-light:latest, maptiler/tileserver-gl-light:v${{ env.PACKAGE_VERSION }} + tags: | + maptiler/tileserver-gl-light:${{ steps.prepare_release.outputs.prerelease == 'true' && 'next' || 'latest' }}, + maptiler/tileserver-gl-light:v${{ env.PACKAGE_VERSION }} platforms: linux/arm64,linux/amd64 - # experimental: https://github.com/docker/build-push-action/blob/master/docs/advanced/cache.md#cache-backend-api cache-from: type=gha cache-to: type=gha,mode=max diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 0000000..99f07da --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,16 @@ +# tileserver-gl changelog + +## 5.1.1 +* Fix wrong node version in Docker image (https://github.com/maptiler/tileserver-gl/pull/1442) by @acalcutt + +## 5.1.0 +* Update recommended node to v22 + Update docker images to use node 22 (https://github.com/maptiler/tileserver-gl/pull/1438) by @acalcutt +* Upgrade Express to v5 + Canvas to v3 + code cleanup (https://github.com/maptiler/tileserver-gl/pull/1429) by @acalcutt +* Terrain Preview and simple Elevation Query (https://github.com/maptiler/tileserver-gl/pull/1425 and https://github.com/maptiler/tileserver-gl/pull/1432) by @okimiko +* add progressive rendering option for static jpeg images (#1397) by @samuel-git + +## 5.0.0 +* Update Maplibre-Native to [v6.0.0](https://github.com/maplibre/maplibre-native/releases/tag/node-v6.0.0) release by @acalcutt in https://github.com/maptiler/tileserver-gl/pull/1376 and @dependabot in https://github.com/maptiler/tileserver-gl/pull/1381 + * This first release that use Metal for rendering instead of OpenGL (ES) for macOS. + * This the first release that uses OpenGL (ES) 3.0 on Windows and Linux + * Note: Windows users may need to update their [c++ redistributable ](https://learn.microsoft.com/en-us/cpp/windows/latest-supported-vc-redist?view=msvc-170) for maplibre-native v6.0.0 diff --git a/Dockerfile b/Dockerfile index facc777..701377a 100644 --- a/Dockerfile +++ b/Dockerfile @@ -35,7 +35,7 @@ SHELL ["/bin/bash", "-o", "pipefail", "-c"] RUN mkdir -p /etc/apt/keyrings; \ curl -fsSL https://deb.nodesource.com/gpgkey/nodesource-repo.gpg.key | gpg --dearmor -o /etc/apt/keyrings/nodesource.gpg; \ - echo "deb [signed-by=/etc/apt/keyrings/nodesource.gpg] https://deb.nodesource.com/node_20.x nodistro main" | tee /etc/apt/sources.list.d/nodesource.list; \ + echo "deb [signed-by=/etc/apt/keyrings/nodesource.gpg] https://deb.nodesource.com/node_22.x nodistro main" | tee /etc/apt/sources.list.d/nodesource.list; \ apt-get -qq update; \ apt-get install -y nodejs; \ npm i -g npm@latest; \ @@ -94,7 +94,7 @@ SHELL ["/bin/bash", "-o", "pipefail", "-c"] RUN mkdir -p /etc/apt/keyrings; \ curl -fsSL https://deb.nodesource.com/gpgkey/nodesource-repo.gpg.key | gpg --dearmor -o /etc/apt/keyrings/nodesource.gpg; \ - echo "deb [signed-by=/etc/apt/keyrings/nodesource.gpg] https://deb.nodesource.com/node_20.x nodistro main" | tee /etc/apt/sources.list.d/nodesource.list; \ + echo "deb [signed-by=/etc/apt/keyrings/nodesource.gpg] https://deb.nodesource.com/node_22.x nodistro main" | tee /etc/apt/sources.list.d/nodesource.list; \ apt-get -qq update; \ apt-get install -y nodejs; \ npm i -g npm@latest; \ diff --git a/Dockerfile_light b/Dockerfile_light index 6a6595b..f16f25d 100644 --- a/Dockerfile_light +++ b/Dockerfile_light @@ -16,7 +16,7 @@ RUN set -ex; \ gnupg; \ mkdir -p /etc/apt/keyrings; \ curl -fsSL https://deb.nodesource.com/gpgkey/nodesource-repo.gpg.key | gpg --dearmor -o /etc/apt/keyrings/nodesource.gpg; \ - echo "deb [signed-by=/etc/apt/keyrings/nodesource.gpg] https://deb.nodesource.com/node_20.x nodistro main" | tee /etc/apt/sources.list.d/nodesource.list; \ + echo "deb [signed-by=/etc/apt/keyrings/nodesource.gpg] https://deb.nodesource.com/node_22.x nodistro main" | tee /etc/apt/sources.list.d/nodesource.list; \ apt-get -qq update; \ apt-get install -y nodejs; \ npm i -g npm@latest; \ diff --git a/Dockerfile_test b/Dockerfile_test index db69272..be79e28 100644 --- a/Dockerfile_test +++ b/Dockerfile_test @@ -13,7 +13,8 @@ RUN set -ex; \ unzip \ build-essential \ ca-certificates \ - wget \ + curl \ + gnupg \ pkg-config \ xvfb \ libglfw3-dev \ @@ -25,16 +26,33 @@ RUN set -ex; \ libjpeg-dev \ libgif-dev \ librsvg2-dev \ + gir1.2-rsvg-2.0 \ + librsvg2-2 \ + librsvg2-common \ libcurl4-openssl-dev \ - libpixman-1-dev; \ - wget -qO- https://deb.nodesource.com/setup_18.x | bash; \ + libpixman-1-dev \ + libpixman-1-0; \ + apt-get -y --purge autoremove; \ + apt-get clean; \ + rm -rf /var/lib/apt/lists/*; + +SHELL ["/bin/bash", "-o", "pipefail", "-c"] + +RUN mkdir -p /etc/apt/keyrings; \ + curl -fsSL https://deb.nodesource.com/gpgkey/nodesource-repo.gpg.key | gpg --dearmor -o /etc/apt/keyrings/nodesource.gpg; \ + echo "deb [signed-by=/etc/apt/keyrings/nodesource.gpg] https://deb.nodesource.com/node_22.x nodistro main" | tee /etc/apt/sources.list.d/nodesource.list; \ + apt-get -qq update; \ apt-get install -y nodejs; \ - apt-get clean; + npm i -g npm@latest; \ + apt-get -y remove gnupg; \ + apt-get -y --purge autoremove; \ + apt-get clean; \ + rm -rf /var/lib/apt/lists/*; RUN mkdir -p /usr/src/app WORKDIR /usr/src/app -RUN wget -O test_data.zip https://github.com/maptiler/tileserver-gl/releases/download/v1.3.0/test_data.zip; \ +RUN curl -L -o test_data.zip https://github.com/maptiler/tileserver-gl/releases/download/v1.3.0/test_data.zip; \ unzip -q test_data.zip -d test_data COPY package.json . diff --git a/PUBLISHING.md b/PUBLISHING.md index 8b41b6b..fedaf39 100644 --- a/PUBLISHING.md +++ b/PUBLISHING.md @@ -1,13 +1,19 @@ # Publishing new version -- Update version in `package.json` -- `git tag vx.x.x` -- `git push --tags` -- `docker buildx build --platform linux/amd64 -t maptiler/tileserver-gl:latest -t maptiler/tileserver-gl:[version] .` -- `docker push maptiler/tileserver-gl --all-tags` -- `npm publish --access public` or `node publish.js` -- `node publish.js --no-publish` -- `cd light` -- `docker buildx build --platform linux/amd64 -t maptiler/tileserver-gl-light:latest -t maptiler/tileserver-gl-light:[version] .` -- `docker push maptiler/tileserver-gl-light --all-tags` -- `npm publish --access public` +1.) Change the version number in package.json. Run the following command in the package root directory, replacing with one of the semantic versioning release types (prerelease, prepatch, preminor, premajor, patch, minor, major): +npm version --preid pre --no-git-tag-version + +--preid specifies which suffix to use in the release such as pre, next, beta, rc, etc. + +prepatch, preminor, and premajor start a new series of pre-releases while bumping the patch, minor, or major version. E.g. premajor with --preid pre would do a prerelease for a new major using the -pre suffix (i.e. it would be a new major with -pre.0) + +You can use prerelease to bump the version for a new pre-release version. E.g. you could run npm version prerelease --preid pre --no-git-tag-version to go from -pre.0 to -pre.1. + +For regular versions, you can use patch, minor, or major. E.g. npm version major --no-git-tag-version. + +2.) Update the changelog, which can be found in CHANGELOG.md. The heading must match ## exactly, or it will not be picked up. For example, for version 5.0.0: +```## 5.0.0``` + +3.) Commit and push the changes. + +4.) Run the 'Build, Test, Release' github workflow. The workflow will create a NPM, Docker, and Github release and Tag. diff --git a/README.md b/README.md index cf310ba..55c2bda 100644 --- a/README.md +++ b/README.md @@ -9,7 +9,7 @@ Vector and raster maps with GL styles. Server-side rendering by MapLibre GL Nati Download vector tiles from [OpenMapTiles](https://data.maptiler.com/downloads/planet/). ## Getting Started with Node -Make sure you have Node.js version **18.17.0** or above installed. Node 20 is recommended. (running `node -v` it should output something like `v20.x.x`). Running without docker requires [Native dependencies](https://maptiler-tileserver.readthedocs.io/en/latest/installation.html#npm) to be installed first. +Make sure you have Node.js version **18.17.0** or above installed. Node 22 is recommended. (running `node -v` it should output something like `v22.x.x`). Running without docker requires [Native dependencies](https://maptiler-tileserver.readthedocs.io/en/latest/installation.html#npm) to be installed first. Install `tileserver-gl` with server-side raster rendering of vector tiles with npm. @@ -43,7 +43,7 @@ An alternative to npm to start the packed software easier is to install [Docker] Example using a mbtiles file ```bash wget https://github.com/maptiler/tileserver-gl/releases/download/v1.3.0/zurich_switzerland.mbtiles -docker run --rm -it -v $(pwd):/data -p 8080:8080 maptiler/tileserver-gl --file zurich_switzerland.mbtiles +docker run --rm -it -v $(pwd):/data -p 8080:8080 maptiler/tileserver-gl:latest --file zurich_switzerland.mbtiles [in your browser, visit http://[server ip]:8080] ``` @@ -51,18 +51,18 @@ Example using a config.json + style + mbtiles file ```bash wget https://github.com/maptiler/tileserver-gl/releases/download/v1.3.0/test_data.zip unzip test_data.zip -docker run --rm -it -v $(pwd):/data -p 8080:8080 maptiler/tileserver-gl +docker run --rm -it -v $(pwd):/data -p 8080:8080 maptiler/tileserver-gl:latest [in your browser, visit http://[server ip]:8080] ``` Example using a different path ```bash -docker run --rm -it -v /your/local/config/path:/data -p 8080:8080 maptiler/tileserver-gl +docker run --rm -it -v /your/local/config/path:/data -p 8080:8080 maptiler/tileserver-gl:latest ``` replace '/your/local/config/path' with the path to your config file -Alternatively, you can use the `maptiler/tileserver-gl-light` docker image instead, which is pure javascript, does not have any native dependencies, and can run anywhere, but does not contain rasterization on the server side made with Maplibre GL Native. +Alternatively, you can use the `maptiler/tileserver-gl-light:latest` docker image instead, which is pure javascript, does not have any native dependencies, and can run anywhere, but does not contain rasterization on the server side made with Maplibre GL Native. ## Getting Started with Linux cli diff --git a/package-lock.json b/package-lock.json index 687ff75..cba4519 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "tileserver-gl", - "version": "5.0.0", + "version": "5.1.1", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "tileserver-gl", - "version": "5.0.0", + "version": "5.1.1", "license": "BSD-2-Clause", "dependencies": { "@jsse/pbfont": "^0.2.2", @@ -34,6 +34,7 @@ "pmtiles": "3.0.7", "proj4": "2.12.1", "sanitize-filename": "1.6.3", + "semver": "^7.6.3", "sharp": "0.33.5", "tileserver-gl-styles": "2.0.0" }, @@ -60,7 +61,7 @@ "yaml-lint": "^1.7.0" }, "engines": { - "node": ">=18.17.0 <21" + "node": ">=18.17.0 <23" } }, "node_modules/@aashutoshrathi/word-wrap": { diff --git a/package.json b/package.json index 4c6bda2..f2e26e5 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "tileserver-gl", - "version": "5.0.0", + "version": "5.1.1", "description": "Map tile server for JSON GL styles - vector and server side generated raster tiles", "main": "src/main.js", "bin": "src/main.js", @@ -43,6 +43,7 @@ "pmtiles": "3.0.7", "proj4": "2.12.1", "sanitize-filename": "1.6.3", + "semver": "^7.6.3", "sharp": "0.33.5", "tileserver-gl-styles": "2.0.0" }, @@ -73,7 +74,7 @@ ], "license": "BSD-2-Clause", "engines": { - "node": ">=18.17.0 <21" + "node": ">=18.17.0 <23" }, "repository": { "url": "git+https://github.com/maptiler/tileserver-gl.git", diff --git a/src/serve_data.js b/src/serve_data.js index b93bd3a..9843dfe 100644 --- a/src/serve_data.js +++ b/src/serve_data.js @@ -308,15 +308,12 @@ export const serve_data = { } else if (format !== 'webp' && format !== 'png') { return res.status(400).send('Invalid format. Must be webp or png.'); } - const z = parseInt(req.params.z, 10); const x = parseFloat(req.params.x); const y = parseFloat(req.params.y); - if (tileJSON.minzoom == null || tileJSON.maxzoom == null) { return res.status(404).send(JSON.stringify(tileJSON)); } - const TILE_SIZE = tileJSON.tileSize || 512; let bbox; let xy; @@ -325,7 +322,6 @@ export const serve_data = { if (Number.isInteger(x) && Number.isInteger(y)) { const intX = parseInt(req.params.x, 10); const intY = parseInt(req.params.y, 10); - if ( zoom < tileJSON.minzoom || zoom > tileJSON.maxzoom || @@ -346,7 +342,6 @@ export const serve_data = { if (zoom > tileJSON.maxzoom) { zoom = tileJSON.maxzoom; } - bbox = [x, y, x + 0.1, y + 0.1]; const { minX, minY } = new SphericalMercator().xyz(bbox, zoom); xy = [minX, minY]; @@ -368,7 +363,6 @@ export const serve_data = { const canvas = createCanvas(TILE_SIZE, TILE_SIZE); const context = canvas.getContext('2d'); context.drawImage(image, 0, 0); - const long = bbox[0]; const lat = bbox[1]; @@ -378,7 +372,6 @@ export const serve_data = { // Truncating to 0.9999 effectively limits latitude to 89.189. This is // about a third of a tile past the edge of the world tile. siny = Math.min(Math.max(siny, -0.9999), 0.9999); - const xWorld = TILE_SIZE * (0.5 + long / 360); const yWorld = TILE_SIZE * @@ -391,7 +384,6 @@ export const serve_data = { const xPixel = Math.floor(xWorld * scale) - xTile * TILE_SIZE; const yPixel = Math.floor(yWorld * scale) - yTile * TILE_SIZE; - if ( xPixel < 0 || yPixel < 0 || @@ -400,12 +392,10 @@ export const serve_data = { ) { return reject('Out of bounds Pixel'); } - const imgdata = context.getImageData(xPixel, yPixel, 1, 1); const red = imgdata.data[0]; const green = imgdata.data[1]; const blue = imgdata.data[2]; - let elevation; if (encoding === 'mapbox') { elevation = -10000 + (red * 256 * 256 + green * 256 + blue) * 0.1; @@ -414,7 +404,6 @@ export const serve_data = { } else { elevation = 'invalid encoding'; } - resolve( res.status(200).send({ z: zoom, @@ -429,9 +418,7 @@ export const serve_data = { }), ); }; - image.onerror = (err) => reject(err); - if (format === 'webp') { try { const img = await sharp(data).toFormat('png').toBuffer();