Publish #79
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Publish | |
on: | |
workflow_dispatch: | |
inputs: | |
dry-run: | |
description: 'Dry run' | |
type: boolean | |
required: false | |
default: 'false' | |
jobs: | |
build: | |
strategy: | |
matrix: | |
include: | |
- os: ubuntu-20.04 | |
target: x86_64-unknown-linux-gnu | |
package: linux-x64-gnu | |
publish: true | |
- os: ubuntu-20.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@v4 | |
- name: Setup Node.js environment | |
uses: actions/setup-node@v4 | |
with: | |
node-version: 20.x | |
- name: Setup Java JDK | |
uses: actions/setup-java@v4 | |
with: | |
distribution: 'temurin' | |
java-version: '17' | |
- 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 | |
uses: JS-DevTools/npm-publish@v3.1.1 | |
if: ${{ matrix.package != 'linux-x64-gnu' }} | |
with: | |
access: public | |
token: ${{ secrets.NPM_TOKEN }} | |
package: npm/${{ matrix.package }}/package.json | |
dry-run: ${{ github.event.inputs.dry-run == 'true' }} | |
ignore-scripts: false | |
- name: NPM Publish | |
uses: JS-DevTools/npm-publish@v3.1.1 | |
if: ${{ matrix.package == 'linux-x64-gnu' }} | |
with: | |
access: public | |
token: ${{ secrets.NPM_TOKEN }} | |
dry-run: ${{ github.event.inputs.dry-run == 'true' }} | |
ignore-scripts: false | |
build-musl: | |
runs-on: ubuntu-20.04 | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Build | |
uses: addnab/docker-run-action@v3 | |
timeout-minutes: 180 | |
with: | |
image: ghcr.io/markusjx/node-java-bridge/java-bridge-node-alpine-build:node-20-jdk-17 | |
options: -v ${{ github.workspace }}:/github/workspace -w /github/workspace | |
run: | | |
npm config set cache /tmp --global | |
export CI=true | |
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 | |
uses: JS-DevTools/npm-publish@v3.1.1 | |
with: | |
access: public | |
token: ${{ secrets.NPM_TOKEN }} | |
package: npm/linux-x64-musl/package.json | |
dry-run: ${{ github.event.inputs.dry-run == 'true' }} | |
ignore-scripts: false | |
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@v4 | |
- 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: actions/create-release@v1 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
tag_name: v${{ env.version }} | |
release_name: Release v${{ env.version }} | |
body: | | |
Auto-generated release | |
draft: true | |
prerelease: false |