Skip to content

Commit

Permalink
Release automation (#95)
Browse files Browse the repository at this point in the history
* v1.13.0-rc.6

* MapLibre 1.13.1 baseline - ignoring failed tests

* Initial version of release workflow

* Release workflow tests

* Testing release workflow

* Package updates

* lint issues

* Testing release build

* Excluding tests which wont run on GH runner without GPU

* Lint issue

* Testing release script

* Testing release script

* testing release script

* Cleanup

* Fixes

* Added missing command

* Fixes

* Fixes

* Fix for windows runner

* Another attempt

* Another attempt

* Another attempt

* Another attempt

* Tests

* Test

* Another attempt

* Another attempt

* Another attempt

* Testing on self-hosted runner

* Fixes for windows runner

* Back to default runner

* Fixes

* v1.13.1

* Fixes

* Fixes

* Fixes

* testing release

* Fixes

* testing release script

* Testing release script

* Version Bump

* teting build

* Testing build

* Version Bump

* Testing build

* Version Bump

* Testing build

* Version Bump

* Another test

* Version Bump

* Making tarball check non-interactive

* another test & trabal check fix

* Version Bump

* Removing debug code & clean up

* Removing vscode stuff

* Remove formatting changes

* Added missing packages

* Revert formating changes

* lint issues

* Update package.json

Co-authored-by: Yuri Astrakhan <[email protected]>

* Update build/version-utils.js

Co-authored-by: Yuri Astrakhan <[email protected]>

* Update test/ignores.json

Co-authored-by: Yuri Astrakhan <[email protected]>

* PR review fixes

* Addressing PR review

* Changelog update for v1.14.0

Co-authored-by: MapLibre <[email protected]>
Co-authored-by: Yuri Astrakhan <[email protected]>
  • Loading branch information
3 people authored Mar 24, 2021
1 parent 256d1b8 commit 12915e3
Show file tree
Hide file tree
Showing 9 changed files with 392 additions and 6 deletions.
193 changes: 193 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,193 @@
# To trigger the workflow, tag sources and push
# git tag -a v1.13.1 -m "version 1.13.1"
# to tag old revision:
# git tag -a v1.13.0-beta.1 2112766 -m "version 1.13.0-beta.1"
# git tag -a v1.13.0 f87090b -m "version 1.13.0"
# git push --tags
name: Release

on:
workflow_dispatch:
push:
tags:
- v*
paths-ignore:
- ".github/**"
- "**/*.md"

jobs:
lint_build_test:
name: Build, Lint and Test
runs-on: windows-latest
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0

- name: Use Node.js 10 x64
uses: actions/setup-node@v2
with:
node-version: 10
architecture: x64
registry-url: 'https://registry.npmjs.org'

- name: Install
run: yarn install --frozen-lockfile

- name: Validate version tag
run: |
node build\version-utils.js validate-latest-tag
- name: Prepare
id: prepare
run: |
$LatestVersionTag=$(node build\version-utils.js latest-version-tag)
echo "Latest version tag=$LatestVersionTag"
echo "::set-output name=version_tag::$LatestVersionTag"
- name: Ensure correct revision
run: |
git checkout tags/${{ steps.prepare.outputs.version_tag }}
- name: Lint
run: |
yarn run lint
yarn run lint-docs
yarn run lint-css
- name: Test
run: |
yarn run test-flow
yarn run test-unit
yarn run test-render
yarn run test-query
yarn run test-expressions
release:
name: Release
runs-on: ubuntu-latest
needs: lint_build_test
defaults:
run:
shell: bash
steps:

- uses: actions/checkout@v2
with:
fetch-depth: 0

- name: Use Node.js 10 x64
uses: actions/setup-node@v2
with:
node-version: 10
architecture: x64
registry-url: 'https://registry.npmjs.org'

- name: Install
run: yarn install --frozen-lockfile

- name: Validate version tag
run: |
build/version-utils.js validate-latest-tag
- name: Prepare release
id: prepare_release
run: |
echo ::set-output name=version_tag::$( build/version-utils.js latest-version-tag)
echo ::set-output name=version::$( build/version-utils.js version-from-tags)
echo ::set-output name=release_type::$( build/version-utils.js version-type )
- name: Ensure correct revision
run: |
git checkout tags/${{ steps.prepare_release.outputs.version_tag }}
- name: Build
run: |
yarn run build-prod-min
yarn run build-css
- name: Create Archive
run: |
zip -r dist dist
- 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 ::set-output name=release_notes::${RELEASE_NOTES_PATH}
- name: Create GitHub Release (regular)
id: create_regular_release
if: ${{ steps.prepare_release.outputs.release_type == 'regular' }}
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ steps.prepare_release.outputs.version_tag }}
release_name: ${{steps.prepare_release.outputs.version_tag }}
body_path: ${{ steps.release_notes.outputs.release_notes }}
draft: false
prerelease: false

- name: Upload GitHub Release Assets (regular)
if: ${{ steps.prepare_release.outputs.release_type == 'regular' }}
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_regular_release.outputs.upload_url }}
asset_path: ./dist.zip
asset_name: dist.zip
asset_content_type: application/zip

- 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.prepare_release.outputs.version_tag }}
release_name: ${{steps.prepare_release.outputs.version_tag }}
draft: false
prerelease: true

- name: Upload GitHub Release Assets (prerelease)
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: Clean up
if: ${{ steps.prepare_release.outputs.release_type == 'regular' }}
run: |
rm -f ${{ steps.prepare_release.outputs.release_notes }}
- name: Update NPM Package Version
run: |
yarn version --non-interactive --no-git-tag-version --new-version ${{ steps.prepare_release.outputs.version }}
- name: Commit & Push updated version
run: |
git add package.json
if [[ -n "$(git status --porcelain)" ]]; then
git config --local user.email "[email protected]"
git config --local user.name "MapLibre"
git commit -m "Version Bump"
git push origin HEAD:main
else
echo "no changes";
fi
- name: Publish NPM package
run: |
yarn publish --non-interactive
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}

26 changes: 23 additions & 3 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,30 @@
## maplibre-gl-js 1.13.0
## main

### Features and improvements

- Add new stuff here

### 🐞 Bug fixes

- Add fixed bugs here

## 1.14.0

### Features and improvements

- New logo

### 🐞 Bug fixes

- Fix a bug where mapbox-gl-js is no longer licensed as open source, but we owe immeasurable gratitude to Mapbox for releasing all their initial code to the community under BSD-3 license.```
- Rename SVGs mapboxgl-ctrl-*.svg to maplibregl (#85)
- fix ImageSource not working in FF/Safari (#87)
- Update HTML debug files to use MapLibre in titles (#84)
- fix CI checksize job to use maplibre name (#86)
- Move output files from mapbox.* to maplibre.* (#75)
- Remove mapbox specifics and branding from .github (#64)
- Fix a bug where mapbox-gl-js is no longer licensed as open source, but we owe immeasurable gratitude to Mapbox for releasing all their initial code to the community under BSD-3 license.

## mapbox-gl-js 1.13.0
## 1.13.0

### ✨ Features and improvements

Expand Down
12 changes: 11 additions & 1 deletion build/diff-tarball.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,13 @@ npmContent('maplibre-gl').then(function(last_version_files) {
packlist({ path: '.' }).then(function(new_version_files) {
new_version_files = new_version_files.map(file => file.replace(/\/\/+/g, '/'));
let diff_new = new_version_files.filter(x => !last_version_files.includes(x));
let diff_last = last_version_files.filter(x => !new_version_files.includes(x));

// excludes folder names which caused this script
// to fail with message: xx files are about to be deleted in the new tarball
// i.e. src/ui was reported but src/ui/anchor.js, src/ui/camera.js, etc are included indeed
let diff_last = last_version_files
.filter(x => !new_version_files.includes(x) && !new_version_files.some(y => y.startsWith(x)));

console.log(`${diff_new.length} files are about to be added in the new tarball`)
diff_new.forEach(file => {
console.log('+', file);
Expand All @@ -14,5 +20,9 @@ npmContent('maplibre-gl').then(function(last_version_files) {
diff_last.forEach(file => {
console.log('-', file);
});

if (diff_new.length > 0 || diff_last.length > 0) {
console.log('\x1b[31m%s\x1b[0m', 'Number of files in tarball will change!');
}
});
});
73 changes: 73 additions & 0 deletions build/release-notes.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
#!/usr/bin/env node

const fs = require('fs');
const execSync = require('child_process').execSync;
const ejs = require('ejs');
const _ = require('lodash');
const semver = require('semver');

const changelogPath = 'CHANGELOG.md';
const changelog = fs.readFileSync(changelogPath, 'utf8');

let currentVersion = execSync('git describe --tags --match=v*.*.* --abbrev=0')
.toString()
.trim()
.replace('v', '');

let gitTags = execSync('git tag --list v*.*.*')
.toString()
.split('\n')
.map(function(tag) {
tag = tag.replace('v', '').trim();
return semver.clean(tag);
});
let previousVersion = semver.maxSatisfying(gitTags, "<" + currentVersion, { includePrerelease: false });

/*
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 = [];
// eslint-disable-next-line no-cond-assign
while (match = regex.exec(changelog)) {
releaseNotes.push({
'version': match[1],
'changelog': match[2].trim(),
});
}

/*
Match the current tag with the most appropriate release notes.
*/
const versionsInReleaseNotes = _.map(releaseNotes, 'version');
const bestReleaseNotesForCurrentVersion = semver.minSatisfying(versionsInReleaseNotes, ">=" + currentVersion);
const currentReleaseNotes = _.find(releaseNotes, { version: bestReleaseNotesForCurrentVersion });

if (!currentReleaseNotes) {
console.error('Could not find a release section satisfying %s in %s — did you forget to rename the "main" section to %s?', currentVersion, changelogPath, currentVersion.split("-")[0]);
process.exit(1); // eslint-disable-line no-process-exit
}

/*
Fill and print the release notes template.
*/
let templatedReleaseNotes;

templatedReleaseNotes = ejs.render(fs.readFileSync('build/release-notes.md.ejs', 'utf8'), {
'CURRENTVERSION': currentVersion,
'PREVIOUSVERSION': previousVersion,
'CHANGELOG': currentReleaseNotes.changelog,
'isPrerelease': semver.prerelease(currentVersion)
});
templatedReleaseNotes = templatedReleaseNotes.trimEnd();

// eslint-disable-next-line eol-last
process.stdout.write(templatedReleaseNotes);
8 changes: 8 additions & 0 deletions build/release-notes.md.ejs
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
https://github.com/maplibre/maplibre-gl-js
[Changes](https://github.com/maplibre/maplibre-gl-js/compare/v<%-PREVIOUSVERSION%>...v<%-CURRENTVERSION%>) since [MapLibre GL JS v<%-PREVIOUSVERSION%>](https://github.com/maplibre/releases/tag/v<%-PREVIOUSVERSION%>):

<%-CHANGELOG-%>

<% if (isPrerelease) { %>
Pre-release version
<% } -%>
Loading

0 comments on commit 12915e3

Please sign in to comment.