From f1e9981aae1d10becc70fd418653c6e2347ad962 Mon Sep 17 00:00:00 2001 From: alex Date: Mon, 15 May 2023 14:17:19 +0100 Subject: [PATCH] main: notify huppy after release --- .github/workflows/publish-new.yml | 1 + scripts/publish-new.ts | 17 +++++++++++++++++ 2 files changed, 18 insertions(+) diff --git a/.github/workflows/publish-new.yml b/.github/workflows/publish-new.yml index 67d5f30f3..f5df542de 100644 --- a/.github/workflows/publish-new.yml +++ b/.github/workflows/publish-new.yml @@ -49,3 +49,4 @@ jobs: env: GH_TOKEN: ${{ github.token }} NPM_TOKEN: ${{ secrets.NPM_TOKEN }} + HUPPY_TOKEN: ${{ secrets.HUPPY_TOKEN }} diff --git a/scripts/publish-new.ts b/scripts/publish-new.ts index 8f56ffda6..1125c2b13 100644 --- a/scripts/publish-new.ts +++ b/scripts/publish-new.ts @@ -1,9 +1,14 @@ import { Auto } from '@auto-it/core' +import fetch from 'cross-fetch' +import { assert } from 'node:console' import { parse } from 'semver' import { exec } from './lib/exec' import { getLatestVersion, publish, setAllVersions } from './lib/publishing' async function main() { + const huppyToken = process.env.HUPPY_TOKEN + assert(huppyToken && typeof huppyToken === 'string', 'HUPPY_ACCESS_KEY env var must be set') + const auto = new Auto({ plugins: ['npm'], baseBranch: 'main', @@ -61,6 +66,18 @@ async function main() { // finally, publish the packages [IF THIS STEP FAILS, RUN THE `publish-manual.ts` script locally] await publish() + + console.log('Notifying huppy of release...') + const huppyResponse = await fetch('http://localhost:3000/api/on-release', { + method: 'POST', + headers: { + 'Content-Type': 'application/json', + }, + body: JSON.stringify({ apiKey: huppyToken, tagToRelease: `v${nextVersion}`, canary: false }), + }) + console.log( + `huppy: [${huppyResponse.status} ${huppyResponse.statusText}] ${await huppyResponse.text()}` + ) } main()