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
This commit is contained in:
Andrew Calcutt 2025-01-10 18:46:19 -05:00 committed by GitHub
parent 4a783446cd
commit c30d799811
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 95 additions and 23 deletions

View file

@ -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

7
CHANGELOG.md Normal file
View file

@ -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

View file

@ -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 <update_type> with one of the semantic versioning release types (prerelease, prepatch, preminor, premajor, patch, minor, major):
npm version <update_type> --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 ## <VERSION> 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.

1
package-lock.json generated
View file

@ -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"
},

View file

@ -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"
},