ci: release nodejs add-on and open release PR

This commit is contained in:
shum committed 2026-10-12 14:05:48 +00:00
1 parent 40083b3f57
commit 03d14f387e
3 files changed
+213 -43

No files matched your search

+7 -43
View File
@@ -839,49 +839,13 @@ jobs:
github_token: ${{ secrets.GITHUB_TOKEN }}
# =========================
# Node.js add-on
# Packages release PR
# =========================
build-nodejs-addon:
name: "Node.js add-on ${{ matrix.platform }}"
needs: [maybe-release]
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
include:
- os: ubuntu-22.04
platform: linux-x86_64
- os: ubuntu-22.04-arm
platform: linux-aarch64
- os: macos-latest
platform: macos-aarch64
- os: macos-15-intel
platform: macos-x86_64
- os: windows-latest
platform: windows-x86_64
defaults:
run:
shell: bash
working-directory: packages/simplex-chat-nodejs
steps:
- name: Checkout Code
uses: actions/checkout@v6
# A new library release updates the Node.js and Python packages in a release PR.
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: 22
- name: Build add-on
run: |
npm install --ignore-scripts --no-audit --no-fund
npx --yes node-gyp rebuild
cp build/Release/simplex.node build/simplex-chat-nodejs-${{ matrix.platform }}.node
- name: Upload add-on artifact
uses: actions/upload-artifact@v4
with:
name: simplex-nodejs-addon-${{ matrix.platform }}
path: packages/simplex-chat-nodejs/build/simplex-chat-nodejs-${{ matrix.platform }}.node
if-no-files-found: error
packages-release-pr:
needs: [maybe-release, build-linux, build-linux-postgres, build-macos, build-windows]
if: ${{ !cancelled() && needs.maybe-release.outputs.libs_tag }}
uses: ./.github/workflows/packages-release-pr.yml
secrets: inherit
+121
View File
@@ -0,0 +1,121 @@
name: nodejs add-on
# Builds the Node.js add-on on every platform for pull requests. A push to master or stable builds and
# releases it to simplex-chat-libs as nodejs-addon-<hash of its sources>, when that release does not exist yet,
# and updates the packages release PR.
# Secrets:
# -------
# NODEJS_REPO_TOKEN
# Only select repositories: simplex-chat-libs
# Permissions:
# * Contents (Read and Write)
on:
workflow_dispatch:
push:
branches:
- master
- stable
paths:
- "packages/simplex-chat-nodejs/cpp/**"
- "packages/simplex-chat-nodejs/binding.gyp"
- "packages/simplex-chat-nodejs/package.json"
- ".github/workflows/nodejs-addon.yml"
pull_request:
paths:
- "packages/simplex-chat-nodejs/cpp/**"
- "packages/simplex-chat-nodejs/binding.gyp"
- ".github/workflows/nodejs-addon.yml"
jobs:
tag:
runs-on: ubuntu-latest
outputs:
tag: ${{ steps.tag.outputs.tag }}
release: ${{ steps.tag.outputs.release }}
steps:
- name: Checkout Code
uses: actions/checkout@v6
- name: Release tag
id: tag
env:
GH_TOKEN: ${{ secrets.NODEJS_REPO_TOKEN }}
run: |
tag=$(python3 scripts/ci/packages_release.py addon-tag)
echo "tag=$tag" >> "$GITHUB_OUTPUT"
if [ "${{ github.event_name }}" != pull_request ] && { [ "${{ github.ref }}" = refs/heads/master ] || [ "${{ github.ref }}" = refs/heads/stable ]; } \
&& ! gh release view "$tag" --repo "${{ github.repository }}-libs" > /dev/null 2>&1; then
echo "release=true" >> "$GITHUB_OUTPUT"
fi
build:
name: "build ${{ matrix.platform }}"
needs: tag
if: github.event_name == 'pull_request' || needs.tag.outputs.release == 'true'
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
include:
- os: ubuntu-22.04
platform: linux-x86_64
- os: ubuntu-22.04-arm
platform: linux-aarch64
- os: macos-latest
platform: macos-aarch64
- os: macos-15-intel
platform: macos-x86_64
- os: windows-latest
platform: windows-x86_64
defaults:
run:
shell: bash
working-directory: packages/simplex-chat-nodejs
steps:
- name: Checkout Code
uses: actions/checkout@v6
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: 22
- name: Build add-on
run: |
npm install --ignore-scripts --no-audit --no-fund
npx --yes node-gyp rebuild
cp build/Release/simplex.node build/simplex-chat-nodejs-${{ matrix.platform }}.node
- name: Upload add-on artifact
uses: actions/upload-artifact@v4
with:
name: simplex-nodejs-addon-${{ matrix.platform }}
path: packages/simplex-chat-nodejs/build/simplex-chat-nodejs-${{ matrix.platform }}.node
if-no-files-found: error
release:
runs-on: ubuntu-latest
needs: [tag, build]
if: needs.tag.outputs.release == 'true'
steps:
- name: Download add-on artifacts
uses: actions/download-artifact@v4
with:
pattern: simplex-nodejs-addon-*
merge-multiple: true
path: addons
- name: Create add-on release
uses: softprops/action-gh-release@v2
with:
repository: ${{ github.repository }}-libs
tag_name: ${{ needs.tag.outputs.tag }}
files: addons/*.node
token: ${{ secrets.NODEJS_REPO_TOKEN }}
packages-release-pr:
needs: release
uses: ./.github/workflows/packages-release-pr.yml
secrets: inherit
+85
View File
@@ -0,0 +1,85 @@
name: packages release PR
# Opens or updates the release PR of simplex-chat (npm, PyPI) and @simplex-chat/types for this branch:
# pins of new library and add-on releases with their SHA-256, and version bumps of changed packages.
# Merging the PR publishes the packages (packages-publish.yml).
# Secrets:
# -------
# NODEJS_REPO_TOKEN
# Reads releases of simplex-chat-libs
# RELEASE_PR_TOKEN
# Only select repositories: simplex-chat
# Permissions:
# * Contents (Read and Write)
# * Pull requests (Read and Write)
# A PR opened with GITHUB_TOKEN does not run the checks of other workflows.
on:
workflow_dispatch:
inputs:
nodejs_version:
description: "simplex-chat npm version, bumped when needed by default"
required: false
types_version:
description: "@simplex-chat/types version, bumped when needed by default"
required: false
python_version:
description: "simplex-chat PyPI version, bumped when needed by default"
required: false
workflow_call:
push:
branches:
- master
- stable
paths:
- "packages/simplex-chat-nodejs/**"
- "packages/simplex-chat-client/types/typescript/**"
- "packages/simplex-chat-python/**"
# nodejs-addon.yml updates the PR after the add-on release
- "!packages/simplex-chat-nodejs/cpp/**"
- "!packages/simplex-chat-nodejs/binding.gyp"
concurrency:
group: packages-release-pr-${{ github.ref }}
cancel-in-progress: false
jobs:
release-pr:
# A merged release PR changes only versions and pins.
if: "${{ !startsWith(github.event.head_commit.message, 'packages: release') }}"
runs-on: ubuntu-latest
steps:
- name: Checkout Code
uses: actions/checkout@v6
with:
fetch-depth: 0
- name: Update pins and versions
id: prepare
env:
GH_TOKEN: ${{ secrets.NODEJS_REPO_TOKEN }}
LIBS_REPOSITORY: ${{ github.repository }}-libs
NPM_SCOPE: ${{ vars.NPM_SCOPE }}
PYPI_URL: ${{ vars.PYPI_URL }}
PYPI_PROJECT: ${{ vars.PYPI_PROJECT }}
run: |
python3 scripts/ci/packages_release.py prepare \
--nodejs-version "${{ inputs.nodejs_version }}" \
--types-version "${{ inputs.types_version }}" \
--python-version "${{ inputs.python_version }}" \
--summary "$RUNNER_TEMP/summary.md"
echo "title=$(head -n 1 "$RUNNER_TEMP/summary.md")" >> "$GITHUB_OUTPUT"
- name: Create or update release PR
uses: peter-evans/create-pull-request@v7
with:
token: ${{ secrets.RELEASE_PR_TOKEN }}
branch: packages-release/${{ github.ref_name }}
base: ${{ github.ref_name }}
title: ${{ steps.prepare.outputs.title }}
commit-message: ${{ steps.prepare.outputs.title }}
body-path: ${{ runner.temp }}/summary.md
author: SimpleX Chat <build@simplex.chat>
committer: SimpleX Chat <build@simplex.chat>
delete-branch: true