2023-05-02 11:11:27 -07:00
|
|
|
const { BskyAgent } = require('@atproto/api');
|
|
|
|
const {Octokit} = require("@octokit/rest");
|
|
|
|
|
|
|
|
(async function main () {
|
|
|
|
const github = new Octokit();
|
|
|
|
const response = await github.rest.repos.getLatestRelease({
|
|
|
|
owner: process.env.OWNER,
|
|
|
|
repo: process.env.REPO,
|
|
|
|
});
|
|
|
|
const release = response.data;
|
|
|
|
|
|
|
|
let notes = release.body;
|
|
|
|
|
|
|
|
// replace all non-supported characters
|
|
|
|
notes = notes.replaceAll('### ', '');
|
|
|
|
notes = notes.replaceAll('**', '');
|
|
|
|
notes = notes.replace(/ \(\[[0-9a-z]+\]\(.*\)/g, '');
|
|
|
|
notes = notes.trim();
|
2023-07-24 10:12:21 -07:00
|
|
|
notes = notes.substring(0, 249);
|
2023-05-02 11:11:27 -07:00
|
|
|
|
|
|
|
const agent = new BskyAgent({ service: 'https://bsky.social' });
|
|
|
|
await agent.login({ identifier: process.env.BLUESKY_IDENTIFIER, password: process.env.BLUESKY_PASSWORD });
|
|
|
|
|
|
|
|
const version = release.name;
|
|
|
|
|
|
|
|
const text = `📦 ${version}
|
|
|
|
|
|
|
|
${notes}
|
|
|
|
|
|
|
|
#ohmyposh #oss #cli #opensource`;
|
|
|
|
|
|
|
|
console.log(`Posting to Bluesky:\n\n${text}`);
|
|
|
|
|
|
|
|
await agent.post({
|
|
|
|
text: text,
|
|
|
|
embed: {
|
|
|
|
$type: 'app.bsky.embed.external',
|
|
|
|
external: {
|
|
|
|
uri: `https://github.com/JanDeDobbeleer/oh-my-posh/releases/tag/${version}`,
|
|
|
|
title: "The best release yet 🚀",
|
|
|
|
description: version,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
});
|
|
|
|
})();
|