<commit_before>'use strict';

/**
 * Grunt task to create new release on GitHub.
 */

const Octokit = require('@octokit/rest');

const owner = 'web-scrobbler';
const repo = 'web-scrobbler';

let githubClient = {};

module.exports = (grunt) => {
	grunt.registerTask('github_release', 'Create a release on GitHub', async function() {
		const done = this.async();
		const data = grunt.config.get(this.name);
		const tagName = `v${data.version}`;

		githubClient = new Octokit({
			auth() {
				return `token ${data.token}`;
			}
		});

		try {
			await publishRelease(tagName);
			grunt.log.ok(`Created release for ${tagName} version`);
		} catch (err) {
			grunt.log.error(err.message);
		} finally {
			done();
		}
	});
};

/**
 * Publish release on GitHub.
 * Find previously created draft release and make it as published one.
 *
 * @param  {String} tagName Git tag
 */
async function publishRelease(tagName) {
	const release = await getReleaseByName(tagName);
	if (!release.draft) {
		throw new Error(`Unable to create release: ${tagName} is not a draft release`);<commit_msg>Migrate to @octokit/rest v17<commit_after>'use strict';

/**
 * Grunt task to create new release on GitHub.
 */

const { Octokit } = require('@octokit/rest');

const owner = 'web-scrobbler';
const repo = 'web-scrobbler';

let githubClient = {};

module.exports = (grunt) => {
	grunt.registerTask('github_release', 'Create a release on GitHub', async function() {
		const done = this.async();
		const data = grunt.config.get(this.name);
		const tagName = `v${data.version}`;

		githubClient = new Octokit({ auth: data.token });

		try {
			await publishRelease(tagName);
			grunt.log.ok(`Created release for ${tagName} version`);
		} catch (err) {
			grunt.log.error(err.message);
		} finally {
			done();
		}
	});
};

/**
 * Publish release on GitHub.
 * Find previously created draft release and make it as published one.
 *
 * @param  {String} tagName Git tag
 */
async function publishRelease(tagName) {
	const release = await getReleaseByName(tagName);
	if (!release.draft) {
		throw new Error(`Unable to create release: ${tagName} is not a draft release`);
{'fraction_non_alphanumeric': 0.14726507713884993, 'fraction_numerical': 0.0009350163627863488, 'mean_word_length': 3.9195402298850577, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4192494', 'n_tokens_mistral': 737, 'n_tokens_neox': 694, 'n_words': 202}