diff --git a/package.json b/package.json index 5720516..6498c58 100644 --- a/package.json +++ b/package.json @@ -29,6 +29,8 @@ "@trivago/prettier-plugin-sort-imports": "^5.2.2", "@typescript-eslint/eslint-plugin": "^8.20.0", "@typescript-eslint/parser": "^8.20.0", + "axios": "^1.7.9", + "dotenv": "^16.4.7", "eslint": "^9.18.0", "eslint-config-prettier": "^10.0.1", "eslint-plugin-prettier": "^5.1.3" diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index ee192c6..7bdb241 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -23,6 +23,12 @@ importers: '@typescript-eslint/parser': specifier: ^8.20.0 version: 8.21.0(eslint@9.19.0)(typescript@5.7.3) + axios: + specifier: ^1.7.9 + version: 1.7.9 + dotenv: + specifier: ^16.4.7 + version: 16.4.7 eslint: specifier: ^9.18.0 version: 9.19.0 @@ -646,6 +652,9 @@ packages: resolution: {integrity: sha512-kNOjDqAh7px0XWNI+4QbzoiR/nTkHAWNud2uvnJquD1/x5a7EQZMJT0AczqK0Qn67oY/TTQ1LbUKajZpp3I9tQ==} engines: {node: '>=8.0.0'} + axios@1.7.9: + resolution: {integrity: sha512-LhLcE7Hbiryz8oMDdDptSrWowmB4Bl6RCt6sIJKpRB4XtVf0iEgewX3au/pJqm+Py1kCASkb/FFKjxQaLtxJvw==} + balanced-match@1.0.2: resolution: {integrity: sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw==} @@ -905,6 +914,15 @@ packages: flatted@3.3.2: resolution: {integrity: sha512-AiwGJM8YcNOaobumgtng+6NHuOqC3A7MixFeDafM3X9cIUM+xUXoS5Vfgf+OihAYe20fxqNM9yPBXJzRtZ/4eA==} + follow-redirects@1.15.9: + resolution: {integrity: sha512-gew4GsXizNgdoRyqmyfMHyAmXsZDk6mHkSxZFCzW9gwlbtOW44CDtYavM+y+72qD/Vq2l550kMF52DT8fOLJqQ==} + engines: {node: '>=4.0'} + peerDependencies: + debug: '*' + peerDependenciesMeta: + debug: + optional: true + form-data-encoder@1.7.2: resolution: {integrity: sha512-qfqtYan3rxrnCk1VYaA4H+Ms9xdpPqvLZa6xmMgFvhO32x7/3J/ExcTd6qpxM0vH2GdMI+poehyBZvqfMTto8A==} @@ -1221,6 +1239,9 @@ packages: process-warning@4.0.1: resolution: {integrity: sha512-3c2LzQ3rY9d0hc1emcsHhfT9Jwz0cChib/QN89oME2R451w5fy3f0afAhERFZAwrbDU43wk12d0ORBpDVME50Q==} + proxy-from-env@1.1.0: + resolution: {integrity: sha512-D+zkORCbA9f1tdWRK0RaCR3GPv50cMxcrz4X8k5LTSUD1Dkw47mKJEZQNunItRTkWwgtaUSo1RVFRIG9ZXiFYg==} + pump@3.0.2: resolution: {integrity: sha512-tUPXtzlGM8FE3P0ZL6DVs/3P58k9nk8/jZeQCurTJylQA8qFYzHFfhBJkuqyE0FifOsQ0uKWekiZ5g8wtr28cw==} @@ -2019,6 +2040,14 @@ snapshots: atomic-sleep@1.0.0: {} + axios@1.7.9: + dependencies: + follow-redirects: 1.15.9 + form-data: 4.0.1 + proxy-from-env: 1.1.0 + transitivePeerDependencies: + - debug + balanced-match@1.0.2: {} base64-js@1.5.1: {} @@ -2292,6 +2321,8 @@ snapshots: flatted@3.3.2: {} + follow-redirects@1.15.9: {} + form-data-encoder@1.7.2: {} form-data@4.0.1: @@ -2591,6 +2622,8 @@ snapshots: process-warning@4.0.1: {} + proxy-from-env@1.1.0: {} + pump@3.0.2: dependencies: end-of-stream: 1.4.4 diff --git a/scripts/release-script b/scripts/release-script new file mode 100755 index 0000000..d0847ac --- /dev/null +++ b/scripts/release-script @@ -0,0 +1,61 @@ +#!/usr/bin/env node + +const axios = require("axios"); +const fs = require("fs"); +require("dotenv").config(); + +const GITHUB_TOKEN = process.env.GITHUB_TOKEN; +const REPO_OWNER = "covalenthq"; +const REPO_NAME = "ai-agent-sdk"; +const RELEASE_TAG = "v0.2.0"; + +async function getContributors(owner, repo, releaseTag) { + const url = `https://api.github.com/repos/${owner}/${repo}/commits?sha=${releaseTag}`; + const headers = { + Authorization: `token ${GITHUB_TOKEN}`, + Accept: "application/vnd.github.v3+json", + }; + + try { + const response = await axios.get(url, { headers }); + const commits = response.data; + + const contributors = new Set(); + commits.forEach((commit) => { + if (commit.author && commit.author.login) { + contributors.add(commit.author.login); + } else if (commit.commit && commit.commit.author) { + contributors.add(commit.commit.author.name); + } + }); + + return Array.from(contributors); + } catch (error) { + console.error("Error fetching contributors: ", error); + return []; + } +} + +function generateReleaseNotes(contributors) { + let releaseNotes = `## Release ${RELEASE_TAG}\n\n`; + releaseNotes += "### Contributors\n\n"; + releaseNotes += contributors + .map((contributor) => `- @${contributor}`) + .join("\n"); + return releaseNotes; +} + +async function main() { + const contributors = await getContributors( + REPO_OWNER, + REPO_NAME, + RELEASE_TAG + ); + const releaseNotes = generateReleaseNotes(contributors); + console.log(releaseNotes); + + // Optionally, write the release notes to a file + fs.writeFileSync(`release_notes_${RELEASE_TAG}.md`, releaseNotes); +} + +main(); \ No newline at end of file