From 78f4f19b3047f7845cd5427a5504195da60ae1b6 Mon Sep 17 00:00:00 2001 From: arashagp Date: Thu, 2 Jan 2025 10:29:34 +0330 Subject: [PATCH] feat: add publish-npm workflow --- .github/workflows/publish-npm.yml | 71 +++++++++++++++++++++++++++++++ 1 file changed, 71 insertions(+) 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..55f8638 --- /dev/null +++ b/.github/workflows/publish-npm.yml @@ -0,0 +1,71 @@ +# yaml-language-server: $schema=https://json.schemastore.org/github-workflow.json + +name: Publish NPM + +on: + workflow_dispatch: + + release: + types: + - created + +env: + NODE_VERSION: lts/* + +jobs: + publish-npm: + if: github.repository_owner == 'the-nexim' + + name: Publish NPM + runs-on: ubuntu-latest + + permissions: + contents: read + id-token: write + + steps: + - name: ๐Ÿ“ฅ Checkout repository + uses: actions/checkout@v4 + + - name: ๐Ÿ”ง Setup Node.js + uses: actions/setup-node@v4 + with: + node-version: ${{ inputs.NODE_VERSION }} + + - name: ๐Ÿ› ๏ธ Setup Node.js Corepack + run: corepack enable + + - name: ๐Ÿ“ฆ Get Yarn Config + id: yarn_config + run: echo "cache_folder=$(yarn config get cacheFolder)" >> $GITHUB_OUTPUT + + - name: ๐Ÿ—„๏ธ Cache Layer + uses: actions/cache@v4 + with: + path: ${{ steps.yarn_config.outputs.cache_folder }} + key: ${{ runner.os }}-yarn-${{ hashFiles('yarn.lock') }} + restore-keys: | + ${{ runner.os }}-yarn- + + - name: ๐Ÿ“ฅ Install Dependencies + run: yarn install --immutable + + - name: ๐Ÿ—ƒ๏ธ Cache Wireit + uses: google/wireit@setup-github-actions-caching/v2 + + - name: ๐Ÿ—๏ธ Build TypeScript + run: yarn build + env: + WIREIT_LOGGER: metrics + + - name: ๐Ÿงน Run ESLint + run: yarn lint + env: + WIREIT_LOGGER: metrics + + - name: ๐Ÿš€ Publish + run: yarn run publish -- --yes + env: + NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}} + NPM_CONFIG_PROVENANCE: true + WIREIT_LOGGER: metrics