Skip to content

Commit

Permalink
chore(release): update contributors when publishing a release (karma-…
Browse files Browse the repository at this point in the history
…runner#3552)

Grunt release publishing [used to](https://github.com/karma-runner/karma/blob/master/gruntfile.js#L103) update `contributors` in `package.json`, but this feature has been lost during the migration to `semantic-release`. This PR restores the same logic in `semantic-release` plugin.

I considered using [semantic-release-contributors](https://www.npmjs.com/package/semantic-release-contributors) first, but it has couple of issues:
- it only adds contributors since last release, so can not restore contributors, who were missed while semantic-release was used for publishing
- it parses author data from commit and then serializes it back, which in some cases produces wrong results (e.g. David Jensen <david@frode.(none)> becomes an empty string, because parsing silently fails)

Because of the above issues I've re-implemented logic from the [Grunt plugin](https://github.com/vojtajina/grunt-npm/blob/master/tasks/npm.js#L90) as a semantic-release plugin and applied changes produced by it.

There are a many changes to existing contributors, because current logic sorts them by the amount of commits.
  • Loading branch information
devoto13 authored and anthony-redFox committed May 5, 2023
1 parent 81e51ae commit 1378b44
Show file tree
Hide file tree
Showing 3 changed files with 73 additions and 38 deletions.
87 changes: 49 additions & 38 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,109 +27,112 @@
"dignifiedquire <friedel.ziegelmayer@gmail.com>",
"johnjbarton <johnjbarton@johnjbarton.com>",
"greenkeeperio-bot <support@greenkeeper.io>",
"Yaroslav Admin <devoto13@gmail.com>",
"Karma Bot <karmarunnerbot@gmail.com>",
"Maksim Ryzhikov <rv.maksim@gmail.com>",
"ukasz Usarz <lukasz.usarz@gmail.com>",
"Yaroslav Admin <devoto13@gmail.com>",
"Christian Budde Christensen <budde377@gmail.com>",
"taichi <ryushi@gmail.com>",
"Wesley Cho <wesley.cho@gmail.com>",
"semantic-release-bot <semantic-release-bot@martynus.net>",
"Liam Newman <bitwiseman@gmail.com>",
"lukasz <lukasz.usarz@gmail.com>",
"Anton <anton.redfox@gmail.com>",
"Todd Wolfson <todd@twolfson.com>",
"Michał Gołębiowski-Owczarek <m.goleb@gmail.com>",
"Mark Trostler <mark@zzo.com>",
"Ciro Nunes <ciroanunes@gmail.com>",
"Shyam Seshadri <shyamseshadri@gmail.com>",
"Tim Cuthbertson <tim@gfxmonk.net>",
"Robo <hop2deep@gmail.com>",
"Christian Budde Christensen <christi@n-bud.de>",
"Pawel Kozlowski <pkozlowski.opensource@gmail.com>",
"Christian Budde Christensen <christi@n-bud.de>",
"Shyam Seshadri <shyamseshadri@gmail.com>",
"Robo <hop2deep@gmail.com>",
"Mourad <mourad@elmaouchi.com>",
"Daniel Compton <desk@danielcompton.net>",
"Mark Ethan Trostler <mark@zzo.com>",
"Kim Joar Bekkelund <kjbekkelund@gmail.com>",
"vivganes <vivek@vivekganesan.com>",
"joshjb84 <joshjb84@hotmail.com>",
"Georgii Dolzhykov <thorn.mailbox@gmail.com>",
"Anton <anton.redfox@gmail.com>",
"Brian Di Palma <offler@gmail.com>",
"Nick Malaguti <nmalaguti@palantir.com>",
"Kim Joar Bekkelund <kjbekkelund@gmail.com>",
"joshjb84 <joshjb84@hotmail.com>",
"David Souther <davidsouther@gmail.com>",
"Brian Di Palma <offler@gmail.com>",
"Matthias Oßwald <1410947+matz3@users.noreply.github.com>",
"Daniel Aleksandersen <code@daniel.priv.no>",
"Jake Champion <jakechampion.jake2@googlemail.com>",
"Marcello Nuccio <marcello.nuccio@gmail.com>",
"Pieter Mees <pietermees@users.noreply.github.com>",
"Brian Ford <btford@umich.edu>",
"Aymeric Beaumet <aymeric@beaumet.me>",
"Andrew Martin <sublimino@gmail.com>",
"Iristyle <Iristyle@github>",
"ywong <wongyok@gmail.com>",
"Chris Casola <chriscasola@gmail.com>",
"Aymeric Beaumet <aymeric@beaumet.me>",
"Jeff Jewiss <jeffjewiss@gmail.com>",
"Pieter Mees <pietermees@users.noreply.github.com>",
"Jake Champion <jakechampion.jake2@googlemail.com>",
"Marcello Nuccio <marcello.nuccio@gmail.com>",
"Jérémy Judéaux <jeremy.judeaux@volune.net>",
"Andrew Martin <sublimino@gmail.com>",
"Brian Ford <btford@umich.edu>",
"Chris Hunt <chrahunt@gmail.com>",
"Ilya Volodin <ivolodin@vistaprint.com>",
"David Souther <davidsouther@gmail.com>",
"pavelgj <pavelgj@gmail.com>",
"sylvain-hamel <sylvainhamel0@gmail.com>",
"Ilya Volodin <ivolodin@vistaprint.com>",
"ywong <wongyok@gmail.com>",
"Iristyle <Iristyle@github>",
"Chris Hunt <chrahunt@gmail.com>",
"Robert Stein <SteinRobert@users.noreply.github.com>",
"ngiebel <ngiebel@starkinvestments.com>",
"Robin Liang <robin.gnail@gmail.com>",
"rdodev <rubenoz@gmail.com>",
"Matt Lewis <matthew.lewis@socialsignin.co.uk>",
"Ruben Bridgewater <ruben.bridgewater@fintura.de>",
"Ezra Brooks <ezra.m.brooks@gmail.com>",
"David Herges <dherges@users.noreply.github.com>",
"Réda Housni Alaoui <reda.housnialaoui@gmail.com>",
"Filipe Guerra <alias.mac@gmail.com>",
"Aseem Bansal <aseembansal@live.com>",
"Ruben Bridgewater <ruben.bridgewater@fintura.de>",
"Bryan Smith <bryanrsmith@gmail.com>",
"Sammy Jelin <sjelin@gmail.com>",
"Réda Housni Alaoui <reda.housnialaoui@gmail.com>",
"David Pärsson <david@parsson.se>",
"Sergei Startsev <ai@programist.ru>",
"Sammy Jelin <sjelin@gmail.com>",
"Jonas Pommerening <jonas.pommerening@aixigo.de>",
"Sergei Startsev <ai@programist.ru>",
"Sergey Simonchik <sergey.simonchik@gmail.com>",
"Sergey Simonchik <sergey.simonchik@jetbrains.com>",
"Shane Russell <shane1337@gmail.com>",
"Jonathan Freeman <freethejazz@gmail.com>",
"Josh <joshhunt180@gmail.com>",
"Bulat Shakirzyanov <mallluhuct@gmail.com>",
"Shane Russell <shane1337@gmail.com>",
"Josh <joshhunt180@gmail.com>",
"Andrew Morris <voltrevo@gmail.com>",
"Greenkeeper <support@greenkeeper.io>",
"Stefan Dragnev <dragnev@telerik.com>",
"Steve Mao <maochenyan@gmail.com>",
"Steve Mao <steve.mao@healthinteract.com.au>",
"Steve Van Opstal <stevevanopstal@gmail.com>",
"Sylvain Hamel <sylvainhamel0@gmail.com>",
"KJ Tsanaktsidis <kjtsanaktsidis@gmail.com>",
"Nico Jansen <jansennico@gmail.com>",
"Terry <zhangwenlp@vip.qq.com>",
"Andrew Morris <voltrevo@gmail.com>",
"Cyrus Chan <chan1cyrus2@gmail.com>",
"Thomas Parisot <thomas@oncle-tom.net>",
"Hugues Malphettes <hmalphettes@gmail.com>",
"Tom Erik Støwer <tomerik@getkahoot.com>",
"Thomas Parisot <thomas@oncle-tom.net>",
"Igor Minar <igor@angularjs.org>",
"Keen Yee Liau <kyliau@google.com>",
"Igor Minar <iiminar@gmail.com>",
"Tom Erik Støwer <tomerik@getkahoot.com>",
"Kelly Jensen <kellyrayj@gmail.com>",
"Ilya Goncharov <ilgonmic@gmail.com>",
"Kevin Huang <kevinziwenhuang@gmail.com>",
"Kevin WENNER <kevin.wenner@massmotionmedia.com>",
"Parashuram <code@r.nparashuram.com>",
"Vivek Ganesan <caliberoviv@gmail.com>",
"Vladimir Starkov <iamstarkov@users.noreply.github.com>",
"Pat Tullmann <pt@bebop.co>",
"Kevin WENNER <kevin.wenner@massmotionmedia.com>",
"ChangZhuo Chen (陳昌倬) <czchen@gmail.com>",
"PatrickJS <github@gdi2290.com>",
"Levi Thomason <me@levithomason.com>",
"ChangZhuo Chen (陳昌倬) <czchen@gmail.com>",
"comdiv <fagim.sadykov@gmail.com>",
"Aseem Bansal <aseembansal@live.com>",
"Luke Page <luke.a.page@gmail.com>",
"comdiv <fagim.sadykov@gmail.com>",
"James Ford <jford@psyked.co.uk>",
"James Talmage <james@talmage.io>",
"DarthCharles <carlos.darth@gmail.com>",
"Richard Harrington <rwharrington87@gmail.com>",
"karmarunnerbot <karmarunnerbot@gmail.com>",
"DarthCharles <carlos.darth@gmail.com>",
"Roarke Gaskill <roarke.gaskill@gmail.com>",
"Ethan J. Brown <ethan_j_brown@hotmail.com>",
"Ezra Brooks <ezra.m.brooks@gmail.com>",
"Roarke Gaskill <roarke.gaskill@gmail.com>",
"Matt Lewis <matthew.lewis@socialsignin.co.uk>",
"David Herges <dherges@users.noreply.github.com>",
"Karol Fabjańczuk <karol.fabjanczuk@lemondemon.pl>",
"Karolis Narkevicius <karolis.n@gmail.com>",
"Keats <balthek@gmail.com>",
Expand All @@ -144,6 +147,7 @@
"M1xA <AnyCPU@users.noreply.github.com>",
"Magnus Markling <github@markling.com>",
"Manfred Stock <m@nfred.ch>",
"Manoel <manoel.lobo@gmail.com>",
"Marko Anastasov <marko@renderedtext.com>",
"Martin Geisler <martin@geisler.net>",
"Martin Jul <martin@mjul.com>",
Expand All @@ -156,6 +160,7 @@
"Matthias Oßwald <matz3@users.noreply.github.com>",
"Matti Paksula <matti.paksula@iki.fi>",
"Mattijs Kneppers <mattijs@arttech.nl>",
"Max Waterman <davidmaxwaterman@fastmail.co.uk>",
"Merott Movahedi <merott@merott.com>",
"Merrick Christensen <merrick.christensen@gmail.com>",
"Michael Krotscheck <krotscheck@gmail.com>",
Expand All @@ -170,9 +175,9 @@
"Nick McCurdy <nick@nickmccurdy.com>",
"Nick Payne <nick@kurai.co.uk>",
"Nick Williams <mr.nicksta@gmail.com>",
"Nico Jansen <jansennico@gmail.com>",
"Nicolas Artman <nicolasartman@users.noreply.github.com>",
"Nicolas Ferrero <ferrero.nicolas@gmail.com>",
"Nikita Balakirev <balakirevnikita@yandex.ru>",
"Nir Moav <nirmoav@users.noreply.github.com>",
"Nish <nishantpatel611@gmail.com>",
"Nuno Job <nunojobpinto@gmail.com>",
Expand All @@ -198,6 +203,7 @@
"Peter Yates <pd.yates@gmail.com>",
"Philip Harrison <philip@mailharrison.com>",
"Pierre Vanduynslager <pierre.denis.vanduynslager@gmail.com>",
"Piotr Błażejewicz (Peter Blazejewicz) <peterblazejewicz@users.noreply.github.com>",
"Piper Chester <piperchester@users.noreply.github.com>",
"Rafal Lindemann <rl@stamina.pl>",
"Remy Sharp <remy@remysharp.com>",
Expand Down Expand Up @@ -234,6 +240,8 @@
"Thai Pangsakulyanont @ Taskworld <thai.p@taskworld.com>",
"Thijs Triemstra <info@collab.nl>",
"Thomas Parisot <thomas.parisot@bbc.co.uk>",
"Tim Gates <tim.gates@iress.com>",
"Tim Hartman <tbhartman@gmail.com>",
"Tim Olshansky <tim.olshansky@gmail.com>",
"Timo Tijhof <krinklemail@gmail.com>",
"Tom MacWright <tom@macwright.org>",
Expand Down Expand Up @@ -289,6 +297,7 @@
"Alexander Pepper <alexander.pepper@infopark.de>",
"Alexander Shtuchkin <ashtuchkin@gmail.com>",
"Alexei <solo@solo.md>",
"Ameer Jhan <ameerjhanprof@gmail.com>",
"Anders Ekdahl <anders.ekdahl@gmail.com>",
"Anders Janmyr <anders.janmyr@sonymobile.com>",
"Andreas Krummsdorf <a.krummsdorf@litixsoft.de>",
Expand All @@ -305,6 +314,7 @@
"Basemm <BAsM.Egy@gmail.com>",
"Benoit Charbonnier <benoit.charbonnier@gmail.com>",
"Bhavesh Kakadiya <bhavesh@superhuman.com>",
"Borewit <Borewit@users.noreply.github.com>",
"Brady Wied <brady@bswtechconsulting.com>",
"Bram Borggreve <borggreve@gmail.com>",
"Breno Calazans <breno@vtex.com.br>",
Expand All @@ -321,6 +331,7 @@
"Chris Dawson <xrdawson@gmail.com>",
"Christian Weiss <cweiss@stripe.com>",
"Christopher Hiller <chiller@badwing.com>",
"Chuf <42591821+GChuf@users.noreply.github.com>",
"Ciro S. Costa <ciro.costa@usp.br>",
"Daan Stolp <mail@daanstolp.nl>",
"Damien Choizit <damien.choizit@gmail.com>",
Expand Down
1 change: 1 addition & 0 deletions release.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ module.exports = {
'@semantic-release/github'
],
prepare: [
'./tools/update-contributors',
'@semantic-release/changelog',
'@semantic-release/npm',
'@semantic-release/git'
Expand Down
23 changes: 23 additions & 0 deletions tools/update-contributors.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
const { execSync } = require('child_process')
const { readFileSync, writeFileSync } = require('fs')
const { resolve } = require('path')

const prepare = async (pluginConfig, { logger }) => {
// Example output:
// 1042 Vojta Jina <vojta.jina@gmail.com>
// 412 Friedel Ziegelmayer <friedel.ziegelmayer@gmail.com>
// 206 dignifiedquire <friedel.ziegelmayer@gmail.com>
// 139 johnjbarton <johnjbarton@johnjbarton.com>
const stdout = execSync('git log --pretty=short | git shortlog -nse', { encoding: 'utf8' })

const pkgPath = resolve(__dirname, '..', 'package.json')
const pkg = JSON.parse(readFileSync(pkgPath, 'utf8'))

// First line is already included as author field. Last line is dropped as it is an empty line.
pkg.contributors = stdout.split('\n').slice(1, -1).map((line) => line.replace(/^[\W\d]+/, ''))
writeFileSync(pkgPath, JSON.stringify(pkg, undefined, ' ') + '\n', 'utf8')

logger.info('Updated contributors list.')
}

module.exports = { prepare }

0 comments on commit 1378b44

Please sign in to comment.