-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Xavier Lau <[email protected]>
- Loading branch information
1 parent
3b90dfd
commit 76d60eb
Showing
5 changed files
with
146 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
name: Release | ||
on: | ||
push: | ||
tags: | ||
- "v[0-9]+.[0-9]+.[0-9]+" | ||
|
||
env: | ||
CARGO_TERM_COLOR: always | ||
|
||
jobs: | ||
build: | ||
name: Build | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Fetch latest code | ||
uses: actions/checkout@v4 | ||
- name: Build | ||
run: cd whitelist-upgrade-hasher && cargo b -r --locked | ||
- name: Compress | ||
run: | | ||
mv whitelist-upgrade-hasher/target/release/wuh . | ||
zstd --ultra -22 -o wuh.zst wuh | ||
- name: Upload artifact | ||
uses: actions/upload-artifact@v4 | ||
with: | ||
name: wuh | ||
path: wuh.zst | ||
retention-days: 1 | ||
|
||
release: | ||
name: Release | ||
runs-on: ubuntu-latest | ||
needs: [build] | ||
steps: | ||
- name: Download artifacts | ||
uses: actions/download-artifact@v4 | ||
- name: Hash | ||
run: | | ||
mkdir -p artifacts | ||
mv wuh* artifacts/ | ||
cd artifacts | ||
sha256sum * | tee ../SHA256 | ||
md5sum * | tee ../MD5 | ||
mv ../SHA256 . | ||
mv ../MD5 . | ||
- name: Publish | ||
uses: softprops/action-gh-release@v1 | ||
with: | ||
discussion_category_name: Announcements | ||
generate_release_notes: true | ||
files: artifacts/* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,5 +5,6 @@ | |
.idea | ||
.vscode | ||
|
||
# Cache | ||
build | ||
# Package manager | ||
## Cargo | ||
target |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
[package] | ||
edition = "2021" | ||
name = "wuh" | ||
version = "0.1.0" | ||
|
||
[dependencies] | ||
# crates.io | ||
array-bytes = { version = "6.2" } | ||
blake2-rfc = { version = "0.2" } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
// std | ||
use std::{env, error::Error, fs}; | ||
// crates.io | ||
use blake2_rfc::blake2b; | ||
|
||
fn main() -> Result<(), Box<dyn Error>> { | ||
let args = env::args().collect::<Vec<_>>(); | ||
let p = args.get(1).expect("missing WASM file path"); | ||
let whitelist_pi = args | ||
.get(2) | ||
.expect("missing whitelist pallet index") | ||
.trim_start_matches("0x"); | ||
let parachain_system_pi = args | ||
.get(3) | ||
.expect("missing parachain system pallet index") | ||
.trim_start_matches("0x"); | ||
let w = fs::read(p)?; | ||
let h1 = blake2b::blake2b(32, &[], &w); | ||
let h1 = h1.as_bytes(); | ||
let mut c = vec![ | ||
u8::from_str_radix(whitelist_pi, 16)?, | ||
0x03, | ||
u8::from_str_radix(parachain_system_pi, 16)?, | ||
0x02, | ||
]; | ||
|
||
c.extend_from_slice(&h1); | ||
c.push(0x01); | ||
|
||
let h2 = blake2b::blake2b(32, &[], &c); | ||
|
||
println!("{}", array_bytes::bytes2hex("0x", h2)); | ||
|
||
Ok(()) | ||
} |