-
Notifications
You must be signed in to change notification settings - Fork 7
155 lines (149 loc) · 6.02 KB
/
publish.yml
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
153
154
155
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: 22.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@e06fe3ef65499b38eb12224f2a60979f6d797330
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