Skip to content

Commit

Permalink
Add debug logging to releases
Browse files Browse the repository at this point in the history
  • Loading branch information
birdcar committed Apr 12, 2022
1 parent 3a405dc commit 7a7735e
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 11 deletions.
15 changes: 10 additions & 5 deletions create_release/dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -10725,7 +10725,7 @@ var __webpack_exports__ = {};
// This entry need to be wrapped in an IIFE because it need to be isolated against other modules in the chunk.
(() => {
const fs = __nccwpck_require__(3292);

const util = __nccwpck_require__(3837);
const core = __nccwpck_require__(2186);
const github = __nccwpck_require__(5438);
const { parser } = __nccwpck_require__(1812);
Expand All @@ -10738,27 +10738,32 @@ async function run() {
timezone: core.getInput('timezone')
});
const { owner, repo } = github.context.repo;
core.debug(`context: ${JSON.stringify(github.context, null, 2)}`);
const changelog = parser(await fs.readFile(changelogPath, 'utf8'));
const tag_name = process.env.GITHUB_REF.replace(/^refs\/tags\/v/, '');
core.debug(`Found tag_name: ${util.inspect(tag_name)}`);

for (let rel of changelog.releases) {
// Only create from the release that matches the tag
if (rel.version.raw !== tag_name) {
core.debug(`rel.version.raw: ${util.inspect(rel.version.raw)}`);
if (rel.version.raw.trim() != tag_name.trim()) {
core.debug(`Skipping release: ${rel.version.raw}`);
core.debug(`${util.inspect(rel.version.raw)} != ${util.inspect(tag_name)}`);
continue;
}

// Remove the first line of the release notes (it matches the title)
const body = rel.toString().split('\n').slice(1).join('\n');

// Create the release
await octokit.rest.repos.createRelease({
const res = await octokit.rest.repos.createRelease({
owner,
repo,
tag_name,
name: `v${tag}`,
name: `v${tag_name}`,
body
}).catch(core.error);

core.debug(`createRelease: ${JSON.stringify(res.data, null, 2)}`);
core.success(`Created release ${tag_name}`);
}

Expand Down
2 changes: 1 addition & 1 deletion create_release/dist/index.js.map

Large diffs are not rendered by default.

15 changes: 10 additions & 5 deletions create_release/src/createRelease.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
const fs = require('fs/promises');

const util = require('util');
const core = require('@actions/core');
const github = require('@actions/github');
const { parser } = require('keep-a-changelog');
Expand All @@ -12,27 +12,32 @@ async function run() {
timezone: core.getInput('timezone')
});
const { owner, repo } = github.context.repo;
core.debug(`context: ${JSON.stringify(github.context, null, 2)}`);
const changelog = parser(await fs.readFile(changelogPath, 'utf8'));
const tag_name = process.env.GITHUB_REF.replace(/^refs\/tags\/v/, '');
core.debug(`Found tag_name: ${util.inspect(tag_name)}`);

for (let rel of changelog.releases) {
// Only create from the release that matches the tag
if (rel.version.raw !== tag_name) {
core.debug(`rel.version.raw: ${util.inspect(rel.version.raw)}`);
if (rel.version.raw.trim() != tag_name.trim()) {
core.debug(`Skipping release: ${rel.version.raw}`);
core.debug(`${util.inspect(rel.version.raw)} != ${util.inspect(tag_name)}`);
continue;
}

// Remove the first line of the release notes (it matches the title)
const body = rel.toString().split('\n').slice(1).join('\n');

// Create the release
await octokit.rest.repos.createRelease({
const res = await octokit.rest.repos.createRelease({
owner,
repo,
tag_name,
name: `v${tag}`,
name: `v${tag_name}`,
body
}).catch(core.error);

core.debug(`createRelease: ${JSON.stringify(res.data, null, 2)}`);
core.success(`Created release ${tag_name}`);
}

Expand Down

0 comments on commit 7a7735e

Please sign in to comment.