Skip to content

Commit

Permalink
Update publish CI
Browse files Browse the repository at this point in the history
  • Loading branch information
Sirherobrine23 authored May 15, 2023
1 parent ff26246 commit 65c84d5
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 29 deletions.
41 changes: 15 additions & 26 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -1,26 +1,22 @@
name: Publish package
name: Test
on:
release:
types:
- prereleased
- released
- released
- prereleased

jobs:
build:
strategy:
matrix:
os:
- ubuntu
- windows
- macos
runs-on: ${{ matrix.os }}-latest
steps:
- uses: actions/checkout@v3
name: Code checkout
with:
persist-credentials: true
ref: main
fetch-depth: 2
submodules: true

# Install basic tools
Expand All @@ -30,41 +26,33 @@ jobs:
node-version: 18.x
registry-url: https://registry.npmjs.org/

- name: Ubuntu dependecies
if: matrix.os == 'ubuntu'
run: |
export DEBIAN_FRONTEND=noninteractive
sudo apt install -y binutils-multiarch gcc-*aarch64-linux-gnu gcc-*aarch64-linux-gnu-base g++-*aarch64-linux-gnu libc6-arm64-cross
- run: npm install --no-save --ignore-scripts
- run: node scripts/build.mjs build --auto -v

- name: Upload generate interface
uses: actions/upload-artifact@v3
continue-on-error: true
with:
name: ${{ matrix.os }}
path: "prebuilds"
retention-days: 7
name: prebuilds_${{ matrix.os }}
path: "prebuilds/**"

publishpackage:
pack_package:
needs: build
runs-on: ubuntu-latest
name: Publish
permissions:
pull-requests: write
contents: write
issues: write
name: Pack npm package
env:
PACKAGE_VERSION: ${{ github.ref }}
steps:
- uses: actions/checkout@v3
name: Code checkout
with:
persist-credentials: true
ref: main
fetch-depth: 2
submodules: true

- name: Ubuntu dependecies
run: |
export DEBIAN_FRONTEND=noninteractive
sudo apt install -y binutils-multiarch gcc-*aarch64-linux-gnu gcc-*aarch64-linux-gnu-base g++-*aarch64-linux-gnu libc6-arm64-cross
# Install basic tools
- uses: actions/setup-node@v3
name: Setup node.js
Expand All @@ -75,7 +63,8 @@ jobs:
- name: Download all artefacts
uses: actions/download-artifact@v3
with:
path: ./
path: ./prebuilds
name:

- name: Edit version and install depencies
run: |
Expand Down
37 changes: 34 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ A quick way to use Wireguard with Node.js without having to run the Wireguard to

> **Note**
>
> we have pre-copied files for linux arm64(aarch64) and linux x86_64, any other architecture will be copied the addons for the same one, in which case you will have to have `gcc` or `clang` installed to compile.
> we have pre-copied files for Windows, MacOS (x64/intel) and Linux (arm64, x86_64), else require `gcc` or `clang` installed to compile Node addon.
With this module it is possible to:

Expand All @@ -27,8 +27,39 @@ This project works because with of [Wireguard embeddable library](https://github
### Get Current peers and Statistics

```ts
import { show } from "wireguard-tools.js";
const wireguardInterfaces = show("wg0");
import { parseWgDevice } from "wireguard-tools.js";
const wireguardInterfaces = parseWgDevice("wg0");
// Wg0 is the interface name.
console.log("Wg0:\n%o", wireguardInterfaces);
```

# Add/Update Wireguard interface

```ts
import { addDevice, parseWgDevice } from "wireguard-tools.js";
addDevice("wg0", {
publicKey: "string",
privateKey: "string",
portListen: 27301,
Address: [
"1.1.1.1/32",
"8.8.8.8/32"/** Mark this peer to be removed, any changes remove this option */
],
replacePeers: true,
peers: {
"publicKeyPeer": {
removeMe: false,
presharedKey: "string",
keepInterval: 5,
endpoint: "google.com:27301",
allowedIPs: [
"8.8.8.8",
"8.8.4.4."
]
}
}
});
const wireguardInterfaces = parseWgDevice("wg0");
// Wg0 is the interface name.
console.log("Wg0:\n%o", wireguardInterfaces);
```
Expand Down

0 comments on commit 65c84d5

Please sign in to comment.