Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update publish script #76

Merged
merged 2 commits into from
Dec 27, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
137 changes: 85 additions & 52 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,69 +10,102 @@ on:
- 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 }}
with:
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 }}
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
27 changes: 24 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand Down
19 changes: 19 additions & 0 deletions scripts/set_versions_ga.sh
Original file line number Diff line number Diff line change
@@ -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
Loading