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