name: 'Build, Test, Release' on: workflow_dispatch: inputs: docker_user: description: 'Docker Username' required: true docker_token: description: 'Docker Token' required: true npm_token: description: 'NPM Token' 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 - name: Update apt-get ๐Ÿš€ run: sudo apt-get update -qq - name: Install dependencies (Ubuntu) ๐Ÿš€ run: >- sudo apt-get install -qq libcairo2-dev libjpeg8-dev libpango1.0-dev libgif-dev build-essential g++ xvfb libgles2-mesa-dev libgbm-dev libxxf86vm-dev - name: Setup node env ๐Ÿ“ฆ uses: actions/setup-node@v4 with: node-version-file: 'package.json' check-latest: true cache: 'npm' - name: Install dependencies ๐Ÿš€ run: npm ci --prefer-offline --no-audit - name: Pull test data ๐Ÿ“ฆ run: >- wget -O test_data.zip https://github.com/maptiler/tileserver-gl/releases/download/v1.3.0/test_data.zip - name: Prepare test data ๐Ÿ“ฆ run: unzip -q test_data.zip -d test_data - name: Run tests ๐Ÿงช run: xvfb-run --server-args="-screen 0 1024x768x24" npm test - name: Remove Test Data run: rm -R test_data* - name: Publish to NPM run: | npm config set //registry.npmjs.org/:_authToken ${NPM_TOKEN} npm publish --access public --tag ${{ env.TAG }} env: NPM_TOKEN: ${{ github.event.inputs.npm_token }} - name: Set up QEMU uses: docker/setup-qemu-action@v3 with: platforms: 'arm64' - name: Set up Docker Buildx uses: docker/setup-buildx-action@v3 - name: Login to DockerHub uses: docker/login-action@v2 with: username: ${{ github.event.inputs.docker_user }} password: ${{ github.event.inputs.docker_token }} - name: Build and publish Full Version to Docker Hub uses: docker/build-push-action@v6 with: context: . push: true tags: | maptiler/tileserver-gl:${{ env.TAG }}, maptiler/tileserver-gl:v${{ env.PACKAGE_VERSION }} platforms: linux/arm64,linux/amd64 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 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 --tag ${{ env.TAG }} env: NPM_TOKEN: ${{ github.event.inputs.npm_token }} - name: Build and publish Light Version to Docker Hub uses: docker/build-push-action@v6 with: context: ./light file: ./light/Dockerfile push: true tags: | maptiler/tileserver-gl-light:${{ env.TAG }}, maptiler/tileserver-gl-light:v${{ env.PACKAGE_VERSION }} platforms: linux/arm64,linux/amd64 cache-from: type=gha cache-to: type=gha,mode=max