Skip to content

Commit c561f35

Browse files
committed
Release v0.1.2
1 parent c9b6c3a commit c561f35

12 files changed

Lines changed: 174 additions & 52 deletions

File tree

Cargo.lock

Lines changed: 17 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ edition = "2021"
1111
homepage = "https://hack.ink/polkadot-runtime-releaser"
1212
license = "GPL-3.0"
1313
repository = "https://github.com/hack-ink/polkadot-runtime-releaser"
14-
version = "0.1.1"
14+
version = "0.1.2"
1515

1616
[workspace.dependencies]
1717
# crates.io
@@ -21,18 +21,19 @@ blake2 = { version = "0.10" }
2121
chrono = { version = "0.4" }
2222
clap = { version = "4.5" }
2323
color-eyre = { version = "0.6" }
24+
frame-metadata = { version = "18.0" }
2425
ipfs-cid = { version = "2.0" }
2526
md-5 = { version = "0.10" }
2627
parity-scale-codec = { version = "3.6" }
2728
reqwew = { version = "0.6", default-features = false }
2829
sc-executor = { version = "0.40" }
30+
sc-executor-common = { version = "0.35" }
2931
serde = { version = "1.0" }
3032
serde_json = { version = "1.0" }
3133
sha2 = { version = "0.10" }
3234
sp-core = { version = "34.0" }
3335
sp-maybe-compressed-blob = { version = "11.0" }
3436
sp-state-machine = { version = "0.43" }
35-
sp-version = { version = "37.0" }
3637
thiserror = { version = "2.0" }
3738
tokio = { version = "1.42" }
3839
toml = { version = "0.8" }

README.md

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,20 @@ cargo install polkadot-runtime-releaser-cli
2626

2727
#### Install from GitHub
2828
```sh
29-
curl -L ..
29+
# macOS
30+
curl -L https://github.com/hack-ink/polkadot-runtime-releaser/releases/latest/download/prr-aarch64-apple-darwin.zip \
31+
-o prr.zip &&
32+
unzip prr.zip &&
33+
chmod u+x prr &&
34+
rm prr.zip
35+
36+
# Linux
37+
curl -L https://github.com/hack-ink/polkadot-runtime-releaser/releases/latest/download/prr-x86_64-unknown-linux-gnu.tar.gz |
38+
tar xz &&
39+
chmod u+x prr
40+
41+
# If you like to move the binary to `~/.local/bin`. (OPTIONAL)
42+
mkdir -p ~/.local/bin && mv prr ~/.local/bin
3043
```
3144

3245
### Rust Toolchain

action/build/action.yml

Lines changed: 27 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,18 +11,40 @@ inputs:
1111
features:
1212
description: "Features to enable for the runtime crate."
1313
required: false
14-
default: ""
15-
toolchain-version:
14+
toolchain-ver:
1615
description: "Rust toolchain version to use."
1716
required: false
18-
default: "stable"
17+
workdir:
18+
description: "Working directory for the runtime."
19+
required: false
20+
output-dir:
21+
description: "Output directory for the runtime."
22+
required: false
1923

2024
runs:
2125
using: "composite"
2226
steps:
2327
- name: Setup Polkadot Runtime Releaser
2428
shell: bash
25-
run: curl -L https://github.com/hack-ink/polkadot-runtime-releaser/releases/download/v0.1.0/polkadot-runtime-releaser.tar.gz | tar xz && chmod +x prr && mv prr /usr/local/bin/prr
29+
run: curl \
30+
-L https://github.com/hack-ink/polkadot-runtime-releaser/releases/download/v0.1.2/polkadot-runtime-releaser.tar.gz | \
31+
tar xz && \
32+
chmod u+x prr && \
33+
mv prr /usr/local/bin/prr
2634
- name: Build
2735
shell: bash
28-
run: prr build ${{ inputs.runtime }} -f ${{ inputs.features }} -t ${{ inputs.toolchain-version }}
36+
run: |
37+
CMD="prr build ${{ inputs.runtime }}"
38+
if [ ! -z "${{ inputs.features }}" ]; then
39+
CMD="$CMD -f ${{ inputs.features }}"
40+
fi
41+
if [ ! -z "${{ inputs.toolchain-ver }}" ]; then
42+
CMD="$CMD -t ${{ inputs.toolchain-ver }}"
43+
fi
44+
if [ ! -z "${{ inputs.workdir }}" ]; then
45+
CMD="$CMD -d ${{ inputs.workdir }}"
46+
fi
47+
if [ ! -z "${{ inputs.output-dir }}" ]; then
48+
CMD="$CMD -o ${{ inputs.output-dir }}"
49+
fi
50+
eval "$CMD"

action/override/action.yml

Lines changed: 35 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,26 +5,56 @@ branding:
55
color: "blue"
66

77
inputs:
8+
repository:
9+
description: "Repository to fetch the runtime code from."
10+
required: true
11+
ref:
12+
description: "Branch, tag, or commit of the runtime repository to fetch."
13+
required: true
814
runtime:
915
description: "Target runtime crate to build."
1016
required: true
1117
features:
1218
description: "Features to enable for the runtime crate."
13-
required: false
14-
default: ""
15-
toolchain-version:
19+
required: true
20+
toolchain-ver:
1621
description: "Rust toolchain version to use."
1722
required: false
18-
default: "stable"
23+
token:
24+
description: "GitHub token for authentication."
25+
required: true
26+
default: ${{ github.token }}
1927

2028
runs:
2129
using: "composite"
2230
steps:
2331
- name: Fetch latest code
2432
uses: actions/checkout@v4
33+
with:
34+
ref: ${{ inputs.runtime }}
35+
path: override
36+
- name: Fetch runtime code
37+
uses: actions/checkout@v4
38+
with:
39+
repository: ${{ inputs.repository }}
40+
ref: ${{ inputs.ref }}
41+
path: runtime
2542
- name: Build runtime
2643
uses: ../build/action.yml
2744
with:
2845
runtime: ${{ inputs.runtime }}
2946
features: ${{ inputs.features }}
30-
toolchain-version: ${{ inputs.toolchain-version }}
47+
toolchain-ver: ${{ inputs.toolchain-ver }}
48+
workdir: runtime
49+
output-dir: override/${{ inputs.features }}
50+
- name: Commit changes
51+
shell: bash
52+
env:
53+
GITHUB_TOKEN: ${{ inputs.token }}
54+
run: |
55+
cd override
56+
git config --global user.name "github-actions[bot]"
57+
git config --global user.email "41898282+github-actions[bot]@users.noreply.github.com"
58+
git add .
59+
git commit -m "Override `${{ inputs.ref }}`"
60+
git push

action/try-runtime/action.yml

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,9 @@ inputs:
1111
features:
1212
description: "Features to enable for the runtime crate."
1313
required: false
14-
default: ""
15-
toolchain-version:
14+
toolchain-ver:
1615
description: "Rust toolchain version to use."
1716
required: false
18-
default: "stable"
1917
try-runtime-version:
2018
description: "Try Runtime CLI version to use."
2119
required: false
@@ -29,16 +27,30 @@ runs:
2927
steps:
3028
- name: Setup try runtime CLI
3129
shell: bash
32-
run: curl -L https://github.com/paritytech/try-runtime-cli/releases/download/v${{ inputs.try-runtime-version }}/try-runtime-x86_64-unknown-linux-musl -o try-runtime && chmod +x try-runtime && mv try-runtime /usr/local/bin/try-runtime
30+
run: curl \
31+
-L https://github.com/paritytech/try-runtime-cli/releases/download/v${{ inputs.try-runtime-version }}/try-runtime-x86_64-unknown-linux-musl \
32+
-o try-runtime && \
33+
chmod +x try-runtime && \
34+
mv try-runtime /usr/local/bin/try-runtime
3335
- name: Build runtime
3436
uses: ../build/action.yml
3537
with:
3638
runtime: ${{ inputs.runtime }}
3739
features: ${{ inputs.features }}
38-
toolchain-version: ${{ inputs.toolchain-version }}
40+
toolchain-ver: ${{ inputs.toolchain-ver }}
3941
- name: Try runtime
42+
id: try_runtime
4043
shell: bash
41-
run: try-runtime --runtime $(find polkadot-runtime-releaser-output -name "*.compact.compressed.wasm") on-runtime-upgrade live -u ${{ inputs.uri }} 2>&1 | tee output.log
44+
run: |
45+
echo "output<<EOF" >> $GITHUB_OUTPUT
46+
try-runtime \
47+
--runtime $(find ./polkadot-runtime-releaser-output \
48+
-name "*.compact.compressed.wasm") \
49+
on-runtime-upgrade \
50+
live \
51+
-u ${{ inputs.uri }} \
52+
2>&1 >> $GITHUB_OUTPUT
53+
echo "EOF" >> $GITHUB_OUTPUT
4254
- name: Comment
4355
uses: peter-evans/create-or-update-comment@v4
4456
with:
@@ -48,6 +60,6 @@ runs:
4860
<summary>Try Runtime Output for ${{ inputs.runtime }}</summary>
4961
5062
```
51-
${{ cat output.log }}
63+
${{ steps.try_runtime.outputs.output }}
5264
```
5365
</details>

cli/src/cli/inspect.rs

Lines changed: 31 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -24,25 +24,19 @@ impl Run for InspectCmd {
2424
let Self { path, check_version, verbose } = self;
2525
let wasmer = Wasmer::load(&path)?;
2626
let built_at = fs::metadata(&path)?.created()?;
27-
let compressed_size = wasmer.compressed()?.len();
28-
let decompressed_size = wasmer.decompressed()?.len();
27+
let compressed = wasmer.compressed()?.len();
28+
let uncompressed = wasmer.decompressed()?.len();
29+
let size = Size { compressed, uncompressed };
2930
let md5 = hasher::md5(&wasmer.code);
3031
let sha256 = hasher::sha256(&wasmer.code);
3132
let blake2_256 = hasher::blake2_256(&wasmer.code);
3233
let ipfs = ipfs_cid::generate_cid_v0(&wasmer.code)?;
33-
let version = wasmer.runtime_version(verbose)?;
34-
let call_hashes = CallHashes::of(&wasmer, check_version);
35-
let json = serde_json::to_string(&Output {
36-
built_at,
37-
compressed_size,
38-
decompressed_size,
39-
md5,
40-
sha256,
41-
blake2_256,
42-
ipfs,
43-
version,
44-
call_hashes,
45-
})?;
34+
let hash = Hash { md5, sha256, blake2_256, ipfs };
35+
let runtime = wasmer.runtime_version(verbose)?;
36+
let metadata = wasmer.metadata()?.version();
37+
let version = Ver { runtime, metadata };
38+
let call_hash = CallHash::of(&wasmer, check_version);
39+
let json = serde_json::to_string(&Output { built_at, size, hash, version, call_hash })?;
4640

4741
println!("{json}");
4842

@@ -55,29 +49,45 @@ impl Run for InspectCmd {
5549
struct Output {
5650
#[serde(serialize_with = "util::ser_system_time")]
5751
built_at: SystemTime,
52+
size: Size,
53+
hash: Hash,
54+
version: Ver,
55+
call_hash: CallHash,
56+
}
57+
#[derive(Debug, Serialize)]
58+
#[serde(rename_all = "kebab-case")]
59+
struct Size {
5860
#[serde(serialize_with = "util::ser_size_mb")]
59-
compressed_size: usize,
61+
compressed: usize,
6062
#[serde(serialize_with = "util::ser_size_mb")]
61-
decompressed_size: usize,
63+
uncompressed: usize,
64+
}
65+
#[derive(Debug, Serialize)]
66+
#[serde(rename_all = "kebab-case")]
67+
struct Hash {
6268
#[serde(serialize_with = "array_bytes::ser_hex")]
6369
md5: [u8; 16],
6470
#[serde(serialize_with = "array_bytes::ser_hex")]
6571
sha256: [u8; 32],
6672
#[serde(serialize_with = "array_bytes::ser_hex")]
6773
blake2_256: [u8; 32],
6874
ipfs: String,
69-
version: Version,
70-
call_hashes: CallHashes,
7175
}
7276
#[derive(Debug, Serialize)]
7377
#[serde(rename_all = "kebab-case")]
74-
struct CallHashes {
78+
struct Ver {
79+
runtime: Version,
80+
metadata: u32,
81+
}
82+
#[derive(Debug, Serialize)]
83+
#[serde(rename_all = "kebab-case")]
84+
struct CallHash {
7585
#[serde(serialize_with = "array_bytes::ser_hex")]
7686
set_code: [u8; 32],
7787
#[serde(serialize_with = "array_bytes::ser_hex")]
7888
authorized_upgrade: [u8; 32],
7989
}
80-
impl CallHashes {
90+
impl CallHash {
8191
fn of(wasmer: &Wasmer, check_version: bool) -> Self {
8292
let set_code = hasher::blake2_256(
8393
[

cli/src/util.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// std
22
use std::time::SystemTime;
33
// crates.io
4-
use chrono::{DateTime, Utc};
4+
use chrono::{DateTime, SecondsFormat, Utc};
55
use serde::Serializer;
66

77
pub fn ser_system_time<S>(time: &SystemTime, serializer: S) -> Result<S::Ok, S::Error>
@@ -10,7 +10,7 @@ where
1010
{
1111
let date = <DateTime<Utc>>::from(*time);
1212

13-
serializer.serialize_str(&date.to_rfc3339())
13+
serializer.serialize_str(&date.to_rfc3339_opts(SecondsFormat::Secs, true))
1414
}
1515

1616
pub fn ser_size_mb<S>(size: &usize, serializer: S) -> Result<S::Ok, S::Error>
@@ -50,6 +50,6 @@ fn ser_should_work() {
5050
size: 1024 * 1024
5151
})
5252
.unwrap(),
53-
r#"{"time":"2021-08-01T00:00:00+00:00","size":"1.00 MB (1,048,576 bytes)"}"#
53+
r#"{"time":"2021-08-01T00:00:00Z","size":"1.00 MB (1,048,576 bytes)"}"#
5454
)
5555
}

0 commit comments

Comments
 (0)