-
Notifications
You must be signed in to change notification settings - Fork 10
152 lines (145 loc) · 5.8 KB
/
publish.yml
File metadata and controls
152 lines (145 loc) · 5.8 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
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}}
- name: NPM Publish
if: ${{ matrix.package == 'linux-x64-gnu' }}
run: npm publish --access public ${{env.DRY_RUN}}
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}}
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