From ac945b0609c9938ef73cd5f4bf849fcfe3f993dc Mon Sep 17 00:00:00 2001 From: Ihor Date: Tue, 12 Nov 2024 21:17:28 +0100 Subject: [PATCH] ci: add npm publish actions --- .github/workflows/npm-publish.yml | 51 +++++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) create mode 100644 .github/workflows/npm-publish.yml diff --git a/.github/workflows/npm-publish.yml b/.github/workflows/npm-publish.yml new file mode 100644 index 0000000..49051ac --- /dev/null +++ b/.github/workflows/npm-publish.yml @@ -0,0 +1,51 @@ +name: Publish to NPM on GH Release Publish + +on: + push: + release: + types: [published] + +jobs: + publish: + if: github.repository == 'brainly/gene' + runs-on: ubuntu-latest + strategy: + matrix: + target: [build, test, lint] + + steps: + - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4 + + - name: Install pnpm + uses: pnpm/action-setup@v4 + with: + version: 9.12.0 + + - name: Setup Node.js + uses: actions/setup-node@1a4442cacd436585916779262731d5b162bc6ec7 # v3 + with: + node-version: '18.20.0' + cache: 'pnpm' + + - name: Install dependencies + run: pnpm install + + - name: Get NX projects + id: nx-projects + run: | + # Kudos to: https://github.com/jscutlery/nx-completion/blob/ca0ab21396ec7748c770f8e15faed2cadff95c57/nx-completion.plugin.zsh#L39-L41 + local cwd_id=$(echo $PWD | (command -v md5sum &> /dev/null && md5sum || md5 -r) | awk '{print $1}') + tmp_cached_def="/tmp/nx-completion-$cwd_id.json" + pnpm nx graph --file="$tmp_cached_def" > /dev/null + echo "::set-output name=projects::$(cat $tmp_cached_def)" + + - name: Print NX projects + run: echo "${{ steps.nx-projects.outputs.projects }}" + + # - name: Run ${{ matrix.target }} + # run: pnpm nx run-many --target=${{ matrix.target }} --all + + # - name: Publish to NPM registry + # env: + # NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} + # run: npm publish