Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Release automation #95

Merged
merged 70 commits into from
Mar 24, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
70 commits
Select commit Hold shift + click to select a range
a7b8ce1
v1.13.0-rc.6
petr-pokorny-1 Mar 11, 2021
79e80f9
MapLibre 1.13.1 baseline - ignoring failed tests
petr-pokorny-1 Mar 11, 2021
567161b
Initial version of release workflow
petr-pokorny-1 Mar 11, 2021
d62fbc0
Release workflow tests
petr-pokorny-1 Mar 11, 2021
1613255
Testing release workflow
petr-pokorny-1 Mar 11, 2021
5b9385c
Package updates
petr-pokorny-1 Mar 11, 2021
68292e6
lint issues
petr-pokorny-1 Mar 11, 2021
450c69d
Testing release build
petr-pokorny-1 Mar 11, 2021
8161010
Excluding tests which wont run on GH runner without GPU
petr-pokorny-1 Mar 11, 2021
37d432e
Lint issue
petr-pokorny-1 Mar 11, 2021
96ac42d
Testing release script
petr-pokorny-1 Mar 11, 2021
618bd70
Testing release script
petr-pokorny-1 Mar 11, 2021
f077746
testing release script
petr-pokorny-1 Mar 11, 2021
53806c6
Cleanup
petr-pokorny-1 Mar 11, 2021
889186e
Fixes
petr-pokorny-1 Mar 11, 2021
19e2638
Added missing command
petr-pokorny-1 Mar 11, 2021
dbd7c25
Fixes
petr-pokorny-1 Mar 11, 2021
7a62162
Fixes
petr-pokorny-1 Mar 11, 2021
438ca86
Fix for windows runner
petr-pokorny-1 Mar 11, 2021
beb350a
Another attempt
petr-pokorny-1 Mar 11, 2021
2e79d41
Another attempt
petr-pokorny-1 Mar 11, 2021
2012b30
Another attempt
petr-pokorny-1 Mar 11, 2021
9a1fc05
Another attempt
petr-pokorny-1 Mar 11, 2021
7501697
Tests
petr-pokorny-1 Mar 11, 2021
9f1dbfa
Test
petr-pokorny-1 Mar 11, 2021
d9c62b7
Another attempt
petr-pokorny-1 Mar 11, 2021
c5c7287
Another attempt
petr-pokorny-1 Mar 11, 2021
e70accc
Another attempt
petr-pokorny-1 Mar 11, 2021
f026083
Testing on self-hosted runner
petr-pokorny-1 Mar 11, 2021
ada1261
Fixes for windows runner
petr-pokorny-1 Mar 11, 2021
d4b1c7d
Back to default runner
petr-pokorny-1 Mar 11, 2021
d403708
Fixes
petr-pokorny-1 Mar 11, 2021
0cc752b
v1.13.1
petr-pokorny-1 Mar 11, 2021
e9f8a93
Fixes
petr-pokorny-1 Mar 11, 2021
6cc62fb
Fixes
petr-pokorny-1 Mar 11, 2021
0a7ade6
Fixes
petr-pokorny-1 Mar 11, 2021
ddc926b
testing release
petr-pokorny-1 Mar 11, 2021
8c9d346
Fixes
petr-pokorny-1 Mar 11, 2021
5c7c9ad
testing release script
petr-pokorny-1 Mar 11, 2021
c79f1fb
Testing release script
petr-pokorny-1 Mar 11, 2021
5dae456
Version Bump
Mar 11, 2021
b0612d8
teting build
petr-pokorny-1 Mar 11, 2021
33d3af0
Testing build
petr-pokorny-1 Mar 11, 2021
5d8e72f
Version Bump
Mar 11, 2021
6e8fa65
Testing build
petr-pokorny-1 Mar 11, 2021
91fbe24
Merge branch 'release-automation' of https://github.com/petr-pokorny-…
petr-pokorny-1 Mar 11, 2021
3f6d068
Version Bump
Mar 11, 2021
5166571
Testing build
petr-pokorny-1 Mar 11, 2021
162691a
Merge branch 'release-automation' of https://github.com/petr-pokorny-…
petr-pokorny-1 Mar 11, 2021
fa35ace
Version Bump
Mar 11, 2021
ee7ad88
Another test
petr-pokorny-1 Mar 11, 2021
75c51cb
Merge branch 'release-automation' of https://github.com/petr-pokorny-…
petr-pokorny-1 Mar 11, 2021
0521545
Version Bump
Mar 11, 2021
cbc8e90
Making tarball check non-interactive
petr-pokorny-1 Mar 11, 2021
e96a58f
Merge branch 'release-automation' of https://github.com/petr-pokorny-…
petr-pokorny-1 Mar 11, 2021
8f8fdbb
another test & trabal check fix
petr-pokorny-1 Mar 11, 2021
fe0ee51
Version Bump
Mar 11, 2021
5e638e8
Removing debug code & clean up
petr-pokorny-1 Mar 11, 2021
a9f0ef7
Merge branch 'release-automation' of https://github.com/petr-pokorny-…
petr-pokorny-1 Mar 11, 2021
4aa3165
Removing vscode stuff
petr-pokorny-1 Mar 11, 2021
78f6662
Remove formatting changes
petr-pokorny-1 Mar 11, 2021
157b14a
Added missing packages
petr-pokorny-1 Mar 11, 2021
a3d3d7d
Revert formating changes
petr-pokorny-1 Mar 11, 2021
a50c98b
lint issues
petr-pokorny-1 Mar 11, 2021
7708fd3
Update package.json
petr-pokorny-1 Mar 12, 2021
f07eb2c
Update build/version-utils.js
petr-pokorny-1 Mar 12, 2021
ae0bd9b
Update test/ignores.json
petr-pokorny-1 Mar 12, 2021
6c315b3
PR review fixes
petr-pokorny-1 Mar 12, 2021
1a6b3bc
Addressing PR review
petr-pokorny-1 Mar 15, 2021
ebe0154
Changelog update for v1.14.0
petr-pokorny-1 Mar 24, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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