mirror of
https://github.com/jackwener/wx-cli.git
synced 2026-10-08 05:15:46 +00:00
feat: npm wrapper + CI publish, fix README YAML/JSON description
This commit is contained in:
@@ -13,16 +13,29 @@ jobs:
|
||||
include:
|
||||
- os: macos-latest
|
||||
target: aarch64-apple-darwin
|
||||
name: wx-macos-arm64
|
||||
asset: wx-macos-arm64
|
||||
npm_dir: darwin-arm64
|
||||
bin: wx
|
||||
- os: macos-latest
|
||||
target: x86_64-apple-darwin
|
||||
name: wx-macos-x86_64
|
||||
asset: wx-macos-x86_64
|
||||
npm_dir: darwin-x64
|
||||
bin: wx
|
||||
- os: ubuntu-latest
|
||||
target: x86_64-unknown-linux-gnu
|
||||
name: wx-linux-x86_64
|
||||
asset: wx-linux-x86_64
|
||||
npm_dir: linux-x64
|
||||
bin: wx
|
||||
- os: ubuntu-latest
|
||||
target: aarch64-unknown-linux-gnu
|
||||
asset: wx-linux-arm64
|
||||
npm_dir: linux-arm64
|
||||
bin: wx
|
||||
- os: windows-latest
|
||||
target: x86_64-pc-windows-msvc
|
||||
name: wx-windows-x86_64.exe
|
||||
asset: wx-windows-x86_64.exe
|
||||
npm_dir: win32-x64
|
||||
bin: wx.exe
|
||||
|
||||
runs-on: ${{ matrix.os }}
|
||||
|
||||
@@ -33,38 +46,98 @@ jobs:
|
||||
with:
|
||||
targets: ${{ matrix.target }}
|
||||
|
||||
- name: Cache cargo registry
|
||||
- name: Install cross-compile tools (Linux arm64)
|
||||
if: matrix.target == 'aarch64-unknown-linux-gnu'
|
||||
run: |
|
||||
sudo apt-get update -q
|
||||
sudo apt-get install -y gcc-aarch64-linux-gnu
|
||||
echo "CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_LINKER=aarch64-linux-gnu-gcc" >> $GITHUB_ENV
|
||||
|
||||
- name: Cache cargo
|
||||
uses: actions/cache@v4
|
||||
with:
|
||||
path: |
|
||||
~/.cargo/registry
|
||||
~/.cargo/git
|
||||
target
|
||||
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
|
||||
restore-keys: ${{ runner.os }}-cargo-
|
||||
key: ${{ runner.os }}-${{ matrix.target }}-cargo-${{ hashFiles('**/Cargo.lock') }}
|
||||
restore-keys: ${{ runner.os }}-${{ matrix.target }}-cargo-
|
||||
|
||||
- name: Build release
|
||||
run: cargo build --release --locked --target ${{ matrix.target }}
|
||||
|
||||
- name: Rename binary (Unix)
|
||||
- name: Copy binary (Unix)
|
||||
if: matrix.os != 'windows-latest'
|
||||
run: |
|
||||
cp target/${{ matrix.target }}/release/wx ${{ matrix.name }}
|
||||
cp target/${{ matrix.target }}/release/wx ${{ matrix.asset }}
|
||||
cp target/${{ matrix.target }}/release/wx npm/platforms/${{ matrix.npm_dir }}/bin/wx
|
||||
|
||||
- name: Rename binary (Windows)
|
||||
- name: Copy binary (Windows)
|
||||
if: matrix.os == 'windows-latest'
|
||||
run: |
|
||||
copy target\${{ matrix.target }}\release\wx.exe ${{ matrix.name }}
|
||||
copy target\${{ matrix.target }}\release\wx.exe ${{ matrix.asset }}
|
||||
copy target\${{ matrix.target }}\release\wx.exe npm\platforms\${{ matrix.npm_dir }}\bin\wx.exe
|
||||
|
||||
- uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: ${{ matrix.name }}
|
||||
path: ${{ matrix.name }}
|
||||
name: ${{ matrix.asset }}
|
||||
path: ${{ matrix.asset }}
|
||||
|
||||
- uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: npm-${{ matrix.npm_dir }}
|
||||
path: npm/platforms/${{ matrix.npm_dir }}/bin/
|
||||
|
||||
- name: Upload to GitHub Release
|
||||
uses: softprops/action-gh-release@v2
|
||||
if: startsWith(github.ref, 'refs/tags/')
|
||||
with:
|
||||
files: ${{ matrix.name }}
|
||||
files: ${{ matrix.asset }}
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
|
||||
publish-npm:
|
||||
needs: build
|
||||
runs-on: ubuntu-latest
|
||||
if: startsWith(github.ref, 'refs/tags/')
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
|
||||
- uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version: '20'
|
||||
registry-url: 'https://registry.npmjs.org'
|
||||
|
||||
- name: Download all platform binaries
|
||||
uses: actions/download-artifact@v4
|
||||
with:
|
||||
pattern: npm-*
|
||||
path: npm-bins/
|
||||
|
||||
- name: Place binaries into platform packages
|
||||
run: |
|
||||
for dir in darwin-arm64 darwin-x64 linux-x64 linux-arm64; do
|
||||
mkdir -p npm/platforms/$dir/bin
|
||||
cp npm-bins/npm-$dir/wx npm/platforms/$dir/bin/wx
|
||||
chmod +x npm/platforms/$dir/bin/wx
|
||||
done
|
||||
mkdir -p npm/platforms/win32-x64/bin
|
||||
cp npm-bins/npm-win32-x64/wx.exe npm/platforms/win32-x64/bin/wx.exe
|
||||
|
||||
- name: Publish platform packages
|
||||
run: |
|
||||
for dir in darwin-arm64 darwin-x64 linux-x64 linux-arm64 win32-x64; do
|
||||
cd npm/platforms/$dir
|
||||
npm publish
|
||||
cd ../../..
|
||||
done
|
||||
env:
|
||||
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
|
||||
|
||||
- name: Publish main package
|
||||
run: |
|
||||
cd npm/wx-cli
|
||||
npm publish
|
||||
env:
|
||||
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
|
||||
|
||||
Reference in New Issue
Block a user