Skip to content

Commit

Permalink
Update actions versions in workflow. When the test server is used the…
Browse files Browse the repository at this point in the history
… np.info.uri also uses the test server base URL. Fix NpProfile in demo page
  • Loading branch information
vemonet committed Feb 11, 2024
1 parent 4eeb846 commit 616cf0b
Show file tree
Hide file tree
Showing 7 changed files with 47 additions and 27 deletions.
30 changes: 15 additions & 15 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,11 @@ jobs:
env:
BINDGEN_EXTRA_CLANG_ARGS: --sysroot /usr/aarch64-linux-gnu

- uses: actions/upload-artifact@v3
- uses: actions/upload-artifact@v4
with:
name: nanopub_x86_64_linux_gnu
path: target/release/nanopub-cli
- uses: actions/upload-artifact@v3
- uses: actions/upload-artifact@v4
with:
name: nanopub_aarch64_linux_gnu
path: target/aarch64-unknown-linux-gnu/release/nanopub-cli
Expand Down Expand Up @@ -83,11 +83,11 @@ jobs:
- run: cargo build --release --target aarch64-apple-darwin
working-directory: ./cli

- uses: actions/upload-artifact@v3
- uses: actions/upload-artifact@v4
with:
name: nanopub_x86_64_apple
path: target/release/nanopub-cli
- uses: actions/upload-artifact@v3
- uses: actions/upload-artifact@v4
with:
name: nanopub_aarch64_apple
path: target/aarch64-apple-darwin/release/nanopub-cli
Expand Down Expand Up @@ -118,7 +118,7 @@ jobs:
- run: cargo build --release
working-directory: ./cli

- uses: actions/upload-artifact@v3
- uses: actions/upload-artifact@v4
with:
name: nanopub_x86_64_windows_msvc
path: target/release/nanopub-cli.exe
Expand All @@ -145,14 +145,14 @@ jobs:
- uses: actions/checkout@v4
with:
submodules: true
- uses: docker/setup-qemu-action@v2
- uses: docker/setup-qemu-action@v3
with:
platforms: linux/${{ matrix.architecture }}
if: github.event_name == 'release' && matrix.architecture != 'x86_64'
- run: sed 's/%arch%/${{ matrix.architecture }}/g' .github/workflows/manylinux_build.sh | sed 's/%for_each_version%/${{ github.event_name == 'release' || '' }}/g' > .github/workflows/manylinux_build_script.sh
- run: docker run -v "$(pwd)":/workdir --platform linux/${{ matrix.architecture }} quay.io/pypa/manylinux2014_${{ matrix.architecture }} /bin/bash /workdir/.github/workflows/manylinux_build_script.sh
if: github.event_name == 'release' || matrix.architecture == 'x86_64'
- uses: actions/upload-artifact@v3
- uses: actions/upload-artifact@v4
with:
name: nanopub_wheel_${{ matrix.architecture }}_linux
path: target/wheels/*.whl
Expand All @@ -177,14 +177,14 @@ jobs:
- uses: actions/checkout@v4
with:
submodules: true
- uses: docker/setup-qemu-action@v2
- uses: docker/setup-qemu-action@v3
with:
platforms: linux/${{ matrix.architecture }}
if: github.event_name == 'release' && matrix.architecture != 'x86_64'
- run: sed 's/%arch%/${{ matrix.architecture }}/g' .github/workflows/musllinux_build.sh | sed 's/%for_each_version%/${{ github.event_name == 'release' || '' }}/g' > .github/workflows/musllinux_build_script.sh
- run: docker run -v "$(pwd)":/workdir --platform linux/${{ matrix.architecture }} quay.io/pypa/musllinux_1_1_${{ matrix.architecture }} /bin/bash /workdir/.github/workflows/musllinux_build_script.sh
if: github.event_name == 'release' || matrix.architecture == 'x86_64'
- uses: actions/upload-artifact@v3
- uses: actions/upload-artifact@v4
with:
name: nanopub_wheel_${{ matrix.architecture }}_linux_musl
path: target/wheels/*.whl
Expand All @@ -210,7 +210,7 @@ jobs:
submodules: true
- run: rustup update && rustup target add aarch64-apple-darwin
- uses: Swatinem/rust-cache@v2
- uses: actions/setup-python@v4
- uses: actions/setup-python@v5
with:
python-version: "3.10"
cache: pip
Expand All @@ -224,7 +224,7 @@ jobs:
if: github.event_name == 'release'
- run: maturin build --release --target aarch64-apple-darwin -m python/Cargo.toml
if: github.event_name == 'release'
- uses: actions/upload-artifact@v3
- uses: actions/upload-artifact@v4
with:
name: nanopub_wheel_universal2_mac
path: target/wheels/*.whl
Expand All @@ -244,7 +244,7 @@ jobs:
submodules: true
- run: rustup update
- uses: Swatinem/rust-cache@v2
- uses: actions/setup-python@v4
- uses: actions/setup-python@v5
with:
python-version: "3.10"
cache: pip
Expand All @@ -256,7 +256,7 @@ jobs:
- run: rm -r target/wheels
- run: maturin build --release -m python/Cargo.toml
- run: maturin sdist -m python/Cargo.toml
- uses: actions/upload-artifact@v3
- uses: actions/upload-artifact@v4
with:
name: nanopub_wheel_x86_64_windows
path: target/wheels/*.whl
Expand All @@ -273,7 +273,7 @@ jobs:
steps:
- uses: actions/checkout@v4
with:
submodule: true
submodules: true
- run: rustup update
- uses: Swatinem/rust-cache@v2

Expand All @@ -293,7 +293,7 @@ jobs:
working-directory: ./js

- name: Upload tarball
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: nanopub_sign_npm
path: ./js/pkg
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ jobs:
steps:
- uses: actions/checkout@v4
- name: Set up Python ${{ env.STABLE_PYTHON_VERSION }}
uses: actions/setup-python@v4
uses: actions/setup-python@v5
with:
python-version: ${{ env.STABLE_PYTHON_VERSION }}

Expand Down Expand Up @@ -129,7 +129,7 @@ jobs:
'target/release/nanopub-cli sign lib/tests/resources/simple1-rsa.trig -k lib/tests/resources/id_rsa'
- name: Upload benchmark markdown
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: benchmark.md
path: ./benchmark.md
4 changes: 2 additions & 2 deletions lib/docs/demo.html
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ <h1 class="text-xl font-semibold">✍️ Nanopublication signing playground 🕹
if (serverUrl && publish) {
console.log(`Publishing to ${serverUrl}`)
}
const profile = new NpProfile(orcid, "Your Name", privKey, "");
const profile = new NpProfile(privKey, orcid, "Your Name", "");
try {
// const checked = new Nanopub(rdfStr).check();
// console.log("CHECKED", checked.info());
Expand Down Expand Up @@ -211,7 +211,7 @@ <h1 class="text-xl font-semibold">✍️ Nanopublication signing playground 🕹
introBtn.addEventListener('click', async (event) => {
let keypair = new KeyPair();
keypair = keypair.toJs();
const profile = new NpProfile(orcidToken.orcid, orcidToken.fullName, keypair.private, "");
const profile = new NpProfile(keypair.private, orcidToken.orcid, orcidToken.fullName, "");
// Publish nanopub link to public key
const intro = Nanopub.publish_intro(profile, getNpServer(false))
.then(np => {
Expand Down
10 changes: 10 additions & 0 deletions lib/docs/use_cli.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,16 @@ curl -sSL https://raw.github.com/vemonet/nanopub-rs/main/scripts/install-binary.

## ✍️ Sign

You can define the path to the key pair used for signing in a `profile.yml` which contains the following information:

```yaml
orcid_id: https://orcid.org/0000-0000-0000-0000
name: Your Name
public_key: /home/user/.nanopub/id_rsa.pub
private_key: /home/user/.nanopub/id_rsa
introduction_nanopub_uri:
```
Sign a Nanopub, by default it will try to use the profile available at `~/.nanopub/profile.yml`

```bash
Expand Down
16 changes: 10 additions & 6 deletions lib/docs/use_javascript.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

[![npm](https://img.shields.io/npm/v/@nanopub/sign)](https://www.npmjs.com/package/@nanopub/sign)

You can easily publish Nanopubs from JavaScript, or TypeScript with the [`@nanopub/sign`](https://www.npmjs.com/package/@nanopub/sign) NPM package.
You can easily publish Nanopubs from JavaScript or TypeScript with the [`@nanopub/sign`](https://www.npmjs.com/package/@nanopub/sign) NPM package.

```admonish example title="Demo"
Visit the **[demo page](https://vemonet.github.io/nanopub-rs/demo.html)** to sign nanopubs, or generate and register a new key pair, directly in your browser using this NPM package. You can checkout the [`demo.html`](https://github.com/vemonet/nanopub-rs/blob/main/lib/docs/demo.html) file as an example to use the package directly from HTML/JS.
Expand All @@ -24,7 +24,7 @@ npm install --save @nanopub/sign

This package provides several functionalities related to the handling of Nanopublications, including signing, publishing, verifying, and fetching them:

1. **Signing Nanopubs**
### ✍️ Sign Nanopubs

This process involves signing a Nanopublication RDF string using a specified RSA private key passed through the profile. The signing operation ensures that the Nanopub is authentically created by the holder of the private key.

Expand All @@ -40,7 +40,7 @@ const signed = new Nanopub(rdfStr).sign(profile);
console.log("Signed:", signed.info());
```

2. **Publishing Nanopubs**
### 📬 Publish Nanopubs

After signing a Nanopub, it can be published to a Nanopub server. This makes the Nanopub accessible to others in the network.

Expand All @@ -49,23 +49,27 @@ const np = await new Nanopub(rdfStr).publish(profile, "");
console.log("Published:", np.info());
```

If the the last argument of `Nanopub.publish` is an empty string it will be published to the [nanopub test server](https://np.test.knowledgepixels.com/). You can easily get the URL of a production server to publish to the network using `getNpServer(true)` (true will pick a random nanopub server on the production network, while false will pick the [main nanopub server](https://server.np.trustyuri.net/)):
#### 🧪 Test and productions servers

If the the last argument of `Nanopub.publish` is an empty string the nanopub will be published to the [test server](https://np.test.knowledgepixels.com/). In this case the nanopub will not be available at https://w3id.org/np/, but at https://np.test.knowledgepixels.com/, e.g. https://np.test.knowledgepixels.com/RAKObyGXmbgTYWj2iN0XGgJv0yWNDQd_DTmAWUouGfIsM

You can publish to the production network by getting the URL of a server using `getNpServer(true)` (true will pick a random nanopub server on the production network, while false will pick the [main nanopub server](https://server.np.trustyuri.net/)):

```typescript
import init, { Nanopub, NpProfile, getNpServer } from "https://unpkg.com/@nanopub/sign";

const np = await new Nanopub(rdfStr).publish(profile, getNpServer(true));
```

3. **Verifying Nanopubs**
### ☑️ Verify Nanopubs

This operation involves checking the integrity of Nanopubs. It ensures that a Nanopub is valid, regardless of whether it is signed or unsigned.

```typescript
const checked = new Nanopub(rdfStr).check();
```

4. **Fetching Nanopubs**
### 📡 Fetch Nanopubs

This function allows you to retrieve Nanopubs from the network using their URI. It's useful for accessing and using Nanopubs created by others.

Expand Down
6 changes: 4 additions & 2 deletions lib/docs/use_python.md
Original file line number Diff line number Diff line change
Expand Up @@ -93,9 +93,11 @@ Run the script:
python sign.py
```

## 📡 Test and production servers
## 🧪 Test and production servers

The [nanopub test server](https://np.test.knowledgepixels.com/) is used if the provided `server_url` is empty, to publish to a production server use `get_np_server(true)`. With true for a random server in the network, and false for the [main nanopub server](https://server.np.trustyuri.net/), defaults to true.
If the provided `server_url` is empty, the nanopub will be published to the [test server](https://np.test.knowledgepixels.com/). In this case the nanopub will not be available at https://w3id.org/np/, but at https://np.test.knowledgepixels.com/, e.g. https://np.test.knowledgepixels.com/RAKObyGXmbgTYWj2iN0XGgJv0yWNDQd_DTmAWUouGfIsM

To publish to a production server use `get_np_server(true)`. With true for a random server in the network, and false for the [main nanopub server](https://server.np.trustyuri.net/), defaults to true.

```python
from nanopub_sign import Nanopub, NpProfile, get_np_server
Expand Down
4 changes: 4 additions & 0 deletions lib/src/nanopub.rs
Original file line number Diff line number Diff line change
Expand Up @@ -378,6 +378,10 @@ impl Nanopub {
};
let published = publish_np(&server_url, &self.get_rdf()?).await?;
if published {
if TEST_SERVER == server_url {
self.info.uri =
Iri::new_unchecked(format!("{}/{}", server_url, self.info.trusty_hash));
}
println!(
"\n🎉 Nanopublication published at {}{}{}",
BOLD, self.info.uri, END
Expand Down

0 comments on commit 616cf0b

Please sign in to comment.