From 1b6d1f3e6a77aa7cc9384c03e202cafbeb24259e Mon Sep 17 00:00:00 2001 From: Denis Fadeev Date: Fri, 30 Aug 2024 18:45:29 +0900 Subject: [PATCH 1/5] ci: publish npm workflow --- .github/workflows/publish-npm.yml | 62 +++++++++++++++++++++++++++++++ package.json | 9 ++++- 2 files changed, 70 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/publish-npm.yml diff --git a/.github/workflows/publish-npm.yml b/.github/workflows/publish-npm.yml new file mode 100644 index 0000000..ad72dba --- /dev/null +++ b/.github/workflows/publish-npm.yml @@ -0,0 +1,62 @@ +name: Publish to NPM + +on: + release: + types: [published] + +jobs: + publish: + runs-on: ubuntu-latest + + steps: + - name: Checkout Repository + uses: actions/checkout@v3 + + - name: Setup Node.js + uses: actions/setup-node@v4 + with: + node-version: "21" + registry-url: "https://registry.npmjs.org" + + - name: Install Rust + run: | + curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y + source $HOME/.cargo/env + + - name: Install Solana CLI + run: | + sh -c "$(curl -sSfL https://release.solana.com/v1.18.15/install)" + export PATH="/home/runner/.local/share/solana/install/active_release/bin:$PATH" + solana --version + + - name: Install Anchor CLI + run: | + cargo install --git https://github.com/coral-xyz/anchor --tag v0.30.0 anchor-cli --locked + anchor --version + + - name: Build + run: anchor build + + - name: Prepare IDL Files + run: | + mv target/idl ./ + + - name: Determine NPM Tag + id: determine-npm-tag + run: | + VERSION_TAG=${GITHUB_REF#refs/tags/v} + if [[ $VERSION_TAG == *"-"* ]]; then + echo ::set-output name=NPM_TAG::${VERSION_TAG#*-} + else + echo ::set-output name=NPM_TAG::latest + fi + env: + GITHUB_REF: ${{ github.ref }} + + - name: Publish to NPM + run: | + yarn publish --access public --new-version ${GITHUB_REF#refs/tags/v} --tag ${{ + steps.determine-npm-tag.outputs.NPM_TAG }} --no-git-tag-version + env: + NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} + GITHUB_REF: ${{ github.ref }} diff --git a/package.json b/package.json index 2ff8fda..54c4ebb 100644 --- a/package.json +++ b/package.json @@ -1,4 +1,11 @@ { + "name": "@zetachain/protocol-contracts-solana", + "private": false, + "version": "0.0.0-set-on-publish", + "description": "Package contains IDL files for the Solana Gateway program, enabling cross-chain functionality with ZetaChain", + "files": [ + "idl" + ], "scripts": { "lint:fix": "prettier */*.js \"*/**/*{.js,.ts}\" -w", "lint": "prettier */*.js \"*/**/*{.js,.ts}\" --check" @@ -21,4 +28,4 @@ "ts-mocha": "^10.0.0", "typescript": "^4.3.5" } -} +} \ No newline at end of file From 8232bf0cf51b442be36a5a525631a9f3af48b192 Mon Sep 17 00:00:00 2001 From: Denis Fadeev Date: Sat, 31 Aug 2024 10:05:01 +0900 Subject: [PATCH 2/5] Update .github/workflows/publish-npm.yml Co-authored-by: Alex Gartner --- .github/workflows/publish-npm.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/publish-npm.yml b/.github/workflows/publish-npm.yml index ad72dba..c6e900f 100644 --- a/.github/workflows/publish-npm.yml +++ b/.github/workflows/publish-npm.yml @@ -10,7 +10,7 @@ jobs: steps: - name: Checkout Repository - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: Setup Node.js uses: actions/setup-node@v4 From 71e859afb8c9097c06095ef9adb0fcb6d41c0951 Mon Sep 17 00:00:00 2001 From: Denis Fadeev Date: Mon, 2 Sep 2024 11:36:21 +0900 Subject: [PATCH 3/5] dtolnay/rust-toolchain@stable --- .github/workflows/publish-npm.yml | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/.github/workflows/publish-npm.yml b/.github/workflows/publish-npm.yml index c6e900f..9de4e90 100644 --- a/.github/workflows/publish-npm.yml +++ b/.github/workflows/publish-npm.yml @@ -19,9 +19,7 @@ jobs: registry-url: "https://registry.npmjs.org" - name: Install Rust - run: | - curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y - source $HOME/.cargo/env + uses: dtolnay/rust-toolchain@stable - name: Install Solana CLI run: | From 8f0c44547cb5c07ade83ed269a5192bd64f5e29d Mon Sep 17 00:00:00 2001 From: Denis Fadeev Date: Mon, 2 Sep 2024 11:43:08 +0900 Subject: [PATCH 4/5] metadaoproject/setup-anchor@v2 --- .github/workflows/publish-npm.yml | 22 ++++++---------------- 1 file changed, 6 insertions(+), 16 deletions(-) diff --git a/.github/workflows/publish-npm.yml b/.github/workflows/publish-npm.yml index 9de4e90..7af77d0 100644 --- a/.github/workflows/publish-npm.yml +++ b/.github/workflows/publish-npm.yml @@ -12,25 +12,15 @@ jobs: - name: Checkout Repository uses: actions/checkout@v4 - - name: Setup Node.js - uses: actions/setup-node@v4 - with: - node-version: "21" - registry-url: "https://registry.npmjs.org" - - name: Install Rust uses: dtolnay/rust-toolchain@stable - - name: Install Solana CLI - run: | - sh -c "$(curl -sSfL https://release.solana.com/v1.18.15/install)" - export PATH="/home/runner/.local/share/solana/install/active_release/bin:$PATH" - solana --version - - - name: Install Anchor CLI - run: | - cargo install --git https://github.com/coral-xyz/anchor --tag v0.30.0 anchor-cli --locked - anchor --version + - name: Install Node.js, Solana CLI and Anchor + uses: metadaoproject/setup-anchor@v2 + with: + anchor-version: '0.30.0' + solana-cli-version: '1.18.15' + node-version: '21.0.0' - name: Build run: anchor build From bed715c195af1b7eb6fc262a4478d5b0368cc4c8 Mon Sep 17 00:00:00 2001 From: Denis Fadeev Date: Tue, 3 Sep 2024 13:09:26 +0900 Subject: [PATCH 5/5] GITHUB_ENV --- .github/workflows/publish-npm.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/publish-npm.yml b/.github/workflows/publish-npm.yml index 7af77d0..561b499 100644 --- a/.github/workflows/publish-npm.yml +++ b/.github/workflows/publish-npm.yml @@ -34,9 +34,9 @@ jobs: run: | VERSION_TAG=${GITHUB_REF#refs/tags/v} if [[ $VERSION_TAG == *"-"* ]]; then - echo ::set-output name=NPM_TAG::${VERSION_TAG#*-} + echo "NPM_TAG=${VERSION_TAG#*-}" >> "$GITHUB_ENV" else - echo ::set-output name=NPM_TAG::latest + echo "NPM_TAG=latest" >> "$GITHUB_ENV" fi env: GITHUB_REF: ${{ github.ref }}