From 1c738313acedf19f64039255125bd9740ca160a2 Mon Sep 17 00:00:00 2001 From: Kevin Schaul Date: Mon, 26 Aug 2024 13:46:12 -0500 Subject: [PATCH 01/10] Update desktop build to pull from this repo Previously the desktop build lived in a separate repo and had to download a released version of the maputnik editor source code. Now that both live in the same repo, the desktop version can simply run the maputnik build command and use those generated files. This commit also removes the ci-desktop workflow, which is not needed. The regular ci workflow already built the desktop version (this commit also fixes that build). Fixes #919 --- .github/workflows/ci-desktop.yml | 52 -------------------------------- .github/workflows/ci.yml | 17 +++-------- .gitignore | 1 + desktop/Makefile | 25 +++++++++------ desktop/README.md | 20 +++++------- desktop/maputnik.go | 4 +-- package.json | 1 + 7 files changed, 32 insertions(+), 88 deletions(-) delete mode 100644 .github/workflows/ci-desktop.yml diff --git a/.github/workflows/ci-desktop.yml b/.github/workflows/ci-desktop.yml deleted file mode 100644 index eb25689b3..000000000 --- a/.github/workflows/ci-desktop.yml +++ /dev/null @@ -1,52 +0,0 @@ -name: ci-desktop - -on: [ push ] - -jobs: - build: - - runs-on: ubuntu-latest - defaults: - run: - working-directory: ./desktop - - steps: - - uses: actions/checkout@v3 - - - name: Set up Go - uses: actions/setup-go@v3 - with: - go-version: 1.18 - - - name: Make - run: make - - - name: Test --help - run: ./bin/linux/maputnik --help - - - name: Test --version - run: ./bin/linux/maputnik --version - - - name: Get style - run: wget https://maputnik.github.io/osm-liberty/style.json - - - name: Test --watch - run: ./bin/linux/maputnik --watch --file style.json & sleep 5; kill $! - - - name: Artifacts/linux - uses: actions/upload-artifact@v3 - with: - name: maputnik-linux - path: ./desktop/bin/linux/ - - - name: Artifacts/darwin - uses: actions/upload-artifact@v3 - with: - name: maputnik-darwin - path: ./desktop/bin/darwin/ - - - name: Artifacts/windows - uses: actions/upload-artifact@v3 - with: - name: maputnik-windows - path: ./desktop/bin/windows/ diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 3492bcc20..7aa467dc7 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -66,33 +66,26 @@ jobs: go-version: ^1.19.x id: go - - name: Check out code into the Go module directory - uses: actions/checkout@v4 - with: - repository: maputnik/desktop - ref: master - path: ./src/github.com/maputnik/desktop/ - - - name: Make - run: cd src/github.com/maputnik/desktop/ && make + - name: Build desktop artifacts + run: npm run build-desktop - name: Artifacts/linux uses: actions/upload-artifact@v1 with: name: maputnik-linux - path: ./src/github.com/maputnik/desktop/bin/linux/ + path: ./desktop/bin/linux/ - name: Artifacts/darwin uses: actions/upload-artifact@v1 with: name: maputnik-darwin - path: ./src/github.com/maputnik/desktop/bin/darwin/ + path: ./desktop/bin/darwin/ - name: Artifacts/windows uses: actions/upload-artifact@v1 with: name: maputnik-windows - path: ./src/github.com/maputnik/desktop/bin/windows/ + path: ./desktop/bin/windows/ e2e-tests: name: "E2E tests using ${{ matrix.browser }}" diff --git a/.gitignore b/.gitignore index d465cc0ce..c5611399c 100644 --- a/.gitignore +++ b/.gitignore @@ -36,3 +36,4 @@ public /build /cypress/screenshots /dist/ +/desktop/version.go diff --git a/desktop/Makefile b/desktop/Makefile index 140d9d6b6..9a533ba09 100644 --- a/desktop/Makefile +++ b/desktop/Makefile @@ -1,21 +1,20 @@ SOURCEDIR=. SOURCES := $(shell find $(SOURCEDIR) -name '*.go') BINARY=maputnik -EDITOR_VERSION ?= v1.7.0 +DESKTOP_VERSION := 1.1.1 +EDITOR_VERSION := $(shell node -p "require('../package.json').version") GOPATH := $(if $(GOPATH),$(GOPATH),$(HOME)/go) GOBIN := $(if $(GOBIN),$(GOBIN),$(HOME)/go/bin) all: $(BINARY) -$(BINARY): $(GOBIN)/gox $(SOURCES) rice-box.go +$(BINARY): $(GOBIN)/gox $(SOURCES) version.go rice-box.go $(GOBIN)/gox -osarch "windows/amd64 linux/amd64 darwin/amd64" -output "bin/{{.OS}}/${BINARY}" -editor/create_folder: - mkdir -p editor - -editor/pull_release: editor/create_folder - # if the directory /home/runner/work/editor/editor/build/build exists, we assume that we are are running the makefile within the editor ci workflow - test -d /home/runner/work/editor/editor/build/build && echo "exists" && cd editor && cp -R /home/runner/work/editor/editor/build/build public/ || (echo "does not exist" && cd editor && rm -rf public && curl -L https://github.com/maputnik/editor/releases/download/$(EDITOR_VERSION)/public.zip --output public.zip && unzip public.zip && rm public.zip) +# Copy the current release into ./editor/maputnik so it can be +# embedded in the binary +editor/pull_release: + cp -r ../dist editor/maputnik $(GOBIN)/gox: go install github.com/mitchellh/gox@v1.0.1 @@ -23,9 +22,17 @@ $(GOBIN)/gox: $(GOBIN)/rice: go install github.com/GeertJohan/go.rice/rice@v1.0.3 +# Embed the current version numbers in the executable by writing version.go +.PHONY: version.go +version.go: + @echo "// DO NOT EDIT: Autogenerated by Makefile\n" > version.go + @echo "package main\n" >> version.go + @echo "const DesktopVersion = \"$(DESKTOP_VERSION)\"" >> version.go + @echo "const EditorVersion = \"$(EDITOR_VERSION)\"" >> version.go + rice-box.go: $(GOBIN)/rice editor/pull_release $(GOBIN)/rice embed-go .PHONY: clean clean: - rm -rf editor/public && rm -f rice-box.go && rm -rf bin + rm -rf editor && rm -f rice-box.go && rm -rf bin diff --git a/desktop/README.md b/desktop/README.md index b6b8baa69..e7592721d 100644 --- a/desktop/README.md +++ b/desktop/README.md @@ -1,18 +1,17 @@ -# Maputnik Desktop [![GitHub CI status](https://github.com/maputnik/desktop/workflows/ci/badge.svg)](https://github.com/maputnik/desktop/actions?query=workflow%3Aci) - +# Maputnik Desktop [![GitHub CI status](https://github.com/maplibre/maputnik/workflows/ci/badge.svg)][github-action-ci] --- A Golang based cross platform executable for integrating Maputnik locally. -This binary packages up the JavaScript and CSS bundle produced by [maputnik/editor](https://github.com/maputnik/desktop) +This binary packages up the JavaScript and CSS bundle produced by maputnik and embeds it in the program for easy distribution. It also allows exposing a local style file and work on it both in Maputnik and with your favorite editor. -Report issues on [maputnik/editor](https://github.com/maputnik/editor). +Report issues on [maplibre/maputnik](https://github.com/maplibre/maputnik). ## Install -You can download a single binary for Linux, OSX or Windows from [the latest releases of **maputnik/editor**](https://github.com/maputnik/editor/releases/latest). +You can download a single binary for Linux, OSX or Windows from [the latest releases of **maplibre/maputnik**](https://github.com/maplibre/maputnik/editor/releases/latest). ### Usage @@ -63,16 +62,11 @@ maputnik --static ./localFolder ### Build -Clone the repository. Make sure you clone it into the correct directory `$GOPATH/src/github.com/maputnik`. - -``` -git clone git@github.com:maputnik/desktop.git -``` - -Run `make` to install the 3rd party dependencies and build the `maputnik` binary embedding the editor. +From the root of the [maplibre/maputnik](https://github.com/maplibre/maputnik) project, install the deps and run the desktop-build command. ``` -make +npm install +npm run build-desktop ``` You should now find the `maputnik` binary in your `bin` directory. diff --git a/desktop/maputnik.go b/desktop/maputnik.go index 1442cb44e..543b1e19c 100644 --- a/desktop/maputnik.go +++ b/desktop/maputnik.go @@ -17,7 +17,7 @@ func main() { app := cli.NewApp() app.Name = "maputnik" app.Usage = "Server for integrating Maputnik locally" - app.Version = "Editor: 1.7.0; Desktop: 1.1.0" + app.Version = "Editor: " + EditorVersion + "; Desktop: " + DesktopVersion app.Flags = []cli.Flag{ &cli.StringFlag{ @@ -40,7 +40,7 @@ func main() { } app.Action = func(c *cli.Context) error { - gui := http.FileServer(rice.MustFindBox("editor/public").HTTPBox()) + gui := http.FileServer(rice.MustFindBox("editor").HTTPBox()) router := mux.NewRouter().StrictSlash(true) diff --git a/package.json b/package.json index 9556b3d30..73eabc62e 100644 --- a/package.json +++ b/package.json @@ -7,6 +7,7 @@ "scripts": { "start": "vite", "build": "tsc && vite build --base=/maputnik/", + "build-desktop": "tsc && vite build --base=/ && cd desktop && make", "i18n:refresh": "i18next 'src/**/*.{ts,tsx,js,jsx}'", "lint": "eslint ./src ./cypress --ext ts,tsx,js,jsx --report-unused-disable-directives --max-warnings 0", "test": "cypress run", From c579324d493bb721288c88377719db83eecb9669 Mon Sep 17 00:00:00 2001 From: Kevin Schaul Date: Mon, 26 Aug 2024 13:57:08 -0500 Subject: [PATCH 02/10] Fix desktop makefile, create dir before using --- desktop/Makefile | 1 + 1 file changed, 1 insertion(+) diff --git a/desktop/Makefile b/desktop/Makefile index 9a533ba09..b643b5ccc 100644 --- a/desktop/Makefile +++ b/desktop/Makefile @@ -14,6 +14,7 @@ $(BINARY): $(GOBIN)/gox $(SOURCES) version.go rice-box.go # Copy the current release into ./editor/maputnik so it can be # embedded in the binary editor/pull_release: + mkdir -p editor/maputnik cp -r ../dist editor/maputnik $(GOBIN)/gox: From d3b89c67c6d1000e6cd3f8555a1c959e2e5dbc2b Mon Sep 17 00:00:00 2001 From: Kevin Schaul Date: Mon, 26 Aug 2024 15:36:02 -0500 Subject: [PATCH 03/10] update actions versions --- .github/workflows/ci.yml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 7aa467dc7..9a06b2951 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -61,28 +61,28 @@ jobs: # Build and upload desktop CLI artifacts - name: Set up Go - uses: actions/setup-go@v3 + uses: actions/setup-go@v5 with: - go-version: ^1.19.x + go-version: ^1.23.x id: go - name: Build desktop artifacts run: npm run build-desktop - name: Artifacts/linux - uses: actions/upload-artifact@v1 + uses: actions/upload-artifact@v4 with: name: maputnik-linux path: ./desktop/bin/linux/ - name: Artifacts/darwin - uses: actions/upload-artifact@v1 + uses: actions/upload-artifact@v4 with: name: maputnik-darwin path: ./desktop/bin/darwin/ - name: Artifacts/windows - uses: actions/upload-artifact@v1 + uses: actions/upload-artifact@v4 with: name: maputnik-windows path: ./desktop/bin/windows/ From 2ebdaa47f3834d5459047dfc4aa66e2b40ec78d3 Mon Sep 17 00:00:00 2001 From: Kevin Schaul Date: Mon, 26 Aug 2024 15:36:53 -0500 Subject: [PATCH 04/10] another update to action version --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 9a06b2951..758bf93e7 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -54,7 +54,7 @@ jobs: - run: npm ci - run: npm run build - name: artifacts/maputnik - uses: actions/upload-artifact@v1 + uses: actions/upload-artifact@v4 with: name: maputnik path: dist From 1e86ad1061eb19f83ba6dfac280a39171295ab98 Mon Sep 17 00:00:00 2001 From: Kevin Schaul Date: Mon, 26 Aug 2024 16:10:32 -0500 Subject: [PATCH 05/10] fix desktop release dir --- desktop/Makefile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/desktop/Makefile b/desktop/Makefile index b643b5ccc..d7984937d 100644 --- a/desktop/Makefile +++ b/desktop/Makefile @@ -14,8 +14,8 @@ $(BINARY): $(GOBIN)/gox $(SOURCES) version.go rice-box.go # Copy the current release into ./editor/maputnik so it can be # embedded in the binary editor/pull_release: - mkdir -p editor/maputnik - cp -r ../dist editor/maputnik + mkdir -p editor + cp -r ../dist/* editor $(GOBIN)/gox: go install github.com/mitchellh/gox@v1.0.1 From a00009b2c7fd60d44c7c7ed5c02528281bd1f2aa Mon Sep 17 00:00:00 2001 From: Kevin Schaul Date: Mon, 26 Aug 2024 16:12:23 -0500 Subject: [PATCH 06/10] fix go cache for github workflow --- .github/workflows/ci.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 758bf93e7..49e0e5009 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -64,6 +64,7 @@ jobs: uses: actions/setup-go@v5 with: go-version: ^1.23.x + cache-dependency-path: desktop/go.sum id: go - name: Build desktop artifacts From c0374a5a3b4f81927161e7d5a5fec4f29fbd37ef Mon Sep 17 00:00:00 2001 From: Kevin Schaul Date: Wed, 28 Aug 2024 16:24:15 -0500 Subject: [PATCH 07/10] Add workflows to automate releases --- .github/workflows/create-bump-version-pr.yml | 39 +++++ .github/workflows/release.yml | 145 +++++++++++++++++++ .gitignore | 1 - CHANGELOG.md | 16 ++ README.md | 10 ++ build/README.md | 11 ++ build/bump-version-changelog.js | 29 ++++ build/release-notes.js | 51 +++++++ package-lock.json | 26 +--- package.json | 1 + 10 files changed, 306 insertions(+), 23 deletions(-) create mode 100644 .github/workflows/create-bump-version-pr.yml create mode 100644 .github/workflows/release.yml create mode 100644 CHANGELOG.md create mode 100644 build/README.md create mode 100644 build/bump-version-changelog.js create mode 100644 build/release-notes.js diff --git a/.github/workflows/create-bump-version-pr.yml b/.github/workflows/create-bump-version-pr.yml new file mode 100644 index 000000000..468b5b1ff --- /dev/null +++ b/.github/workflows/create-bump-version-pr.yml @@ -0,0 +1,39 @@ +name: Create bump version PR + +on: + workflow_dispatch: + inputs: + version: + description: Version to change to. + required: true + type: string + +jobs: + bump-version-pr: + name: Bump version PR + runs-on: ubuntu-latest + defaults: + run: + shell: bash + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: 0 + ref: main + + - name: Use Node.js from nvmrc + uses: actions/setup-node@v4 + with: + node-version-file: ".nvmrc" + + - name: Bump version + run: | + npm version --commit-hooks false --git-tag-version false ${{ inputs.version }} + ./build/bump-version-changelog.js ${{ inputs.version }} + + - name: Create Pull Request + uses: peter-evans/create-pull-request@v6 + with: + commit-message: Bump version to ${{ inputs.version }} + branch: bump-version-to-${{ inputs.version }} + title: Bump version to ${{ inputs.version }} diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 000000000..1902bb44c --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,145 @@ +name: Release + +on: + push: + branches: [main] + workflow_dispatch: + +jobs: + release-check: + name: Check if version changed + runs-on: ubuntu-latest + defaults: + run: + shell: bash + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: 0 + ref: main + + - name: Use Node.js from nvmrc + uses: actions/setup-node@v4 + with: + node-version-file: ".nvmrc" + + - name: Check if version has been updated + id: check + uses: EndBug/version-check@v2 + + outputs: + publish: ${{ steps.check.outputs.changed }} + + release: + name: Release + needs: release-check + if: ${{ needs.release-check.outputs.publish == 'true' }} + runs-on: ubuntu-latest + defaults: + run: + shell: bash + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: 0 + ref: main + + - name: Use Node.js from nvmrc + uses: actions/setup-node@v4 + with: + node-version-file: ".nvmrc" + registry-url: "https://registry.npmjs.org" + + - name: Set up Go for desktop build + uses: actions/setup-go@v5 + with: + go-version: ^1.23.x + cache-dependency-path: desktop/go.sum + id: go + + - name: Get version + id: package-version + uses: martinbeentjes/npm-get-version-action@v1.3.1 + + - name: Install + run: npm ci + + - name: Prepare release + id: prepare_release + run: | + RELEASE_TYPE=$(node -e "console.log(require('semver').prerelease('${{ steps.package-version.outputs.current-version }}') ? 'prerelease' : 'regular')") + echo "release_type=$RELEASE_TYPE" >> $GITHUB_OUTPUT + + - name: Build + run: | + npm run build + npm run build-desktop + + - name: Tag commit and push + id: tag_version + uses: mathieudutour/github-tag-action@v6.2 + with: + github_token: ${{ secrets.GITHUB_TOKEN }} + custom_tag: ${{ steps.package-version.outputs.current-version }} + + - name: Create Archives + run: | + zip -r dist dist + zip -r desktop desktop/bin/ + + - name: Build Release Notes + id: release_notes + if: ${{ steps.prepare_release.outputs.release_type == 'regular' }} + run: | + RELEASE_NOTES_PATH="${PWD}/release_notes.txt" + ./build/release-notes.js > ${RELEASE_NOTES_PATH} + echo "release_notes=${RELEASE_NOTES_PATH}" >> $GITHUB_OUTPUT + + - name: Create GitHub Release (regular) + id: create_regular_release + if: ${{ steps.prepare_release.outputs.release_type == 'regular' }} + uses: ncipollo/release-action@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + tag: ${{ steps.tag_version.outputs.new_tag }} + name: ${{ steps.tag_version.outputs.new_tag }} + bodyFile: ${{ steps.release_notes.outputs.release_notes }} + artifacts: "dist.zip,desktop.zip" + allowUpdates: true + draft: false + prerelease: false + + - name: Create GitHub Release (prerelease) + id: create_prerelease + if: ${{ steps.prepare_release.outputs.release_type == 'prerelease' }} + uses: actions/create-release@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + tag_name: ${{ steps.tag_version.outputs.new_tag }} + release_name: ${{ steps.tag_version.outputs.new_tag }} + draft: false + prerelease: true + + - name: Upload GitHub Release Assets (prerelease) - dist.zip + uses: actions/upload-release-asset@v1 + if: ${{ steps.prepare_release.outputs.release_type == 'prerelease' }} + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + upload_url: ${{ steps.create_prerelease.outputs.upload_url }} + asset_path: ./dist.zip + asset_name: dist.zip + asset_content_type: application/zip + + - name: Upload GitHub Release Assets (prerelease) - desktop.zip + uses: actions/upload-release-asset@v1 + if: ${{ steps.prepare_release.outputs.release_type == 'prerelease' }} + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + upload_url: ${{ steps.create_prerelease.outputs.upload_url }} + asset_path: ./desktop.zip + asset_name: desktop.zip + asset_content_type: application/zip diff --git a/.gitignore b/.gitignore index c5611399c..7fef4e637 100644 --- a/.gitignore +++ b/.gitignore @@ -33,7 +33,6 @@ node_modules public /errorShots /old -/build /cypress/screenshots /dist/ /desktop/version.go diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 000000000..e21613ad2 --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,16 @@ +## main + +### ✨ Features and improvements +- Add GitHub workflows for releasing new versions +- Update desktop build to pull from this repo (#922) +- _...Add new stuff here..._ + +### 🐞 Bug fixes +- _...Add new stuff here..._ + +## 2.0.0 +- Update MapLibre to version 4 (#872) + +## 1.7.0 +- See release notes at https://maputnik.github.io/blog/2020/04/23/release-v1.7.0 + diff --git a/README.md b/README.md index cc7bae537..9970de518 100644 --- a/README.md +++ b/README.md @@ -94,6 +94,16 @@ You can also see the tests as they run or select which suites to run by executin npm run cy:open ``` +## Release process + +1. Review [`CHANGELOG.md`](/CHANGELOG.md) + - Double-check that all changes included in the release are appropriately documented. + - To-be-released changes should be under the "main" header. + - Commit any final changes to the changelog. +2. Run [Create bump version PR](https://github.com/maplibre/maputnik/actions/workflows/create-bump-version-pr.yml) by manual workflow dispatch and set the version number in the input. This will create a PR that changes the changelog and `package.json` file to review and merge. +3. Once merged, an automatic process will kick in and creates a GitHub release and uploads release assets. + + ## Sponsors Thanks to the supporters of the **[Kickstarter campaign](https://www.kickstarter.com/projects/174808720/maputnik-visual-map-editor-for-mapbox-gl)**. This project would not be possible without these commercial and individual sponsors. diff --git a/build/README.md b/build/README.md new file mode 100644 index 000000000..9cf562fc7 --- /dev/null +++ b/build/README.md @@ -0,0 +1,11 @@ +# Build Scripts + +This folder holds common build scripts used by some of the Github workflows. + +The scripts are borrowed from [maplibre/maplibre-gl-js](https://github.com/maplibre/maplibre-gl-js/tree/bc70bc559cea5c987fa1b79fd44766cef68bbe28/build). + +## Generate Release Notes + +`bump-version-changelog.js` Used to update the changelog with the current notes, and set up a space for new notes + +`release-notes.js` Used to generate release notes when releasing a new version diff --git a/build/bump-version-changelog.js b/build/bump-version-changelog.js new file mode 100644 index 000000000..1c9795b8f --- /dev/null +++ b/build/bump-version-changelog.js @@ -0,0 +1,29 @@ +#!/usr/bin/env node + +/** + * This script updates the changelog.md file with the version given in the arguments + * It replaces ## main with ## + * Removes _...Add new stuff here..._ + * And adds on top a ## main with add stuff here. + * + * Copied from maplibre/maplibre-gl-js + * https://github.com/maplibre/maplibre-gl-js/blob/bc70bc559cea5c987fa1b79fd44766cef68bbe28/build/release-notes.js + */ + +import * as fs from 'fs'; + +const changelogPath = 'CHANGELOG.md'; +let changelog = fs.readFileSync(changelogPath, 'utf8'); +changelog = changelog.replace('## main', `## ${process.argv[2]}`); +changelog = changelog.replaceAll('- _...Add new stuff here..._\n', ''); +changelog = `## main + +### ✨ Features and improvements +- _...Add new stuff here..._ + +### 🐞 Bug fixes +- _...Add new stuff here..._ + +` + changelog; + +fs.writeFileSync(changelogPath, changelog, 'utf8'); diff --git a/build/release-notes.js b/build/release-notes.js new file mode 100644 index 000000000..c50a7b33e --- /dev/null +++ b/build/release-notes.js @@ -0,0 +1,51 @@ +#!/usr/bin/env node + +// Copied from maplibre/maplibre-gl-js +// https://github.com/maplibre/maplibre-gl-js/blob/bc70bc559cea5c987fa1b79fd44766cef68bbe28/build/release-notes.js + +import * as fs from 'fs'; +import semver from 'semver'; + +const changelogPath = 'CHANGELOG.md'; +const changelog = fs.readFileSync(changelogPath, 'utf8'); + +/* + Parse the raw changelog text and split it into individual releases. + + This regular expression: + - Matches lines starting with "## x.x.x". + - Groups the version number. + - Skips the (optional) release date. + - Groups the changelog content. + - Ends when another "## x.x.x" is found. +*/ +const regex = /^## (\d+\.\d+\.\d+.*?)\n(.+?)(?=\n^## \d+\.\d+\.\d+.*?\n)/gms; + +let releaseNotes = []; +let match; +// eslint-disable-next-line no-cond-assign +while (match = regex.exec(changelog)) { + releaseNotes.push({ + 'version': match[1], + 'changelog': match[2].trim(), + }); +} + +const latest = releaseNotes[0]; +const previous = releaseNotes[1]; + +// Print the release notes template. + +let header = 'Changes since previous version' +if (previous) { + header = `https://github.com/maplibre/maputnik + [Changes](https://github.com/maplibre/maputnik/compare/v${previous.version}...v${latest.version}) since [Maputnik v${previous.version}](https://github.com/maplibre/maputnik/releases/tag/v${previous.version})` +} +const templatedReleaseNotes = `${header} + +${latest.changelog} + +${semver.prerelease(latest.version) ? 'Pre-release version' : ''}`; + +// eslint-disable-next-line eol-last +process.stdout.write(templatedReleaseNotes.trimEnd()); diff --git a/package-lock.json b/package-lock.json index 8110f387a..44910feb0 100644 --- a/package-lock.json +++ b/package-lock.json @@ -107,6 +107,7 @@ "mocha": "^10.3.0", "postcss": "^8.4.38", "react-hot-loader": "^4.13.1", + "semver": "^7.6.3", "stylelint": "^16.2.1", "stylelint-config-recommended-scss": "^14.0.0", "stylelint-scss": "^6.2.1", @@ -9841,12 +9842,9 @@ } }, "node_modules/semver": { - "version": "7.6.0", - "resolved": "https://registry.npmjs.org/semver/-/semver-7.6.0.tgz", - "integrity": "sha512-EnwXhrlwXMk9gKu5/flx5sv/an57AkRplG3hTK68W7FRDN+k+OWBj65M7719OkA82XLBxrcX0KSHj+X5COhOVg==", - "dependencies": { - "lru-cache": "^6.0.0" - }, + "version": "7.6.3", + "resolved": "https://registry.npmjs.org/semver/-/semver-7.6.3.tgz", + "integrity": "sha512-oVekP1cKtI+CTDvHWYFUcMtsK/00wmAEfyqKfNdARm8u1wNVhSgaX7A8d4UuIlUI5e84iEwOhs7ZPYRmzU9U6A==", "bin": { "semver": "bin/semver.js" }, @@ -9854,22 +9852,6 @@ "node": ">=10" } }, - "node_modules/semver/node_modules/lru-cache": { - "version": "6.0.0", - "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-6.0.0.tgz", - "integrity": "sha512-Jo6dJ04CmSjuznwJSS3pUeWmd/H0ffTlkXXgwZi+eq1UCmqQwCh+eLsYOYCwY991i2Fah4h1BEMCx4qThGbsiA==", - "dependencies": { - "yallist": "^4.0.0" - }, - "engines": { - "node": ">=10" - } - }, - "node_modules/semver/node_modules/yallist": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/yallist/-/yallist-4.0.0.tgz", - "integrity": "sha512-3wdGidZyq5PB084XLES5TpOSRA3wjXAlIWMhum2kRcv/41Sn2emQ0dycQW4uZXLejwKvg6EsvbdlVL+FYEct7A==" - }, "node_modules/serialize-javascript": { "version": "6.0.0", "resolved": "https://registry.npmjs.org/serialize-javascript/-/serialize-javascript-6.0.0.tgz", diff --git a/package.json b/package.json index 73eabc62e..1bdfdb138 100644 --- a/package.json +++ b/package.json @@ -138,6 +138,7 @@ "mocha": "^10.3.0", "postcss": "^8.4.38", "react-hot-loader": "^4.13.1", + "semver": "^7.6.3", "stylelint": "^16.2.1", "stylelint-config-recommended-scss": "^14.0.0", "stylelint-scss": "^6.2.1", From f4e13c00dbddebe4abe32e4b35acbfdc641165cb Mon Sep 17 00:00:00 2001 From: Kevin Schaul Date: Wed, 28 Aug 2024 16:28:02 -0500 Subject: [PATCH 08/10] Add pull request template Copied from maplibre/maplibre-gl-js --- .github/PULL_REQUEST_TEMPLATE.md | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 .github/PULL_REQUEST_TEMPLATE.md diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md new file mode 100644 index 000000000..fa2de5e56 --- /dev/null +++ b/.github/PULL_REQUEST_TEMPLATE.md @@ -0,0 +1,11 @@ +## Launch Checklist + + + + + - [ ] Briefly describe the changes in this PR. + - [ ] Link to related issues. + - [ ] Include before/after visuals or gifs if this PR includes visual changes. + - [ ] Write tests for all new functionality. + - [ ] Add an entry to `CHANGELOG.md` under the `## main` section. + From cbbd948553d9a3e016d561687ef5bbb1fcf891eb Mon Sep 17 00:00:00 2001 From: Kevin Schaul Date: Thu, 29 Aug 2024 08:46:57 -0500 Subject: [PATCH 09/10] Remove prerelease code --- .github/workflows/release.yml | 43 +---------------------------------- build/release-notes.js | 3 --- package-lock.json | 26 +++++++++++++++++---- package.json | 2 -- 4 files changed, 23 insertions(+), 51 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 1902bb44c..3449477cc 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -64,12 +64,6 @@ jobs: - name: Install run: npm ci - - name: Prepare release - id: prepare_release - run: | - RELEASE_TYPE=$(node -e "console.log(require('semver').prerelease('${{ steps.package-version.outputs.current-version }}') ? 'prerelease' : 'regular')") - echo "release_type=$RELEASE_TYPE" >> $GITHUB_OUTPUT - - name: Build run: | npm run build @@ -89,15 +83,13 @@ jobs: - name: Build Release Notes id: release_notes - if: ${{ steps.prepare_release.outputs.release_type == 'regular' }} run: | RELEASE_NOTES_PATH="${PWD}/release_notes.txt" ./build/release-notes.js > ${RELEASE_NOTES_PATH} echo "release_notes=${RELEASE_NOTES_PATH}" >> $GITHUB_OUTPUT - - name: Create GitHub Release (regular) + - name: Create GitHub Release id: create_regular_release - if: ${{ steps.prepare_release.outputs.release_type == 'regular' }} uses: ncipollo/release-action@v1 env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} @@ -110,36 +102,3 @@ jobs: draft: false prerelease: false - - name: Create GitHub Release (prerelease) - id: create_prerelease - if: ${{ steps.prepare_release.outputs.release_type == 'prerelease' }} - uses: actions/create-release@v1 - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - with: - tag_name: ${{ steps.tag_version.outputs.new_tag }} - release_name: ${{ steps.tag_version.outputs.new_tag }} - draft: false - prerelease: true - - - name: Upload GitHub Release Assets (prerelease) - dist.zip - uses: actions/upload-release-asset@v1 - if: ${{ steps.prepare_release.outputs.release_type == 'prerelease' }} - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - with: - upload_url: ${{ steps.create_prerelease.outputs.upload_url }} - asset_path: ./dist.zip - asset_name: dist.zip - asset_content_type: application/zip - - - name: Upload GitHub Release Assets (prerelease) - desktop.zip - uses: actions/upload-release-asset@v1 - if: ${{ steps.prepare_release.outputs.release_type == 'prerelease' }} - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - with: - upload_url: ${{ steps.create_prerelease.outputs.upload_url }} - asset_path: ./desktop.zip - asset_name: desktop.zip - asset_content_type: application/zip diff --git a/build/release-notes.js b/build/release-notes.js index c50a7b33e..1d1699540 100644 --- a/build/release-notes.js +++ b/build/release-notes.js @@ -4,7 +4,6 @@ // https://github.com/maplibre/maplibre-gl-js/blob/bc70bc559cea5c987fa1b79fd44766cef68bbe28/build/release-notes.js import * as fs from 'fs'; -import semver from 'semver'; const changelogPath = 'CHANGELOG.md'; const changelog = fs.readFileSync(changelogPath, 'utf8'); @@ -45,7 +44,5 @@ const templatedReleaseNotes = `${header} ${latest.changelog} -${semver.prerelease(latest.version) ? 'Pre-release version' : ''}`; - // eslint-disable-next-line eol-last process.stdout.write(templatedReleaseNotes.trimEnd()); diff --git a/package-lock.json b/package-lock.json index 44910feb0..8110f387a 100644 --- a/package-lock.json +++ b/package-lock.json @@ -107,7 +107,6 @@ "mocha": "^10.3.0", "postcss": "^8.4.38", "react-hot-loader": "^4.13.1", - "semver": "^7.6.3", "stylelint": "^16.2.1", "stylelint-config-recommended-scss": "^14.0.0", "stylelint-scss": "^6.2.1", @@ -9842,9 +9841,12 @@ } }, "node_modules/semver": { - "version": "7.6.3", - "resolved": "https://registry.npmjs.org/semver/-/semver-7.6.3.tgz", - "integrity": "sha512-oVekP1cKtI+CTDvHWYFUcMtsK/00wmAEfyqKfNdARm8u1wNVhSgaX7A8d4UuIlUI5e84iEwOhs7ZPYRmzU9U6A==", + "version": "7.6.0", + "resolved": "https://registry.npmjs.org/semver/-/semver-7.6.0.tgz", + "integrity": "sha512-EnwXhrlwXMk9gKu5/flx5sv/an57AkRplG3hTK68W7FRDN+k+OWBj65M7719OkA82XLBxrcX0KSHj+X5COhOVg==", + "dependencies": { + "lru-cache": "^6.0.0" + }, "bin": { "semver": "bin/semver.js" }, @@ -9852,6 +9854,22 @@ "node": ">=10" } }, + "node_modules/semver/node_modules/lru-cache": { + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-6.0.0.tgz", + "integrity": "sha512-Jo6dJ04CmSjuznwJSS3pUeWmd/H0ffTlkXXgwZi+eq1UCmqQwCh+eLsYOYCwY991i2Fah4h1BEMCx4qThGbsiA==", + "dependencies": { + "yallist": "^4.0.0" + }, + "engines": { + "node": ">=10" + } + }, + "node_modules/semver/node_modules/yallist": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/yallist/-/yallist-4.0.0.tgz", + "integrity": "sha512-3wdGidZyq5PB084XLES5TpOSRA3wjXAlIWMhum2kRcv/41Sn2emQ0dycQW4uZXLejwKvg6EsvbdlVL+FYEct7A==" + }, "node_modules/serialize-javascript": { "version": "6.0.0", "resolved": "https://registry.npmjs.org/serialize-javascript/-/serialize-javascript-6.0.0.tgz", diff --git a/package.json b/package.json index 1bdfdb138..9556b3d30 100644 --- a/package.json +++ b/package.json @@ -7,7 +7,6 @@ "scripts": { "start": "vite", "build": "tsc && vite build --base=/maputnik/", - "build-desktop": "tsc && vite build --base=/ && cd desktop && make", "i18n:refresh": "i18next 'src/**/*.{ts,tsx,js,jsx}'", "lint": "eslint ./src ./cypress --ext ts,tsx,js,jsx --report-unused-disable-directives --max-warnings 0", "test": "cypress run", @@ -138,7 +137,6 @@ "mocha": "^10.3.0", "postcss": "^8.4.38", "react-hot-loader": "^4.13.1", - "semver": "^7.6.3", "stylelint": "^16.2.1", "stylelint-config-recommended-scss": "^14.0.0", "stylelint-scss": "^6.2.1", From ad2f13e1a1d1120763ca5e5c15b85c1b86569f10 Mon Sep 17 00:00:00 2001 From: Kevin Schaul Date: Thu, 29 Aug 2024 08:51:26 -0500 Subject: [PATCH 10/10] Re-add build-desktop npm script --- package.json | 1 + 1 file changed, 1 insertion(+) diff --git a/package.json b/package.json index 9556b3d30..73eabc62e 100644 --- a/package.json +++ b/package.json @@ -7,6 +7,7 @@ "scripts": { "start": "vite", "build": "tsc && vite build --base=/maputnik/", + "build-desktop": "tsc && vite build --base=/ && cd desktop && make", "i18n:refresh": "i18next 'src/**/*.{ts,tsx,js,jsx}'", "lint": "eslint ./src ./cypress --ext ts,tsx,js,jsx --report-unused-disable-directives --max-warnings 0", "test": "cypress run",