diff --git a/.github/scripts/send-version-release-notification.mjs b/.github/scripts/send-version-release-notification.mjs new file mode 100644 index 00000000000..e2d8a2ea5d8 --- /dev/null +++ b/.github/scripts/send-version-release-notification.mjs @@ -0,0 +1,32 @@ +import { ensureEnvVar } from './github-helpers.mjs'; + +async function sendVersionReleaseNotification() { + const payload = ensureEnvVar('PAYLOAD'); + const webhookData = ensureEnvVar('N8N_VERSION_RELEASE_NOTIFICATION_DATA'); + + const { user, secret, url } = JSON.parse(webhookData); + + console.log('Payload: ', JSON.parse(payload)); + + const response = await fetch(url, { + method: 'POST', + headers: { + 'Content-Type': 'application/json', + Authorization: 'Basic ' + Buffer.from(`${user}:${secret}`).toString('base64'), + }, + body: payload, + }); + + const status = response.status; + console.log('Webhook call returned status ' + status); + + if (status !== 200) { + const body = await response.text(); + throw new Error(`Webhook call failed:\n\n ${body}`); + } +} + +// only run when executed directly, not when imported by tests +if (import.meta.url === `file://${process.argv[1]}`) { + sendVersionReleaseNotification(); +} diff --git a/.github/workflows/release-publish-post-release.yml b/.github/workflows/release-publish-post-release.yml index 078fea0a265..ee38e419a2a 100644 --- a/.github/workflows/release-publish-post-release.yml +++ b/.github/workflows/release-publish-post-release.yml @@ -64,3 +64,11 @@ jobs: version: ${{ inputs.version }} experimental: ${{ inputs.release_type == 'rc' }} secrets: inherit + + send-version-release-notification: + name: 'Send version release notifications' + uses: ./.github/workflows/release-version-release-notification.yml + with: + previous-version: ${{ inputs.previous_version }} + version: ${{ inputs.version }} + secrets: inherit diff --git a/.github/workflows/release-version-release-notification.yml b/.github/workflows/release-version-release-notification.yml new file mode 100644 index 00000000000..848d25459fc --- /dev/null +++ b/.github/workflows/release-version-release-notification.yml @@ -0,0 +1,50 @@ +name: 'Release: Send version release notification' +run-name: 'Send version release notification for n8n@${{ inputs.version }}' + +on: + workflow_dispatch: + inputs: + previous-version: + description: 'The previous release version (e.g. 2.10.2)' + required: true + type: string + version: + description: 'The release version (e.g. 2.11.0)' + required: true + type: string + workflow_call: + inputs: + previous-version: + description: 'The previous release version (e.g. 2.10.2)' + required: true + type: string + version: + description: 'The release version (e.g. 2.11.0)' + required: true + type: string + +jobs: + release-notification: + runs-on: ubuntu-slim + environment: release + steps: + - name: Checkout + uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 + with: + fetch-depth: 0 + + - name: Setup Node.js + uses: ./.github/actions/setup-nodejs + with: + build-command: '' + install-command: npm install --prefix=.github/scripts --no-package-lock + + - name: Send release notification + env: + N8N_VERSION_RELEASE_NOTIFICATION_DATA: ${{ secrets.N8N_VERSION_RELEASE_NOTIFICATION_DATA }} + PAYLOAD: | + { + "previous_version": "${{ inputs.previous-version }}", + "new_version": "${{ inputs.version }}" + } + run: node ./.github/scripts/send-version-release-notification.mjs