mirror of
https://github.com/simplex-chat/simplex-chat.git
synced 2026-10-17 23:50:39 +00:00
ci: release nodejs add-on and open release PR
This commit is contained in:
@@ -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
|
||||
Reference in New Issue
Block a user