Added git action to publish npm package @netapplabs/nfs-js-node #147
Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # This workflow will do a clean installation of node dependencies, cache/restore them, build the source code and run tests across different versions of node | |
| # For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-nodejs | |
| name: CI | |
| on: | |
| push: | |
| branches: [ "*" ] | |
| pull_request: | |
| branches: [ "*" ] | |
| env: | |
| CARGO_TERM_COLOR: always | |
| jobs: | |
| build: | |
| runs-on: ${{ matrix.settings.host }} | |
| strategy: | |
| matrix: | |
| settings: | |
| - host: ubuntu-22.04 | |
| target: x86_64-unknown-linux-gnu | |
| runtests: true | |
| - host: ubuntu-22.04 | |
| target: aarch64-unknown-linux-gnu | |
| runtests: false | |
| - host: macos-latest | |
| target: aarch64-apple-darwin | |
| runtests: true | |
| - host: macos-latest | |
| target: x86_64-apple-darwin | |
| runtests: false | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Setup go | |
| uses: actions/setup-go@v3 | |
| with: | |
| go-version: '1.23' | |
| check-latest: true | |
| - name: Setup SSH | |
| run: | | |
| mkdir -p $HOME/.ssh | |
| echo "${{ secrets.SSH_KEY_FOR_LIBNFS_SYS }}" > $HOME/.ssh/libnfs-sys | |
| echo "${{ secrets.SSH_KEY_FOR_LIBNFS_RS }}" > $HOME/.ssh/libnfs-rs | |
| echo "${{ secrets.SSH_KEY_FOR_NFS_RS }}" > $HOME/.ssh/nfs-rs | |
| chmod 600 $HOME/.ssh/libnfs* $HOME/.ssh/nfs-rs | |
| - name: Checkout submodules | |
| run: | | |
| ln -sf $HOME/.ssh/libnfs-sys $HOME/.ssh/id_rsa | |
| git clone git@github.com:NetAppLabs/libnfs-sys.git | |
| ln -sf $HOME/.ssh/libnfs-rs $HOME/.ssh/id_rsa | |
| git clone git@github.com:NetAppLabs/libnfs-rs.git | |
| ln -sf $HOME/.ssh/nfs-rs $HOME/.ssh/id_rsa | |
| git clone git@github.com:NetAppLabs/nfs-rs.git | |
| rm $HOME/.ssh/id_rsa | |
| - name: Install non-rust non-node dependencies | |
| run: ./deps.sh | |
| - name: linux deps | |
| if: runner.os == 'Linux' | |
| shell: bash | |
| run: | | |
| sudo apt-get -y install \ | |
| libc6-dev-amd64-cross libc6-dev-arm64-cross \ | |
| crossbuild-essential-arm64 crossbuild-essential-amd64 \ | |
| gcc-aarch64-linux-gnu \ | |
| binfmt-support binutils binutils-aarch64-linux-gnu | |
| - uses: mlugg/setup-zig@v1 | |
| - uses: actions-rust-lang/setup-rust-toolchain@v1 | |
| with: | |
| rustflags: "" | |
| - name: Use Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: 20.x | |
| cache: 'yarn' | |
| registry-url: 'https://npm.pkg.github.com' | |
| scope: '@netapplabs' | |
| - name: Prepare yarn | |
| run: yarn install | |
| - name: Build | |
| run: yarn build | |
| - name: Test | |
| if: ${{ matrix.settings.runtests }} | |
| run: yarn test | |
| - name: Upload node module | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: nfs-js-node.${{ matrix.settings.host }}-${{ matrix.settings.target }} | |
| path: | | |
| nfs-js-node.*.node | |
| lib | |
| publish: | |
| runs-on: ubuntu-22.04 | |
| if: ${{ github.ref == 'refs/heads/master' || github.ref == 'refs/heads/publish_npm' }} | |
| permissions: | |
| contents: write | |
| packages: write | |
| needs: build | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Use Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: 20.x | |
| cache: 'yarn' | |
| registry-url: 'https://npm.pkg.github.com' | |
| scope: '@netapplabs' | |
| - name: Download Artifact | |
| uses: actions/download-artifact@v4 | |
| with: | |
| pattern: nfs-js-node.* | |
| merge-multiple: true | |
| - name: Setup git | |
| run: | | |
| git config --global user.name 'github-actions[bot]' | |
| git config --global user.email 'github-actions[bot]@users.noreply.github.com' | |
| - name: Bump version | |
| run: npx standard-version | |
| - name: Publish Artifacts | |
| run: npm publish --ignore-scripts | |
| env: | |
| NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Commit and push version bump | |
| run: | | |
| git push --follow-tags |