From 6d85ab12abb868aa8d77e69322a329f25189eed1 Mon Sep 17 00:00:00 2001 From: Dmytro Date: Wed, 27 Dec 2023 16:00:43 +0000 Subject: [PATCH 1/2] Update publish script --- .github/workflows/publish.yml | 138 +++++++++++++++++++++------------- README.md | 27 ++++++- scripts/set_versions_ga.sh | 19 +++++ 3 files changed, 128 insertions(+), 56 deletions(-) create mode 100644 scripts/set_versions_ga.sh diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index ad57b24..28d1093 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -7,60 +7,25 @@ on: - develop - beta - stable - - test-publish jobs: - build: + create_release: if: github.event.pull_request.merged - runs-on: ubuntu-latest + name: Create release + runs-on: ubuntu-20.04 + outputs: + upload_url: ${{ steps.create_release.outputs.upload_url }} + version: ${{ steps.export_outputs.outputs.version }} + branch: ${{ steps.export_outputs.outputs.branch }} steps: - uses: actions/checkout@v2 with: submodules: true - - uses: actions/setup-node@v1 - with: - node-version: '18.x' - registry-url: 'https://registry.npmjs.org' - - uses: oven-sh/setup-bun@v1 - - name: Install dependencies - run: | - yarn install - - name: Set version and branch - run: | - export BRANCH=${GITHUB_REF##*/} - export VERSION=$(npm run --silent version) - echo "Branch: $BRANCH" - echo "Base version: $VERSION" - export VERSION=$(bash ./helper-scripts/calculate_version.sh) - echo "VERSION=$VERSION" >> $GITHUB_ENV - echo "BRANCH=$BRANCH" >> $GITHUB_ENV - echo "Version $VERSION" - - name: Set release - run: | - if [[ "$BRANCH" == "stable" ]]; then - export PRERELEASE=false - else - export PRERELEASE=true - fi - echo "PRERELEASE=$PRERELEASE" >> $GITHUB_ENV - - name: Yarn build + - name: Set Versions run: | - yarn prepack - - name: Publish on npm - run: | - if [[ "$BRANCH" == "stable" ]]; then - npm publish --access public - else - npm version --no-git-tag-version ${{ env.VERSION }} --allow-same-version - npm publish --access public --tag ${{ env.BRANCH }} - fi - env: - NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} - - name: Build CLI - run: | - bun build:exec - mv ima ima-${{ env.VERSION }} + bash ./scripts/set_versions_ga.sh - name: Create Release + id: create_release uses: actions/create-release@v1 env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} @@ -68,11 +33,78 @@ jobs: tag_name: ${{ env.VERSION }} release_name: ${{ env.VERSION }} draft: false - prerelease: ${{ env.PRERELEASE }} - - name: Release - uses: softprops/action-gh-release@v1 - with: - tag_name: ${{ env.VERSION }} - name: ${{ env.VERSION }} - files: ima-${{ env.VERSION }} - prerelease: ${{ env.PRERELEASE }} \ No newline at end of file + prerelease: true + - name: Export outputs + id: export_outputs + run: | + echo "::set-output name=version::$VERSION" + echo "::set-output name=branch::$BRANCH" + build_and_publish: + if: github.event.pull_request.merged + needs: create_release + name: Build and publish for ${{ matrix.os }} + runs-on: ${{ matrix.os }} + strategy: + matrix: + include: + - os: ubuntu-20.04 + asset_name: ima-${{ needs.create_release.outputs.version }}-Linux-x86_64 + - os: macos-latest + asset_name: ima-${{ needs.create_release.outputs.version }}-Darwin-x86_64 + steps: + - uses: actions/checkout@v2 + with: + submodules: true + - uses: actions/setup-node@v1 + with: + node-version: '18.x' + registry-url: 'https://registry.npmjs.org' + - uses: oven-sh/setup-bun@v1 + - name: Install dependencies + run: | + yarn install + + - name: Yarn build + if: matrix.os == 'ubuntu-20.04' + run: | + yarn prepack + - name: Publish on npm + if: matrix.os == 'ubuntu-20.04' + run: | + if [[ "$BRANCH" == "stable" ]]; then + npm publish --access public + else + npm version --no-git-tag-version ${{ env.VERSION }} --allow-same-version + npm publish --access public --tag ${{ env.BRANCH }} + fi + env: + NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} + + - name: Build CLI + run: | + bun build:exec + mv ima ima-${{ env.VERSION }} + + - name: Upload Release Asset Ubuntu + if: matrix.os == 'ubuntu-20.04' + id: upload-release-asset-ubuntu + uses: actions/upload-release-asset@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + upload_url: ${{ needs.create_release.outputs.upload_url }} + asset_path: ${{ matrix.asset_name }} + asset_name: ${{ matrix.asset_name }} + asset_content_type: application/octet-stream + + - name: Upload Release Asset Mac + if: matrix.os == 'macos-latest' + id: upload-release-asset-mac + uses: actions/upload-release-asset@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + upload_url: ${{ needs.create_release.outputs.upload_url }} + asset_path: ${{ matrix.asset_name }} + asset_name: ${{ matrix.asset_name }} + asset_content_type: application/octet-stream \ No newline at end of file diff --git a/README.md b/README.md index cd673ab..c2f0db9 100644 --- a/README.md +++ b/README.md @@ -36,11 +36,32 @@ Full usage documentation with examples can be found on our docs portal: https:// git clone --recurse-submodules --remote-submodules https://github.com/skalenetwork/ima-js ``` -### IMA-SDK +## CLI usage -Version `0.3.0` is compatible with ima-sdk `0.2.1` +IMA-JS now also available as a standalone command line tool -### Testing +### Installation + +```bash +VERSION_NUM={RELEASE_NAME_HERE} && sudo -E bash -c "curl -L https://github.com/skalenetwork/ima-js/releases/download/$VERSION_NUM/ima-$VERSION_NUM > /usr/local/bin/ima" +sudo chmod +x /usr/local/bin/ima +``` + +### Usage + +```bash +ima --help +``` + +#### Connect chains + +Example: + +```bash +ima connect -n1 chain1 -n2 chain2 -pk1 456 -pk2 123 -e1 http://0.0.0.0:10001 -e2 http://0.0.0.0:10002 +``` + +## Testing > Check out GA test workflow in `.github/workflows/test.yml` to see all steps. diff --git a/scripts/set_versions_ga.sh b/scripts/set_versions_ga.sh new file mode 100644 index 0000000..1382c29 --- /dev/null +++ b/scripts/set_versions_ga.sh @@ -0,0 +1,19 @@ +#!/usr/bin/env bash + +echo "PROJECT_DIR=$GITHUB_WORKSPACE" >> $GITHUB_ENV +echo PROJECT_DIR: $GITHUB_WORKSPACE + +export BRANCH=${GITHUB_REF##*/} +echo "Branch $BRANCH" + +export VERSION=$(npm run --silent version) +export VERSION=$(bash ./helper-scripts/calculate_version.sh) + +echo "VERSION=$VERSION" >> $GITHUB_ENV +echo "Version $VERSION" + +export OS=`uname -s`-`uname -m` +export EXECUTABLE_NAME=ima-$VERSION-$OS + +echo "BRANCH=$BRANCH" >> $GITHUB_ENV +echo "EXECUTABLE_NAME=$EXECUTABLE_NAME" >> $GITHUB_ENV \ No newline at end of file From 294c1bc027f730cf7a3b553111c507d645e74378 Mon Sep 17 00:00:00 2001 From: Dmytro Date: Wed, 27 Dec 2023 17:40:13 +0000 Subject: [PATCH 2/2] Update publish script --- .github/workflows/publish.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 28d1093..5b57a27 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -7,6 +7,7 @@ on: - develop - beta - stable + - test-publish jobs: create_release: