diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 8691235..7dda100 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -17,6 +17,8 @@ jobs: release: name: 'Build, Test, Publish' runs-on: ubuntu-22.04 + outputs: + prerelease: ${{ steps.prepare_release.outputs.prerelease }} steps: - name: Check out repository ✨ uses: actions/checkout@v4 @@ -54,17 +56,25 @@ jobs: - name: Remove Test Data run: rm -R test_data* - - name: Publish to Full Version NPM + - name: Get Release Info + id: prepare_release + run: | + PACKAGE_VERSION=$(grep '"version"' package.json | cut -d '"' -f 4 | head -n 1) + echo "PACKAGE_VERSION=$PACKAGE_VERSION" >> $GITHUB_ENV + RELEASE_TYPE="$(node -e "console.log(require('semver').prerelease('$PACKAGE_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,9 +94,10 @@ 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 @@ -101,7 +112,7 @@ jobs: 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 +122,10 @@ 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 + \ No newline at end of file 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" },