diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index c747f57..014fad9 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -1,29 +1,72 @@ -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-to-npm: + runs-on: ubuntu-latest steps: - - name: Checkout code into workspace directory - uses: actions/checkout@v2 + - name: Checkout + uses: actions/checkout@v3 - - name: Setup Node - uses: actions/setup-node@v1 + - uses: actions/setup-node@v3 with: - node-version: '18.x' + node-version: 18 + registry-url: 'https://registry.npmjs.org' + 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 + - 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 + packages: write + steps: + - name: Checkout + uses: actions/checkout@v3 + + - uses: actions/setup-node@v3 with: - token: ${{ secrets.NPM_AUTH_TOKEN }} + node-version: 18 + registry-url: 'https://npm.pkg.github.com' + 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.GITHUB_TOKEN }} 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 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"