Skip to content

Publish

Publish #98

Workflow file for this run

name: Publish
on:
workflow_dispatch:
inputs:
dry-run:
description: 'Dry run'
type: boolean
required: false
default: 'false'
env:
JAVA_VERSION: 21
NODE_VERSION: 24
CARGO_TERM_COLOR: always
DRY_RUN: ${{ (github.event.inputs.dry-run == 'true' && '--dry-run') || '' }}
permissions:
id-token: write
contents: read
jobs:
build:
strategy:
matrix:
include:
- os: ubuntu-24.04
target: x86_64-unknown-linux-gnu
package: linux-x64-gnu
publish: true
- os: ubuntu-24.04
target: aarch64-unknown-linux-gnu
package: linux-arm64-gnu
publish: false
- os: windows-latest
target: x86_64-pc-windows-msvc
package: win32-x64-msvc
publish: false
- os: windows-latest
target: i686-pc-windows-msvc
package: win32-ia32-msvc
publish: false
- os: macos-latest
target: x86_64-apple-darwin
package: darwin-x64
publish: false
- os: macos-latest
target: aarch64-apple-darwin
package: darwin-arm64
publish: false
runs-on: ${{ matrix.os }}
steps:
- name: Checkout
uses: actions/checkout@v6
- name: Setup Node.js environment
uses: actions/setup-node@v6
with:
node-version: ${{env.NODE_VERSION}}.x
registry-url: 'https://registry.npmjs.org'
- name: Setup Java JDK
uses: actions/setup-java@v5
with:
distribution: 'temurin'
java-version: ${{env.JAVA_VERSION}}
- name: Add rust target
run: rustup target add ${{ matrix.target }}
- name: Setup cross-compilation
if: ${{ matrix.target == 'aarch64-unknown-linux-gnu' }}
run: |
sudo apt-get update
sudo apt-get install gcc-multilib -y
sudo apt-get install gcc-aarch64-linux-gnu g++-aarch64-linux-gnu -y
mkdir .cargo
printf '[target.aarch64-unknown-linux-gnu]\nlinker = "aarch64-linux-gnu-gcc"\n' >> .cargo/config
- name: Install Dependencies
run: npm ci
- name: Build
run: npm run build -- -- --target ${{ matrix.target }}
shell: bash
- name: Get version
id: version
run: echo "version=$(node -p 'require(`./package.json`).version')" >> $GITHUB_ENV
shell: bash
- name: Set version
run: npm version --no-git-tag-version --allow-same-version ${{ env.version }} -f
working-directory: npm/${{ matrix.package }}
- name: Move binary
run: mv java.*.node npm/${{ matrix.package }}
shell: bash
- name: NPM Publish Binary
if: ${{ matrix.package != 'linux-x64-gnu' }}
working-directory: npm/${{ matrix.package }}
run: npm publish --access public ${{env.DRY_RUN}}
continue-on-error: true
- name: NPM Publish
if: ${{ matrix.package == 'linux-x64-gnu' }}
run: npm publish --access public ${{env.DRY_RUN}}
continue-on-error: true
build-musl:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- name: Setup Node.js environment
uses: actions/setup-node@v6
with:
node-version: ${{env.NODE_VERSION}}.x
registry-url: 'https://registry.npmjs.org'
- name: Build
uses: addnab/docker-run-action@v3
timeout-minutes: 180
with:
image: ghcr.io/markusjx/node-java-bridge/test-alpine:${{env.NODE_VERSION}}-${{env.JAVA_VERSION}}
options: -v ${{ github.workspace }}:/github/workspace -w /github/workspace
run: |
npm ci
npm run build
- name: Get version
id: version
run: echo "version=$(node -p 'require(`./package.json`).version')" >> $GITHUB_ENV
shell: bash
- name: Set version
run: npm version --no-git-tag-version --allow-same-version ${{ env.version }} -f
working-directory: npm/linux-x64-musl
- name: Move binary
run: mv java.*.node npm/linux-x64-musl
shell: bash
- name: NPM Publish Binary
working-directory: npm/linux-x64-musl
run: npm publish --access public ${{env.DRY_RUN}}
continue-on-error: true
draft-release:
needs: [build, build-musl]
runs-on: ubuntu-latest
if: github.ref == 'refs/heads/main' && github.event.inputs.dry-run != 'true'
steps:
- name: Checkout
uses: actions/checkout@v6
- name: Get version
id: version
run: echo "version=$(node -p 'require(`./package.json`).version')" >> $GITHUB_ENV
shell: bash
- name: Create Release
id: create_release
uses: softprops/action-gh-release@v2
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: v${{ env.version }}
name: Release v${{ env.version }}
generate_release_notes: true
draft: true
prerelease: false