add support for pre-release in release workflow

This commit is contained in:
acalcutt 2025-01-10 17:18:53 -05:00
parent 9d222c1dec
commit 9af4c5da5d
3 changed files with 26 additions and 11 deletions

View file

@ -17,6 +17,8 @@ jobs:
release: release:
name: 'Build, Test, Publish' name: 'Build, Test, Publish'
runs-on: ubuntu-22.04 runs-on: ubuntu-22.04
outputs:
prerelease: ${{ steps.prepare_release.outputs.prerelease }}
steps: steps:
- name: Check out repository ✨ - name: Check out repository ✨
uses: actions/checkout@v4 uses: actions/checkout@v4
@ -54,17 +56,25 @@ jobs:
- name: Remove Test Data - name: Remove Test Data
run: rm -R 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: | run: |
npm config set //registry.npmjs.org/:_authToken ${NPM_TOKEN} 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: env:
NPM_TOKEN: ${{ github.event.inputs.npm_token }} 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 - name: Set up QEMU
uses: docker/setup-qemu-action@v3 uses: docker/setup-qemu-action@v3
with: with:
@ -84,9 +94,10 @@ jobs:
with: with:
context: . context: .
push: true 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 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-from: type=gha
cache-to: type=gha,mode=max cache-to: type=gha,mode=max
@ -101,7 +112,7 @@ jobs:
working-directory: ./light working-directory: ./light
run: | run: |
npm config set //registry.npmjs.org/:_authToken ${NPM_TOKEN} 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: env:
NPM_TOKEN: ${{ github.event.inputs.npm_token }} NPM_TOKEN: ${{ github.event.inputs.npm_token }}
@ -111,8 +122,10 @@ jobs:
context: ./light context: ./light
file: ./light/Dockerfile file: ./light/Dockerfile
push: true 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 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-from: type=gha
cache-to: type=gha,mode=max cache-to: type=gha,mode=max

1
package-lock.json generated
View file

@ -33,6 +33,7 @@
"pmtiles": "3.0.7", "pmtiles": "3.0.7",
"proj4": "2.12.1", "proj4": "2.12.1",
"sanitize-filename": "1.6.3", "sanitize-filename": "1.6.3",
"semver": "^7.6.3",
"sharp": "0.33.5", "sharp": "0.33.5",
"tileserver-gl-styles": "2.0.0" "tileserver-gl-styles": "2.0.0"
}, },

View file

@ -42,6 +42,7 @@
"pmtiles": "3.0.7", "pmtiles": "3.0.7",
"proj4": "2.12.1", "proj4": "2.12.1",
"sanitize-filename": "1.6.3", "sanitize-filename": "1.6.3",
"semver": "^7.6.3",
"sharp": "0.33.5", "sharp": "0.33.5",
"tileserver-gl-styles": "2.0.0" "tileserver-gl-styles": "2.0.0"
}, },