diff --git a/.github/workflows/npm-publish.yml b/.github/workflows/npm-publish.yml index 0b878be..016f09f 100644 --- a/.github/workflows/npm-publish.yml +++ b/.github/workflows/npm-publish.yml @@ -27,8 +27,8 @@ jobs: - name: Install dependencies and build run: npm ci - - name: Build Release - run: npm run build + - name: Make release + run: npm run make id: makeRelease - name: Fail job if makeRelease failed @@ -39,28 +39,26 @@ jobs: - name: Publish NPM package (regular) if: "!github.event.release.prerelease" run: | - npm run pub + npm publish env: NODE_AUTH_TOKEN: ${{secrets.npm_token}} - name: Publish NPM package (pre-release) if: "github.event.release.prerelease" run: | - npm run pub-next + npm publish --tag next env: NODE_AUTH_TOKEN: ${{secrets.npm_token}} - - name: Send Dispatch Event to CDN Repo - run: | - curl -X POST \ - -H "Authorization: token ${{ secrets.CDN_MAPTILER_TOKEN }}" \ - -H "Accept: application/vnd.github.v3+json" \ - https://api.github.com/repos/maptiler/cdn.maptiler.com/dispatches \ - -d '{ \ - "event_type": "repo_release", \ - "client_payload": { \ - "repo": "${{ github.repository }}", \ - "tag": "${{ github.event.release.tag_name }}", \ - "build_dir": "build" \ - } - }' + - name: Get Package version + id: version + run: echo "PACKAGE_VERSION=$(node -p "require('./package.json').version")" >> $GITHUB_ENV + - name: Publish to CDN Cloudflar R2 + uses: ryand56/r2-upload-action@v1.4 + with: + r2-account-id: ${{ secrets.CDN_MAPTILER_ACCOUNT_ID }} + r2-access-key-id: ${{ secrets.CDN_MAPTILER_ACCESS_KEY_ID }} + r2-secret-access-key: ${{ secrets.CDN_MAPTILER_SECRET_ACCESS_KEY }} + r2-bucket: cdn-storage + source-dir: dist + destination-dir: maptiler-geocoding-control/v${{ env.PACKAGE_VERSION }}/ diff --git a/.github/workflows/publish-dry-run.yml b/.github/workflows/publish-dry-run.yml new file mode 100644 index 0000000..924f895 --- /dev/null +++ b/.github/workflows/publish-dry-run.yml @@ -0,0 +1,51 @@ +# This workflow will run tests using node and then publish a package to GitHub Packages when a release is created +# For more information see: https://docs.github.com/en/actions/publishing-packages/publishing-nodejs-packages + +name: Node.js Package + +on: + pull_request: + types: [opened] + +jobs: + test-build-and-publish: + runs-on: ubuntu-latest + steps: + - name: Checkout repo + uses: actions/checkout@v4 + with: + ref: ${{ github.event.release.target_commitish }} + + - uses: actions/setup-node@v4 + with: + node-version: 20 + registry-url: https://registry.npmjs.org/ + + - name: Clear NPM cache + run: npm cache clean --force + + - name: Install dependencies and build + run: npm ci + + - name: Make release + run: npm run make + id: makeRelease + + - name: Fail job if makeRelease failed + if: steps.makeRelease.outcome == 'failure' + run: exit 1 + + id: check-build-status + - name: Publish NPM package (regular) + if: "!github.event.release.prerelease" + run: | + npm publish --dry-run + env: + NODE_AUTH_TOKEN: ${{secrets.npm_token}} + + - name: Publish NPM package (pre-release) + if: "github.event.release.prerelease" + run: | + npm publish --tag next --dry-run + env: + NODE_AUTH_TOKEN: ${{secrets.npm_token}} diff --git a/README.md b/README.md index 82b957f..3ca462e 100644 --- a/README.md +++ b/README.md @@ -20,7 +20,7 @@ ## What? -The *MapTiler Geocoding control* implements a powerful search box in your maps or online forms, enabling your application users to find any place on Earth down to individual addresses. Use the search box control with [MapTiler SDK JS](https://docs.maptiler.com/sdk-js/) (or other map libraries like [Leaflet](https://docs.maptiler.com/leaflet/), [MapLibre GL JS](https://github.com/maplibre/maplibre-gl-js), [OpenLayers](https://docs.maptiler.com/openlayers/)). +The _MapTiler Geocoding control_ implements a powerful search box in your maps or online forms, enabling your application users to find any place on Earth down to individual addresses. Use the search box control with [MapTiler SDK JS](https://docs.maptiler.com/sdk-js/) (or other map libraries like [Leaflet](https://docs.maptiler.com/leaflet/), [MapLibre GL JS](https://github.com/maplibre/maplibre-gl-js), [OpenLayers](https://docs.maptiler.com/openlayers/)). ## Why? @@ -29,13 +29,13 @@ The _Geocoding control_ uses the [MapTiler Geocoding API](https://www.maptiler.c With this control, users of mapping application can: -* Find any place on Earth (States, Cities, Streets, Addresses, POIs, ...) down -to the address level -* Find and identify objects or place names using a coordinate pair or a single mouse click (reverse geocoding) -* Restrict the search area to a specific country, bounding box, or proximity -* Highlight searched results on the map (marker or full geometry) -* Autocomplete words while typing -* and much more. Check out the [Geocoding Control API reference](https://docs.maptiler.com/sdk-js/modules/geocoding/api/api-reference/#options) to see all the options. +- Find any place on Earth (States, Cities, Streets, Addresses, POIs, ...) down + to the address level +- Find and identify objects or place names using a coordinate pair or a single mouse click (reverse geocoding) +- Restrict the search area to a specific country, bounding box, or proximity +- Highlight searched results on the map (marker or full geometry) +- Autocomplete words while typing +- and much more. Check out the [Geocoding Control API reference](https://docs.maptiler.com/sdk-js/modules/geocoding/api/api-reference/#options) to see all the options. The component can be used as an ES module or UMD module with or without bundler. diff --git a/package.json b/package.json index e93680c..c3fc804 100644 --- a/package.json +++ b/package.json @@ -32,6 +32,7 @@ ], "scripts": { "dev": "vite --host", + "make": "npm run clean && npm run build", "build": "node sync-info.js run && npm run check && concurrently --names \"SVELTE ,MAPLIBRE,MAPTILER,MAPLIB-C,LEAFLET ,LEAFLE-C,OL ,OL-C ,REACT ,TYPES ,VANILLA \" \"npm run build-svelte\" \"npm run build-maplibre\" \"npm run build-maptilersdk\" \"npm run build-maplibre-controller\" \"npm run build-leaflet\" \"npm run build-leaflet-controller\" \"npm run build-openlayers\" \"npm run build-openlayers-controller\" \"npm run build-react\" \"npm run build-vanilla\" \"npm run build-types\" && cp LICENSE README.md package.json dist && cp -r dist.svelte dist/svelte", "build-svelte": "svelte-package -i src -o dist.svelte && VITE_LIB_VERSION=$npm_package_version node replace-env-vars.js", "build-maptilersdk": "FLAVOUR=maptilersdk vite build",