From c30d79981131dff465c738190c16d550ea3ffc77 Mon Sep 17 00:00:00 2001 From: Andrew Calcutt Date: Fri, 10 Jan 2025 18:46:19 -0500 Subject: [PATCH 1/5] add support for pre-release in release workflow (#1434) * add support for pre-release in release workflow * Update release.yml * add release check * workflow cleanup * cleanup * Create CHANGELOG.md * Update PUBLISHING.md --- .github/workflows/release.yml | 81 +++++++++++++++++++++++++++++------ CHANGELOG.md | 7 +++ PUBLISHING.md | 28 +++++++----- package-lock.json | 1 + package.json | 1 + 5 files changed, 95 insertions(+), 23 deletions(-) create mode 100644 CHANGELOG.md diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 8691235..0e83758 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -14,9 +14,51 @@ 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)' )" + RELEASE_TYPE="$(node -e "console.log(require('semver').prerelease('$currentVersion') ? 'prerelease' : 'regular')")" + echo "version=$currentVersion" >> "$GITHUB_OUTPUT" + echo "published=$isPublished" >> "$GITHUB_OUTPUT" + if [[ $RELEASE_TYPE == 'regular' ]]; then + echo "prerelease=false" >> "$GITHUB_OUTPUT" + else + echo "prerelease=true" >> "$GITHUB_OUTPUT" + fi + echo "currentVersion: $currentVersion" + echo "isPublished: $isPublished" + echo "prerelease: ${prerelease}" + outputs: + published: ${{ steps.check.outputs.published }} + prerelease: ${{ steps.check.outputs.prerelease }} + 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 }} + PRERELEASE: ${{ needs.release-check.outputs.prerelease }} + TAG: ${{ env.PRERELEASE == 'true' && 'next' || 'latest' }} steps: - name: Check out repository ✨ uses: actions/checkout@v4 @@ -54,17 +96,13 @@ jobs: - name: Remove Test Data run: rm -R test_data* - - name: Publish to Full Version NPM + - name: Publish to NPM run: | npm config set //registry.npmjs.org/:_authToken ${NPM_TOKEN} - npm publish --access public + npm publish --access public --tag ${{ env.TAG }} 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:${{ env.TAG }}, + 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: ${{ env.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 ${{ env.TAG }} 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:${{ env.TAG }}, + 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..108af87 --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,7 @@ +# tileserver-gl changelog + +## 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 \ No newline at end of file diff --git a/PUBLISHING.md b/PUBLISHING.md index 8b41b6b..ae17ff6 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/package-lock.json b/package-lock.json index 408b652..1210376 100644 --- a/package-lock.json +++ b/package-lock.json @@ -33,6 +33,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" }, diff --git a/package.json b/package.json index 14f94ae..86cf087 100644 --- a/package.json +++ b/package.json @@ -42,6 +42,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" }, From 70f954b3089e5b3b18b0d01bca30ebc482086500 Mon Sep 17 00:00:00 2001 From: Andrew Calcutt Date: Fri, 10 Jan 2025 18:53:06 -0500 Subject: [PATCH 2/5] remove bad env use (#1435) --- .github/workflows/release.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 0e83758..4255e55 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -58,7 +58,7 @@ jobs: env: PACKAGE_VERSION: ${{ needs.release-check.outputs.version }} PRERELEASE: ${{ needs.release-check.outputs.prerelease }} - TAG: ${{ env.PRERELEASE == 'true' && 'next' || 'latest' }} + TAG: ${{ needs.release-check.outputs.prerelease == 'true' && 'next' || 'latest' }} steps: - name: Check out repository ✨ uses: actions/checkout@v4 From 77b741986f99af7134ed91991a589e4fe1d9642d Mon Sep 17 00:00:00 2001 From: Andrew Calcutt Date: Fri, 10 Jan 2025 18:56:23 -0500 Subject: [PATCH 3/5] try to Fix workflow (#1436) * remove bad env use * try to fix outputs level --- .github/workflows/release.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 4255e55..7f66e8b 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -45,10 +45,10 @@ jobs: echo "currentVersion: $currentVersion" echo "isPublished: $isPublished" echo "prerelease: ${prerelease}" - outputs: - published: ${{ steps.check.outputs.published }} - prerelease: ${{ steps.check.outputs.prerelease }} - version: ${{ steps.check.outputs.version }} + outputs: + published: ${{ steps.check.outputs.published }} + prerelease: ${{ steps.check.outputs.prerelease }} + version: ${{ steps.check.outputs.version }} release: needs: release-check From 52549e5c3cb4b751a8d75e652be0031e1f7ec174 Mon Sep 17 00:00:00 2001 From: Andrew Calcutt Date: Fri, 10 Jan 2025 19:08:42 -0500 Subject: [PATCH 4/5] Fix workflow missing semver in first job (#1437) * remove bad env use * try to fix outputs level * move release type get to where semver is installed --- .github/workflows/release.yml | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 7f66e8b..525361c 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -34,20 +34,12 @@ jobs: run: | currentVersion="$( node -e "console.log(require('./package.json').version)" )" isPublished="$( npm view tileserver-gl versions --json | jq -c --arg cv "$currentVersion" 'any(. == $cv)' )" - RELEASE_TYPE="$(node -e "console.log(require('semver').prerelease('$currentVersion') ? 'prerelease' : 'regular')")" echo "version=$currentVersion" >> "$GITHUB_OUTPUT" echo "published=$isPublished" >> "$GITHUB_OUTPUT" - if [[ $RELEASE_TYPE == 'regular' ]]; then - echo "prerelease=false" >> "$GITHUB_OUTPUT" - else - echo "prerelease=true" >> "$GITHUB_OUTPUT" - fi echo "currentVersion: $currentVersion" echo "isPublished: $isPublished" - echo "prerelease: ${prerelease}" outputs: published: ${{ steps.check.outputs.published }} - prerelease: ${{ steps.check.outputs.prerelease }} version: ${{ steps.check.outputs.version }} release: @@ -57,8 +49,6 @@ jobs: runs-on: ubuntu-22.04 env: PACKAGE_VERSION: ${{ needs.release-check.outputs.version }} - PRERELEASE: ${{ needs.release-check.outputs.prerelease }} - TAG: ${{ needs.release-check.outputs.prerelease == 'true' && 'next' || 'latest' }} steps: - name: Check out repository ✨ uses: actions/checkout@v4 @@ -96,10 +86,20 @@ jobs: - name: Remove Test Data run: rm -R test_data* + - 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 --tag ${{ env.TAG }} + npm publish --access public --tag ${{ needs.release-check.outputs.prerelease == 'true' && 'next' || 'latest' }} env: NPM_TOKEN: ${{ github.event.inputs.npm_token }} @@ -123,7 +123,7 @@ jobs: context: . push: true tags: | - maptiler/tileserver-gl:${{ env.TAG }}, + maptiler/tileserver-gl:${{ needs.release-check.outputs.prerelease == 'true' && 'next' || 'latest' }}, maptiler/tileserver-gl:v${{ env.PACKAGE_VERSION }} platforms: linux/arm64,linux/amd64 cache-from: type=gha @@ -157,7 +157,7 @@ jobs: working-directory: ./light run: | npm config set //registry.npmjs.org/:_authToken ${NPM_TOKEN} - npm publish --access public --tag ${{ env.TAG }} + npm publish --access public --tag ${{ needs.release-check.outputs.prerelease == 'true' && 'next' || 'latest' }} env: NPM_TOKEN: ${{ github.event.inputs.npm_token }} @@ -168,7 +168,7 @@ jobs: file: ./light/Dockerfile push: true tags: | - maptiler/tileserver-gl-light:${{ env.TAG }}, + maptiler/tileserver-gl-light:${{ needs.release-check.outputs.prerelease == 'true' && 'next' || 'latest' }}, maptiler/tileserver-gl-light:v${{ env.PACKAGE_VERSION }} platforms: linux/arm64,linux/amd64 cache-from: type=gha From 3abbb39633e0aa8e8e692692a0aa2c3f7263caf5 Mon Sep 17 00:00:00 2001 From: Andrew Calcutt Date: Fri, 10 Jan 2025 19:11:31 -0500 Subject: [PATCH 5/5] Update PUBLISHING.md --- PUBLISHING.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/PUBLISHING.md b/PUBLISHING.md index ae17ff6..fedaf39 100644 --- a/PUBLISHING.md +++ b/PUBLISHING.md @@ -12,7 +12,7 @@ You can use prerelease to bump the version for a new pre-release version. E.g. y 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 +```## 5.0.0``` 3.) Commit and push the changes.