From 8757aa33bc2e20e49b71b130d5512eefe8c26070 Mon Sep 17 00:00:00 2001 From: Wilfried Kopp Date: Fri, 4 Jun 2021 18:46:11 +0200 Subject: [PATCH 01/13] Fix some tests to be more platform independant --- cli/tests/test.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/cli/tests/test.rs b/cli/tests/test.rs index 76ffc3f..ed6b1e5 100644 --- a/cli/tests/test.rs +++ b/cli/tests/test.rs @@ -32,9 +32,9 @@ mod cli_tests { fn it_gets_a_runtime() { let mut cmd = Command::cargo_bin(env!("CARGO_PKG_NAME")).unwrap(); - let assert = cmd.args(&["get", "--output", "/tmp/runtime.wasm", "wss://rpc.polkadot.io"]).assert(); + let assert = cmd.args(&["get", "--output", "runtime.wasm", "wss://rpc.polkadot.io"]).assert(); assert.success().code(0); - assert!(Path::new("/tmp/runtime.wasm").exists()); + assert!(Path::new("runtime.wasm").exists()); } #[test] @@ -53,11 +53,11 @@ mod cli_tests { #[test] fn it_shows_meta_v12() { let mut cmd = Command::cargo_bin(env!("CARGO_PKG_NAME")).unwrap(); - let assert = cmd.args(&["get", "--chain", "polkadot"]).assert(); + let assert = cmd.args(&["get", "--chain", "polkadot", "--output", "runtime.wasm"]).assert(); assert.success().code(0); let mut cmd = Command::cargo_bin(env!("CARGO_PKG_NAME")).unwrap(); - let assert = cmd.args(&["meta", "/tmp/runtime.wasm"]).assert(); + let assert = cmd.args(&["meta", "runtime.wasm"]).assert(); assert.success().code(0); } } From f9061e52977bf2ebcb56054e6bd20690f8dbd8bc Mon Sep 17 00:00:00 2001 From: Wilfried Kopp Date: Fri, 4 Jun 2021 18:51:32 +0200 Subject: [PATCH 02/13] feat(ci): add a basic github workflow --- .github/workflows/check.yml | 56 +++++++++++++++++++++++++++++++++++++ 1 file changed, 56 insertions(+) create mode 100644 .github/workflows/check.yml diff --git a/.github/workflows/check.yml b/.github/workflows/check.yml new file mode 100644 index 0000000..1ca18e8 --- /dev/null +++ b/.github/workflows/check.yml @@ -0,0 +1,56 @@ +# This workflow runs on every push and checks whether everything looks good + +name: Quick check + +on: + push + +jobs: + setup: + strategy: + fail-fast: false + matrix: + os: ["ubuntu-latest", "macos-latest"] + rust: [stable] + runs-on: ${{ matrix.os }} + steps: + - name: Install Rust stable toolchain + uses: actions-rs/toolchain@v1 + with: + profile: minimal + toolchain: ${{ matrix.rust }} + override: true + components: clippy, rustfmt + + # - name: Cache Dependencies & Build Outputs + # uses: actions/cache@v2 + # with: + # path: | + # ~/.cargo/registry + # ~/.cargo/git + # target + # key: ${{ runner.os }}-${{ matrix.os }}-cargo-${{ hashFiles('**/Cargo.lock') }} + + - uses: actions/checkout@v2 + + - name: Cargo fmt + uses: actions-rs/cargo@v1 + with: + command: fmt + args: --all -- --check + + - name: Cargo clippy + uses: actions-rs/cargo@v1 + with: + command: clippy + args: -- -D warnings + + - name: Cargo test + uses: actions-rs/cargo@v1 + with: + command: test + + - name: Cargo check + uses: actions-rs/cargo@v1 + with: + command: check From 6ab81e599768683d1ea8955cca68128878371974 Mon Sep 17 00:00:00 2001 From: Wilfried Kopp Date: Fri, 4 Jun 2021 19:19:58 +0200 Subject: [PATCH 03/13] WIP: add macos build release workflow --- .github/workflows/build-macos.yml | 49 +++++++++++++++++++++++++++++++ .github/workflows/check.yml | 2 +- 2 files changed, 50 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/build-macos.yml diff --git a/.github/workflows/build-macos.yml b/.github/workflows/build-macos.yml new file mode 100644 index 0000000..42d6771 --- /dev/null +++ b/.github/workflows/build-macos.yml @@ -0,0 +1,49 @@ +# This workflow runs on every push and checks whether everything looks good + +name: Quick check + +on: + push: + tags: + - "v*" + +jobs: + macos: + env: + TARGET_DIR: target/release + + runs-on: macos-latest + steps: + - name: Check tooling + shell: bash + run: | + tar --version + shasum --version + + - name: Extract tag name + id: tag + uses: actions/github-script@0.2.0 + with: + github-token: ${{ secrets.GITHUB_TOKEN }} + script: | + return context.payload.ref.replace(/\/refs\/tags\//, ''); + + - uses: actions/checkout@v2 + + - name: Build release + uses: actions-rs/cargo@v1 + with: + command: build + args: --release --locked + + - name: Compress + shell: bash + run: | + tar -czf ${{ env.TARGET_DIR }}/subwasm-macos-${{ steps.tag.outputs.result }}.tar.gz -C ${{ env.TARGET_DIR }} subwasm + + - name: Compute checksum + shell: bash + run: | + shasum -a 256 ${{ env.TARGET_DIR }}/subwasm-macos-${{ steps.tag.outputs.result }}.tar.gz > ${{ env.TARGET_DIR }}/subwasm-macos-${{ steps.tag.outputs.result }}.tar.gz.sha256 + ls -al + cat ${{ env.TARGET_DIR }}/*{{VERSION}}*.sha256 diff --git a/.github/workflows/check.yml b/.github/workflows/check.yml index 1ca18e8..5998671 100644 --- a/.github/workflows/check.yml +++ b/.github/workflows/check.yml @@ -6,7 +6,7 @@ on: push jobs: - setup: + check: strategy: fail-fast: false matrix: From 42e21bb8d73d639ce1a3a8fde4da09b3aadd43a9 Mon Sep 17 00:00:00 2001 From: Wilfried Kopp Date: Fri, 4 Jun 2021 20:18:31 +0200 Subject: [PATCH 04/13] WIP Fix CI --- .github/workflows/build-linux.yml | 44 +++++++++++++++++ .github/workflows/build-macos.yml | 6 ++- .github/workflows/daily-check.yml | 48 +++++++++++++++++++ .../workflows/{check.yml => quick-check.yml} | 9 +--- 4 files changed, 98 insertions(+), 9 deletions(-) create mode 100644 .github/workflows/build-linux.yml create mode 100644 .github/workflows/daily-check.yml rename .github/workflows/{check.yml => quick-check.yml} (85%) diff --git a/.github/workflows/build-linux.yml b/.github/workflows/build-linux.yml new file mode 100644 index 0000000..c845ede --- /dev/null +++ b/.github/workflows/build-linux.yml @@ -0,0 +1,44 @@ +# This workflow runs on every push and checks whether everything looks good + +name: Quick check + +on: + push: + tags: + - "v*" + +jobs: + linux: + env: + TARGET_DIR: target/release + + runs-on: ubuntu-latest + steps: + - name: Check tooling + shell: bash + run: | + tar --version + shasum --version + + - name: Extract tag name + id: tag + uses: actions/github-script@0.2.0 + with: + github-token: ${{ secrets.GITHUB_TOKEN }} + script: | + return context.payload.ref.replace(/\/refs\/tags\//, ''); + + - uses: actions/checkout@v2 + + - name: Build release + uses: actions-rs/cargo@v1 + with: + command: build + args: --release --locked + + - name: Echo + shell: bash + run: | + echo ${{ steps.tag.outputs.result }} + + \ No newline at end of file diff --git a/.github/workflows/build-macos.yml b/.github/workflows/build-macos.yml index 42d6771..36efd85 100644 --- a/.github/workflows/build-macos.yml +++ b/.github/workflows/build-macos.yml @@ -27,6 +27,8 @@ jobs: github-token: ${{ secrets.GITHUB_TOKEN }} script: | return context.payload.ref.replace(/\/refs\/tags\//, ''); + - name: Tag name to ENV + run: echo "TAG=${{ steps.tag.outputs.result }}" >> $GITHUB_ENV - uses: actions/checkout@v2 @@ -39,11 +41,11 @@ jobs: - name: Compress shell: bash run: | - tar -czf ${{ env.TARGET_DIR }}/subwasm-macos-${{ steps.tag.outputs.result }}.tar.gz -C ${{ env.TARGET_DIR }} subwasm + tar -czf ${{ env.TARGET_DIR }}/subwasm-macos-${{ env.TAG }}.tar.gz -C ${{ env.TARGET_DIR }} subwasm - name: Compute checksum shell: bash run: | - shasum -a 256 ${{ env.TARGET_DIR }}/subwasm-macos-${{ steps.tag.outputs.result }}.tar.gz > ${{ env.TARGET_DIR }}/subwasm-macos-${{ steps.tag.outputs.result }}.tar.gz.sha256 + shasum -a 256 ${{ env.TARGET_DIR }}/subwasm-macos-${{ env.TAG }}.tar.gz > ${{ env.TARGET_DIR }}/subwasm-macos-${{ env.TAG }}.tar.gz.sha256 ls -al cat ${{ env.TARGET_DIR }}/*{{VERSION}}*.sha256 diff --git a/.github/workflows/daily-check.yml b/.github/workflows/daily-check.yml new file mode 100644 index 0000000..6621ea4 --- /dev/null +++ b/.github/workflows/daily-check.yml @@ -0,0 +1,48 @@ +# This workflow runs on every push and checks whether everything looks good + +name: Daily Check + +on: + schedule: + - "0 3 * * *" + +jobs: + check: + strategy: + fail-fast: false + matrix: + os: ["ubuntu-latest", "macos-latest", "windows-latest"] + rust: ["stable", "nightly"] + runs-on: ${{ matrix.os }} + steps: + - name: Install Rust stable toolchain + uses: actions-rs/toolchain@v1 + with: + profile: minimal + toolchain: ${{ matrix.rust }} + override: true + components: clippy, rustfmt + + - uses: actions/checkout@v2 + + - name: Cargo fmt + uses: actions-rs/cargo@v1 + with: + command: fmt + args: --all -- --check + + - name: Cargo clippy + uses: actions-rs/cargo@v1 + with: + command: clippy + args: -- -D warnings + + - name: Cargo test + uses: actions-rs/cargo@v1 + with: + command: test + + - name: Cargo check + uses: actions-rs/cargo@v1 + with: + command: check diff --git a/.github/workflows/check.yml b/.github/workflows/quick-check.yml similarity index 85% rename from .github/workflows/check.yml rename to .github/workflows/quick-check.yml index 5998671..2b99d71 100644 --- a/.github/workflows/check.yml +++ b/.github/workflows/quick-check.yml @@ -7,18 +7,13 @@ on: jobs: check: - strategy: - fail-fast: false - matrix: - os: ["ubuntu-latest", "macos-latest"] - rust: [stable] - runs-on: ${{ matrix.os }} + runs-on: ubuntu-latest steps: - name: Install Rust stable toolchain uses: actions-rs/toolchain@v1 with: profile: minimal - toolchain: ${{ matrix.rust }} + toolchain: stable override: true components: clippy, rustfmt From c5fb760744571a4c897dc874ad2275e00ce68278 Mon Sep 17 00:00:00 2001 From: Wilfried Kopp Date: Fri, 4 Jun 2021 20:39:29 +0200 Subject: [PATCH 05/13] Fix capture of the tag name --- .github/workflows/build-linux.yml | 11 ++--------- .github/workflows/build-macos.yml | 9 +-------- .github/workflows/daily-check.yml | 2 +- .github/workflows/quick-check.yml | 2 +- 4 files changed, 5 insertions(+), 19 deletions(-) diff --git a/.github/workflows/build-linux.yml b/.github/workflows/build-linux.yml index c845ede..f5b7114 100644 --- a/.github/workflows/build-linux.yml +++ b/.github/workflows/build-linux.yml @@ -21,12 +21,7 @@ jobs: shasum --version - name: Extract tag name - id: tag - uses: actions/github-script@0.2.0 - with: - github-token: ${{ secrets.GITHUB_TOKEN }} - script: | - return context.payload.ref.replace(/\/refs\/tags\//, ''); + run: echo "TAG=${GITHUB_REF/\/refs\/tag\//}" >> $GITHUB_ENV - uses: actions/checkout@v2 @@ -39,6 +34,4 @@ jobs: - name: Echo shell: bash run: | - echo ${{ steps.tag.outputs.result }} - - \ No newline at end of file + echo ${{ env.TAG }} diff --git a/.github/workflows/build-macos.yml b/.github/workflows/build-macos.yml index 36efd85..0e16f2d 100644 --- a/.github/workflows/build-macos.yml +++ b/.github/workflows/build-macos.yml @@ -21,14 +21,7 @@ jobs: shasum --version - name: Extract tag name - id: tag - uses: actions/github-script@0.2.0 - with: - github-token: ${{ secrets.GITHUB_TOKEN }} - script: | - return context.payload.ref.replace(/\/refs\/tags\//, ''); - - name: Tag name to ENV - run: echo "TAG=${{ steps.tag.outputs.result }}" >> $GITHUB_ENV + run: echo "TAG=${GITHUB_REF/\/refs\/tag\//}" >> $GITHUB_ENV - uses: actions/checkout@v2 diff --git a/.github/workflows/daily-check.yml b/.github/workflows/daily-check.yml index 6621ea4..4eaa914 100644 --- a/.github/workflows/daily-check.yml +++ b/.github/workflows/daily-check.yml @@ -7,7 +7,7 @@ on: - "0 3 * * *" jobs: - check: + daily_check: strategy: fail-fast: false matrix: diff --git a/.github/workflows/quick-check.yml b/.github/workflows/quick-check.yml index 2b99d71..accc17d 100644 --- a/.github/workflows/quick-check.yml +++ b/.github/workflows/quick-check.yml @@ -6,7 +6,7 @@ on: push jobs: - check: + quick_check: runs-on: ubuntu-latest steps: - name: Install Rust stable toolchain From ebe500b4282167ea357d90facf96112b274dadc2 Mon Sep 17 00:00:00 2001 From: Wilfried Kopp Date: Fri, 4 Jun 2021 20:40:59 +0200 Subject: [PATCH 06/13] Fix daily check cron --- .github/workflows/daily-check.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/daily-check.yml b/.github/workflows/daily-check.yml index 4eaa914..c96d49a 100644 --- a/.github/workflows/daily-check.yml +++ b/.github/workflows/daily-check.yml @@ -4,7 +4,7 @@ name: Daily Check on: schedule: - - "0 3 * * *" + - cron: "0 3 * * *" jobs: daily_check: From fd3d0e28633f784e30594fcd4a95c09dec575cf2 Mon Sep 17 00:00:00 2001 From: Wilfried Kopp Date: Fri, 4 Jun 2021 20:54:55 +0200 Subject: [PATCH 07/13] WIP And it's fixing again... --- .github/workflows/build-linux.yml | 19 +++++++------------ .github/workflows/build-macos.yml | 6 ++++-- 2 files changed, 11 insertions(+), 14 deletions(-) diff --git a/.github/workflows/build-linux.yml b/.github/workflows/build-linux.yml index f5b7114..cf6f331 100644 --- a/.github/workflows/build-linux.yml +++ b/.github/workflows/build-linux.yml @@ -14,24 +14,19 @@ jobs: runs-on: ubuntu-latest steps: - - name: Check tooling - shell: bash - run: | - tar --version - shasum --version - - name: Extract tag name - run: echo "TAG=${GITHUB_REF/\/refs\/tag\//}" >> $GITHUB_ENV - + run: | + TAG=${GITHUB_REF/refs\/tags\//} + echo "TAG=$TAG" >> $GITHUB_ENV - uses: actions/checkout@v2 - name: Build release uses: actions-rs/cargo@v1 with: - command: build - args: --release --locked + command: install + args: cargo-deb - - name: Echo + - name: Build deb shell: bash run: | - echo ${{ env.TAG }} + cargo deb diff --git a/.github/workflows/build-macos.yml b/.github/workflows/build-macos.yml index 0e16f2d..0496fab 100644 --- a/.github/workflows/build-macos.yml +++ b/.github/workflows/build-macos.yml @@ -21,8 +21,10 @@ jobs: shasum --version - name: Extract tag name - run: echo "TAG=${GITHUB_REF/\/refs\/tag\//}" >> $GITHUB_ENV - + run: | + TAG=${GITHUB_REF/refs\/tags\//} + echo "TAG=$TAG" >> $GITHUB_ENV + - uses: actions/checkout@v2 - name: Build release From dda2235a907fe5377a9cb30fc48aac1f4b2e9979 Mon Sep 17 00:00:00 2001 From: Wilfried Kopp Date: Fri, 4 Jun 2021 21:51:39 +0200 Subject: [PATCH 08/13] WIP --- .github/workflows/build-linux.yml | 5 ++-- .github/workflows/build-macos.yml | 44 +++++++++++++++++++++++-------- Formula/template.rb | 11 ++++++++ 3 files changed, 47 insertions(+), 13 deletions(-) create mode 100644 Formula/template.rb diff --git a/.github/workflows/build-linux.yml b/.github/workflows/build-linux.yml index cf6f331..15a2baa 100644 --- a/.github/workflows/build-linux.yml +++ b/.github/workflows/build-linux.yml @@ -1,6 +1,6 @@ # This workflow runs on every push and checks whether everything looks good -name: Quick check +name: Build Linux Binaries on: push: @@ -29,4 +29,5 @@ jobs: - name: Build deb shell: bash run: | - cargo deb + cargo deb -p subwasm + \ No newline at end of file diff --git a/.github/workflows/build-macos.yml b/.github/workflows/build-macos.yml index 0496fab..4281741 100644 --- a/.github/workflows/build-macos.yml +++ b/.github/workflows/build-macos.yml @@ -1,6 +1,6 @@ # This workflow runs on every push and checks whether everything looks good -name: Quick check +name: Build MacOS Binaries on: push: @@ -24,7 +24,7 @@ jobs: run: | TAG=${GITHUB_REF/refs\/tags\//} echo "TAG=$TAG" >> $GITHUB_ENV - + - uses: actions/checkout@v2 - name: Build release @@ -33,14 +33,36 @@ jobs: command: build args: --release --locked - - name: Compress - shell: bash - run: | - tar -czf ${{ env.TARGET_DIR }}/subwasm-macos-${{ env.TAG }}.tar.gz -C ${{ env.TARGET_DIR }} subwasm + # - name: Compress + # shell: bash + # run: | + # tar -czf ${{ env.TARGET_DIR }}/subwasm-macos-${{ env.TAG }}.tar.gz -C ${{ env.TARGET_DIR }} subwasm - - name: Compute checksum - shell: bash + # - name: Compute checksum + # shell: bash + # run: | + # shasum -a 256 ${{ env.TARGET_DIR }}/subwasm-macos-${{ env.TAG }}.tar.gz > ${{ env.TARGET_DIR }}/subwasm-macos-${{ env.TAG }}.tar.gz.sha256 + # ls -al + # cat ${{ env.TARGET_DIR }}/*${{ env.TAG }}*.sha256 + + - name: Upload artifacts + uses: actions/upload-artifact@v2 + with: + name: subwasm-macos-package-${{ github.sha }} + path: | + ${{ env.TARGET_DIR }}/subwasm + + - name: Download Artifact + uses: actions/download-artifact@v2 + with: + name: subwasm-macos-package-${{ github.sha }} + path: artifact + + - name: Compute sha256 run: | - shasum -a 256 ${{ env.TARGET_DIR }}/subwasm-macos-${{ env.TAG }}.tar.gz > ${{ env.TARGET_DIR }}/subwasm-macos-${{ env.TAG }}.tar.gz.sha256 - ls -al - cat ${{ env.TARGET_DIR }}/*{{VERSION}}*.sha256 + ls -al artifacts + ZIP=`ls artifacts/*.zip | head -n 1` + echo $ZIP + shasum -a 256 artifacts/$ZIP > artifacts/$ZIP.sha256 + cat artifacts/$ZIP.sha256 + diff --git a/Formula/template.rb b/Formula/template.rb new file mode 100644 index 0000000..8f5c163 --- /dev/null +++ b/Formula/template.rb @@ -0,0 +1,11 @@ +class Subwasm < Formula + desc "CLI utility to get information about Substrate based chains Runtime WASM" + homepage "https://github.com/chevdor/subwasm" + url "https://github.com/chevdor/subwasm/releases/download/v{{ version }}/subwasm-macos-v{{ version }}.tar.gz" + sha256 "{{ sha256 }}" + version "{{ version }}" + + def install + bin.install "subwasm" + end + end From 9a3c8b569199eee172cc6796b1d039283213a123 Mon Sep 17 00:00:00 2001 From: Wilfried Kopp Date: Fri, 4 Jun 2021 22:09:57 +0200 Subject: [PATCH 09/13] Fixes for Linux and MacOS --- .github/workflows/build-macos.yml | 2 +- cli/Cargo.toml | 17 +++++++++++++++-- cli/LICENSE | 7 +++++++ 3 files changed, 23 insertions(+), 3 deletions(-) create mode 100644 cli/LICENSE diff --git a/.github/workflows/build-macos.yml b/.github/workflows/build-macos.yml index 4281741..fa4fae9 100644 --- a/.github/workflows/build-macos.yml +++ b/.github/workflows/build-macos.yml @@ -56,7 +56,7 @@ jobs: uses: actions/download-artifact@v2 with: name: subwasm-macos-package-${{ github.sha }} - path: artifact + path: artifacts - name: Compute sha256 run: | diff --git a/cli/Cargo.toml b/cli/Cargo.toml index 08b0826..358c09d 100644 --- a/cli/Cargo.toml +++ b/cli/Cargo.toml @@ -2,12 +2,12 @@ authors = ["chevdor ", "Wilfried Kopp Date: Fri, 4 Jun 2021 22:23:43 +0200 Subject: [PATCH 10/13] Add generated deb to the artifacts --- .github/workflows/build-linux.yml | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build-linux.yml b/.github/workflows/build-linux.yml index 15a2baa..38c6d22 100644 --- a/.github/workflows/build-linux.yml +++ b/.github/workflows/build-linux.yml @@ -20,7 +20,7 @@ jobs: echo "TAG=$TAG" >> $GITHUB_ENV - uses: actions/checkout@v2 - - name: Build release + - name: Install cargo deb uses: actions-rs/cargo@v1 with: command: install @@ -30,4 +30,11 @@ jobs: shell: bash run: | cargo deb -p subwasm - \ No newline at end of file + + - name: Upload artifacts + uses: actions/upload-artifact@v2 + with: + name: subwasm-linux-deb-${{ github.sha }} + path: | + target/debian/*.deb + \ No newline at end of file From 04e4337e9eb14d3e4799415e494f8ff3aa0f3feb Mon Sep 17 00:00:00 2001 From: Wilfried Kopp Date: Fri, 4 Jun 2021 22:28:35 +0200 Subject: [PATCH 11/13] Comment out experiment --- .github/workflows/build-macos.yml | 25 ++++++++++++------------- 1 file changed, 12 insertions(+), 13 deletions(-) diff --git a/.github/workflows/build-macos.yml b/.github/workflows/build-macos.yml index fa4fae9..2298f3b 100644 --- a/.github/workflows/build-macos.yml +++ b/.github/workflows/build-macos.yml @@ -52,17 +52,16 @@ jobs: path: | ${{ env.TARGET_DIR }}/subwasm - - name: Download Artifact - uses: actions/download-artifact@v2 - with: - name: subwasm-macos-package-${{ github.sha }} - path: artifacts + # - name: Download Artifact + # uses: actions/download-artifact@v2 + # with: + # name: subwasm-macos-package-${{ github.sha }} + # path: artifacts - - name: Compute sha256 - run: | - ls -al artifacts - ZIP=`ls artifacts/*.zip | head -n 1` - echo $ZIP - shasum -a 256 artifacts/$ZIP > artifacts/$ZIP.sha256 - cat artifacts/$ZIP.sha256 - + # - name: Compute sha256 + # run: | + # ls -al artifacts + # ZIP=`ls artifacts/*.zip | head -n 1` + # echo $ZIP + # shasum -a 256 artifacts/$ZIP > artifacts/$ZIP.sha256 + # cat artifacts/$ZIP.sha256 From a057dfd7d17fb5477f0b9e4ebd62e747433563ec Mon Sep 17 00:00:00 2001 From: Wilfried Kopp Date: Wed, 16 Jun 2021 11:30:53 +0200 Subject: [PATCH 12/13] ci: wip --- .github/workflows/build-linux.yml | 74 +++++++++++++++++++++++++++++-- 1 file changed, 70 insertions(+), 4 deletions(-) diff --git a/.github/workflows/build-linux.yml b/.github/workflows/build-linux.yml index 38c6d22..5a6baa2 100644 --- a/.github/workflows/build-linux.yml +++ b/.github/workflows/build-linux.yml @@ -19,6 +19,8 @@ jobs: TAG=${GITHUB_REF/refs\/tags\//} echo "TAG=$TAG" >> $GITHUB_ENV - uses: actions/checkout@v2 + - name: Get Release Version + run: echo "RELEASE_VERSION=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV - name: Install cargo deb uses: actions-rs/cargo@v1 @@ -29,12 +31,76 @@ jobs: - name: Build deb shell: bash run: | - cargo deb -p subwasm + cargo deb -p subwasm -o "subwasm_linux_amd64_${{ env.RELEASE_VERSION }}.deb" - name: Upload artifacts uses: actions/upload-artifact@v2 with: - name: subwasm-linux-deb-${{ github.sha }} + name: subwasm_linux_amd64_${{ env.RELEASE_VERSION }} path: | - target/debian/*.deb - \ No newline at end of file + subwasm_linux_amd64_${{ env.RELEASE_VERSION }}.deb + + create_draft: + needs: ["linux"] + name: Create Draft + runs-on: ubuntu-latest + outputs: + release_url: ${{ steps.create-release.outputs.html_url }} + asset_upload_url: ${{ steps.create-release.outputs.upload_url }} + steps: + - uses: actions/checkout@v2 + - name: Get Release Version + run: echo "RELEASE_VERSION=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV + + - uses: actions/download-artifact@v2 + + - name: Generate changelog + id: change_log + run: | + OUT=`git log $(git describe --tags --abbrev=0)..HEAD --oneline` + echo "::set-output name=changes::$OUT" + + - name: Create Draft Release + id: create-release + uses: actions/create-release@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + tag_name: ${{ env.RELEASE_VERSION }} + release_name: Tera ${{ env.RELEASE_VERSION }} + body: | + # Description + You can find the changelogs below. + + # Downloads + Download the binary for your OS from below: + - **Linux** + - [deb package](https://github.com/chevdor/subwasm/releases/download/${{ env.RELEASE_VERSION }}/subwasm_linux_amd64_${{ env.RELEASE_VERSION }}.deb) + + # Release Highlights + ---- + These were the highlights. Check below for the full changelog :point_down: + ${{ steps.change_log.outputs.changes }} + draft: true + + publish-binaries: + runs-on: ubuntu-latest + needs: ["create_draft"] + steps: + - uses: actions/checkout@v2 + - name: Get Release Version + run: echo "RELEASE_VERSION=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV + - uses: actions/download-artifact@v2 + - name: debug + shell: bash + run: | + echo ${{ github.workspace }} + - name: Upload binaries + uses: actions/upload-release-asset@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + upload_url: ${{ needs.create_draft.outputs.asset_upload_url }} + asset_path: "subwasm_linux_amd64_${{ env.RELEASE_VERSION }}/subwasm_linux_amd64_${{ env.RELEASE_VERSION }}.deb" + asset_name: "subwasm_linux_amd64_${{ env.RELEASE_VERSION }}.deb" + asset_content_type: application/vnd.debian.binary-package From 82b6b887b14c061af16559d20bf98773417df95a Mon Sep 17 00:00:00 2001 From: Wilfried Kopp Date: Fri, 18 Jun 2021 10:57:19 +0200 Subject: [PATCH 13/13] ci: fix CI --- .github/workflows/build-linux.yml | 106 --------------- .github/workflows/release.yml | 210 ++++++++++++++++++++++++++++++ Formula/template.rb | 11 -- templates/changelog.md | 13 ++ templates/formula.rb | 14 ++ templates/release.md | 35 +++++ 6 files changed, 272 insertions(+), 117 deletions(-) delete mode 100644 .github/workflows/build-linux.yml create mode 100644 .github/workflows/release.yml delete mode 100644 Formula/template.rb create mode 100644 templates/changelog.md create mode 100644 templates/formula.rb create mode 100644 templates/release.md diff --git a/.github/workflows/build-linux.yml b/.github/workflows/build-linux.yml deleted file mode 100644 index 5a6baa2..0000000 --- a/.github/workflows/build-linux.yml +++ /dev/null @@ -1,106 +0,0 @@ -# This workflow runs on every push and checks whether everything looks good - -name: Build Linux Binaries - -on: - push: - tags: - - "v*" - -jobs: - linux: - env: - TARGET_DIR: target/release - - runs-on: ubuntu-latest - steps: - - name: Extract tag name - run: | - TAG=${GITHUB_REF/refs\/tags\//} - echo "TAG=$TAG" >> $GITHUB_ENV - - uses: actions/checkout@v2 - - name: Get Release Version - run: echo "RELEASE_VERSION=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV - - - name: Install cargo deb - uses: actions-rs/cargo@v1 - with: - command: install - args: cargo-deb - - - name: Build deb - shell: bash - run: | - cargo deb -p subwasm -o "subwasm_linux_amd64_${{ env.RELEASE_VERSION }}.deb" - - - name: Upload artifacts - uses: actions/upload-artifact@v2 - with: - name: subwasm_linux_amd64_${{ env.RELEASE_VERSION }} - path: | - subwasm_linux_amd64_${{ env.RELEASE_VERSION }}.deb - - create_draft: - needs: ["linux"] - name: Create Draft - runs-on: ubuntu-latest - outputs: - release_url: ${{ steps.create-release.outputs.html_url }} - asset_upload_url: ${{ steps.create-release.outputs.upload_url }} - steps: - - uses: actions/checkout@v2 - - name: Get Release Version - run: echo "RELEASE_VERSION=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV - - - uses: actions/download-artifact@v2 - - - name: Generate changelog - id: change_log - run: | - OUT=`git log $(git describe --tags --abbrev=0)..HEAD --oneline` - echo "::set-output name=changes::$OUT" - - - name: Create Draft Release - id: create-release - uses: actions/create-release@v1 - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - with: - tag_name: ${{ env.RELEASE_VERSION }} - release_name: Tera ${{ env.RELEASE_VERSION }} - body: | - # Description - You can find the changelogs below. - - # Downloads - Download the binary for your OS from below: - - **Linux** - - [deb package](https://github.com/chevdor/subwasm/releases/download/${{ env.RELEASE_VERSION }}/subwasm_linux_amd64_${{ env.RELEASE_VERSION }}.deb) - - # Release Highlights - ---- - These were the highlights. Check below for the full changelog :point_down: - ${{ steps.change_log.outputs.changes }} - draft: true - - publish-binaries: - runs-on: ubuntu-latest - needs: ["create_draft"] - steps: - - uses: actions/checkout@v2 - - name: Get Release Version - run: echo "RELEASE_VERSION=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV - - uses: actions/download-artifact@v2 - - name: debug - shell: bash - run: | - echo ${{ github.workspace }} - - name: Upload binaries - uses: actions/upload-release-asset@v1 - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - with: - upload_url: ${{ needs.create_draft.outputs.asset_upload_url }} - asset_path: "subwasm_linux_amd64_${{ env.RELEASE_VERSION }}/subwasm_linux_amd64_${{ env.RELEASE_VERSION }}.deb" - asset_name: "subwasm_linux_amd64_${{ env.RELEASE_VERSION }}.deb" - asset_content_type: application/vnd.debian.binary-package diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..9a9d8eb --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,210 @@ +# This workflow runs on every push and checks whether everything looks good + +name: Release + +on: + push: + tags: + - "v*" + +jobs: + linux: + env: + TARGET_DIR: target/release + + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + + - name: Install latest nightly + uses: actions-rs/toolchain@v1 + with: + toolchain: nightly + override: true + components: rustfmt, clippy + + - name: Install cargo deb + uses: actions-rs/cargo@v1 + with: + command: install + args: cargo-deb + + - name: Build debian package + shell: bash + run: | + cargo deb -p subwasm -o "subwasm_linux_amd64.deb" + + - name: Upload artifacts + uses: actions/upload-artifact@v2 + with: + name: linux + path: | + subwasm_linux_amd64.deb + + macos: + env: + TARGET_DIR: target/release + + runs-on: macos-latest + steps: + - uses: actions/checkout@v2 + with: + fetch-depth: 0 + + - name: Get Release Version + run: | + echo GITHUB_REF=$GITHUB_REF + RELEASE_VERSION=${GITHUB_REF#refs/*/} + RAW_VERSION=${RELEASE_VERSION:1} + echo "RELEASE_VERSION=$RELEASE_VERSION" >> $GITHUB_ENV + echo "RAW_VERSION=$RAW_VERSION" >> $GITHUB_ENV + echo "SHORT_SHA=${GITHUB_SHA::8}" >> $GITHUB_ENV + + - name: Install latest nightly + uses: actions-rs/toolchain@v1 + with: + toolchain: nightly + override: true + components: rustfmt, clippy + + - name: Check tooling + shell: bash + run: | + tar --version + shasum --version + + - name: Build MacOS binary + shell: bash + run: | + cargo build --release + ls -al "${{ env.TARGET_DIR }}/subwasm" + + - name: Compress & sha256 + run: | + tar -czf ${{ env.TARGET_DIR }}/subwasm_macos.tar.gz -C ${{ env.TARGET_DIR }} subwasm + SHA256=$(shasum -a 256 ${{ env.TARGET_DIR }}/subwasm_macos.tar.gz | awk '{ print $1}' | tee ${{ env.TARGET_DIR }}/subwasm_macos.tar.gz.sha256) + echo SHA256: $SHA256 + echo "SHA256=$SHA256" >> $GITHUB_ENV + + - name: Upload MacOS artifacts + uses: actions/upload-artifact@v2 + with: + name: macos + path: | + ${{ env.TARGET_DIR }}/subwasm + ${{ env.TARGET_DIR }}/subwasm_macos.tar.gz + ${{ env.TARGET_DIR }}/subwasm_macos.tar.gz.sha256 + + - name: Install tera MacOS binary v0.1.3 + run: | + URL=https://github.com/chevdor/tera-cli/releases/download/v0.1.3/tera-macos-v0.1.3.tar.gz + wget $URL + tar xvf tera-macos-v0.1.3.tar.gz -C /usr/local/bin + tera --version + + # We do that before checking out master (in case we were not in master already) + - name: Prepare new Formula + env: + NAME: Tera + DESCRIPTION: "A command line utility written in Rust download, inspect and compare Substrate based chains WASM Runtimes" + SITE: https://github.com + REPO: chevdor/subwasm + SHA256: ${{env.SHA256}} + VERSION: ${{env.RAW_VERSION}} + run: | + tera --version + tera --template templates/formula.rb --env-only > $HOME/subwasm.rb + cat $HOME/subwasm.rb + + - name: Update Homebrew Formula + run: | + cp -f $HOME/subwasm.rb Formula/subwasm.rb + git config --global user.name 'TeraBot' + git config --global user.email 'chevdor@users.noreply.github.com' + git commit Formula/subwasm.rb -m "build: new homebrew formula for ${{ env.RELEASE_VERSION }}" + git push origin HEAD:master + + create_draft: + needs: ["linux", "macos"] + name: Create Draft + runs-on: ubuntu-latest + outputs: + release_url: ${{ steps.create-release.outputs.html_url }} + asset_upload_url: ${{ steps.create-release.outputs.upload_url }} + steps: + - uses: actions/checkout@v2 + with: + fetch-depth: 0 + - name: Get Release Version + run: | + echo "RELEASE_VERSION=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV + echo "SHORT_SHA=${GITHUB_SHA::8}" >> $GITHUB_ENV + - uses: actions/download-artifact@v2 + + - name: Install tera v0.1.3 + run: | + URL=https://github.com/chevdor/tera-cli/releases/download/v0.1.3/tera-cli_linux_amd64.deb + wget $URL + sudo dpkg -i tera-cli_linux_amd64.deb + tera --version + + - name: Generate changelog + id: change_log + run: | + LAST_TAG=$(git describe --tags --abbrev=0 ${{ env.RELEASE_VERSION }}^ ) + JSON=$(git log $LAST_TAG..HEAD \ + --pretty=format:'{ "commit": "%H", "short_sha": "%h", "author": "%an", "date": "%ad", "message": "%s"},' \ + $@ | \ + perl -pe 'BEGIN{print "{ \"since\": \"'${LAST_TAG}'\", \"commits\": ["}; END{print "]}"}' | \ + perl -pe 's/},]/}]/') + echo $JSON | tera --template templates/changelog.md --stdin > changelog.md + + - name: Render release notes + run: | + export DEBIAN_URL="https://github.com/chevdor/subwasm/releases/download/${{ env.RELEASE_VERSION }}/subwasm_linux_amd64.deb" + export MACOS_TGZ_URL="https://github.com/chevdor/subwasm/releases/download/${{ env.RELEASE_VERSION }}/subwasm_macos.tar.gz" + export CHANGELOG=$(cat changelog.md) + tera --env --env-only --template templates/release.md > RELEASE_NOTES.md + + - name: Create Release + id: create-release + uses: actions/create-release@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + tag_name: ${{ env.RELEASE_VERSION }} + release_name: Subwasm ${{ env.RELEASE_VERSION }} (${{ env.SHORT_SHA }}) + body_path: ./RELEASE_NOTES.md + draft: true + + publish-binaries: + runs-on: ubuntu-latest + needs: ["create_draft"] + steps: + - uses: actions/checkout@v2 + - name: Get Release Version + run: | + echo "RELEASE_VERSION=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV + echo "SHORT_SHA=${GITHUB_SHA::8}" >> $GITHUB_ENV + + - uses: actions/download-artifact@v2 + + - name: Upload Debian package + uses: actions/upload-release-asset@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + upload_url: ${{ needs.create_draft.outputs.asset_upload_url }} + asset_path: "linux/subwasm_linux_amd64.deb" + asset_name: "subwasm_linux_amd64_${{ env.RELEASE_VERSION }}.deb" + asset_content_type: application/vnd.debian.binary-package + + - name: Upload MacOS archive + uses: actions/upload-release-asset@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + upload_url: ${{ needs.create_draft.outputs.asset_upload_url }} + asset_path: "macos/subwasm_macos.tar.gz" + asset_name: "subwasm_macos_${{ env.RELEASE_VERSION }}.tar.gz" + asset_content_type: application/gzip diff --git a/Formula/template.rb b/Formula/template.rb deleted file mode 100644 index 8f5c163..0000000 --- a/Formula/template.rb +++ /dev/null @@ -1,11 +0,0 @@ -class Subwasm < Formula - desc "CLI utility to get information about Substrate based chains Runtime WASM" - homepage "https://github.com/chevdor/subwasm" - url "https://github.com/chevdor/subwasm/releases/download/v{{ version }}/subwasm-macos-v{{ version }}.tar.gz" - sha256 "{{ sha256 }}" - version "{{ version }}" - - def install - bin.install "subwasm" - end - end diff --git a/templates/changelog.md b/templates/changelog.md new file mode 100644 index 0000000..f98d036 --- /dev/null +++ b/templates/changelog.md @@ -0,0 +1,13 @@ +{% if commits | length %} +# Changes since {{ since }} + +{% for commit in commits %} +{%- set s = commit.message | split(pat=":") -%} +{% if s | length > 1 -%} + - {{ commit.short_sha }}: {{ s.0 }} -{{ s.1 }} [@{{ commit.author }}] +{% else -%} + - {{ commit.short_sha }}: {{ commit.message }} [@{{ commit.author }}] +{% endif -%} +{%- endfor %} + +{% endif -%} diff --git a/templates/formula.rb b/templates/formula.rb new file mode 100644 index 0000000..62babf7 --- /dev/null +++ b/templates/formula.rb @@ -0,0 +1,14 @@ +{% set BIN = BIN | default(value=NAME | lower) %} +{%- set HOMEPAGE = HOMEPAGE | default(value=SITE ~ "/" ~ REPO) -%} + +class {{ NAME }} < Formula + desc "{{ DESCRIPTION }}" + homepage "{{ HOMEPAGE }}" + url "{{ SITE }}/{{ REPO }}/releases/download/v{{ VERSION }}/{{ ARCHIVE | default(value=BIN ~"-macos-v" ~ VERSION) }}.tar.gz" + sha256 "{{ SHA256 }}" + version "{{ VERSION }}" + + def install + bin.install "{{ BIN }}" + end +end \ No newline at end of file diff --git a/templates/release.md b/templates/release.md new file mode 100644 index 0000000..5332e10 --- /dev/null +++ b/templates/release.md @@ -0,0 +1,35 @@ +# Description + +You can find the changelogs below. + +# Downloads + +Download the binary for your OS from below: +- **Linux** + - [Debian package]({{ DEBIAN_URL }}) +- **MacOS** + - [Archive]({{ MACOS_TGZ_URL }}) +# Install + +## From source + +``` +cargo install --git https://github.com/chevdor/tera-cli +``` + +## Linux +``` +wget {{ DEBIAN_URL }} +dpkg -i tera-cli_linux_amd64.deb +tera --help +``` + +## MacOS + +``` +brew tap chevdor/tera-cli https://github.com/chevdor/tera-cli +brew update +brew install chevdor/tera-cli/tera +``` + +{{ CHANGELOG }}