From 30d620841b1c38cff2121c03be0cf70b301d96ea Mon Sep 17 00:00:00 2001 From: Nikita Melnikov Date: Wed, 19 Jul 2023 19:15:51 +0200 Subject: [PATCH 1/6] add workflow for publishing package to github registry --- .github/workflows/release.yml | 51 +++++++++++++++++++++-------------- 1 file changed, 31 insertions(+), 20 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index c747f57..565202d 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -1,29 +1,40 @@ -name: Release +name: Publish package on: - # manual trigger - workflow_dispatch: + push: + tags: + - v*.*.* jobs: - release: - runs-on: ubuntu-20.04 - env: - NODE_AUTH_TOKEN: ${{ secrets.NPM_AUTH_TOKEN }} + publish: + runs-on: ubuntu-latest + permissions: + contents: read + packages: write steps: - - name: Checkout code into workspace directory - uses: actions/checkout@v2 - - - name: Setup Node - uses: actions/setup-node@v1 + - name: Checkout + uses: actions/checkout@v3 + - uses: actions/setup-node@v3 with: - node-version: '18.x' + node-version: 18 + registry-url: 'https://npm.pkg.github.com' + scope: ${{ github.repository_owner }} - - name: Install yarn - run: npm install --global yarn + - name: Update package.json + run: | + TAG_NAME=${GITHUB_REF/refs\/tags\//} + PACKAGE_VERSION=${TAG_NAME#v} + echo "Updating package.json to version $PACKAGE_VERSION" + cat <<< $(jq -r ".version=\"$PACKAGE_VERSION\"" package.json) > package.json + cat package.json - - name: Install dependency - run: yarn install + - name: Install dependencies + run: yarn install --frozen-lockfile - - uses: JS-DevTools/npm-publish@v1 - with: - token: ${{ secrets.NPM_AUTH_TOKEN }} + - name: Build + run: yarn build + + - name: Publish + run: yarn publish + env: + NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }} From 3331e016d841d2dd64234064e4cfefdd4eba52a9 Mon Sep 17 00:00:00 2001 From: Nikita Melnikov Date: Wed, 19 Jul 2023 19:21:03 +0200 Subject: [PATCH 2/6] remove .npmrc before publish --- .github/workflows/release.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 565202d..917b643 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -14,6 +14,8 @@ jobs: steps: - name: Checkout uses: actions/checkout@v3 + + - run: rm .npmrc - uses: actions/setup-node@v3 with: node-version: 18 From 52e70c81805e5a825aaf6a9c513beaf773061064 Mon Sep 17 00:00:00 2001 From: Nikita Melnikov Date: Wed, 19 Jul 2023 19:24:02 +0200 Subject: [PATCH 3/6] try to remove publishConfig --- package.json | 3 --- 1 file changed, 3 deletions(-) diff --git a/package.json b/package.json index 2a0abea..f04f518 100644 --- a/package.json +++ b/package.json @@ -52,9 +52,6 @@ "typescript": "^4.2.4" }, "peerDependencies": {}, - "publishConfig": { - "registry": "https://npm.pkg.github.com/1inch" - }, "husky": { "hooks": { "pre-commit": "lint-staged && yarn run typecheck" From 47629d9a6f032cc8142da285f4983c6bad657473 Mon Sep 17 00:00:00 2001 From: Nikita Melnikov Date: Wed, 19 Jul 2023 19:26:27 +0200 Subject: [PATCH 4/6] publish to npm --- .github/workflows/release.yml | 32 +++++++++++++++++++++++++++++++- 1 file changed, 31 insertions(+), 1 deletion(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 917b643..a80a34c 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -6,7 +6,37 @@ on: - v*.*.* jobs: - publish: + publish-to-npm: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v3 + + - uses: actions/setup-node@v3 + with: + node-version: 18 + scope: ${{ github.repository_owner }} + + - name: Update package.json + run: | + TAG_NAME=${GITHUB_REF/refs\/tags\//} + PACKAGE_VERSION=${TAG_NAME#v} + echo "Updating package.json to version $PACKAGE_VERSION" + cat <<< $(jq -r ".version=\"$PACKAGE_VERSION\"" package.json) > package.json + cat package.json + + - name: Install dependencies + run: yarn install --frozen-lockfile + + - name: Build + run: yarn build + + - name: Publish + run: yarn publish + env: + NODE_AUTH_TOKEN: ${{ secrets.NPM_AUTH_TOKEN }} + + publish-to-github: runs-on: ubuntu-latest permissions: contents: read From 2fb23c3c97c562588b78517d3475957c3a44ee1d Mon Sep 17 00:00:00 2001 From: Nikita Melnikov Date: Wed, 19 Jul 2023 19:28:56 +0200 Subject: [PATCH 5/6] specify registry --- .github/workflows/release.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index a80a34c..f5bf33b 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -15,6 +15,7 @@ jobs: - uses: actions/setup-node@v3 with: node-version: 18 + registry-url: 'https://registry.npmjs.org' scope: ${{ github.repository_owner }} - name: Update package.json From bfcf9492640574755f6a89ef015c40698411bc22 Mon Sep 17 00:00:00 2001 From: Nikita Melnikov Date: Wed, 19 Jul 2023 19:45:28 +0200 Subject: [PATCH 6/6] specify registry --- .github/workflows/release.yml | 1 - .npmrc | 2 -- 2 files changed, 3 deletions(-) delete mode 100644 .npmrc diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index f5bf33b..014fad9 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -46,7 +46,6 @@ jobs: - name: Checkout uses: actions/checkout@v3 - - run: rm .npmrc - uses: actions/setup-node@v3 with: node-version: 18 diff --git a/.npmrc b/.npmrc deleted file mode 100644 index 8ce8925..0000000 --- a/.npmrc +++ /dev/null @@ -1,2 +0,0 @@ -registry=https://registry.npmjs.org -always-auth=true \ No newline at end of file