From c3b9da5b28523e915a9627420a3e5630d71b25a8 Mon Sep 17 00:00:00 2001 From: rabi-siddique Date: Mon, 18 Nov 2024 16:19:52 +0500 Subject: [PATCH] feat: publish package to npm --- .github/workflows/release.yml | 119 ++++++++-------------------------- .release-it.json | 14 ---- package.json | 10 ++- 3 files changed, 36 insertions(+), 107 deletions(-) delete mode 100644 .release-it.json diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 1ccc3cb6f..3f2bf1f3a 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -1,113 +1,48 @@ -name: Release CI +name: Release Package on: push: - branches: [master] - workflow_dispatch: - inputs: - version: - description: 'release: major|minor|patch' - required: true - default: patch - -concurrency: - group: ${{ github.head_ref || github.run_id }} - cancel-in-progress: true + branches: + - master jobs: release: + name: Publish to npm runs-on: ubuntu-latest - name: release - - container: - image: synthetixio/docker-node:18.16-ubuntu steps: - - name: Checkout - uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # pin@v2 - with: - fetch-depth: 0 - ref: master + - name: Checkout code + uses: actions/checkout@v4 - - name: Set pnpm cache directory - run: pnpm config set store-dir .pnpm-store - continue-on-error: true - - - name: Setup cache - uses: actions/cache@88522ab9f39a2ea568f7027eddc7d8d8bc9d59c8 # pin@v2 + - name: Set up Node.js + uses: actions/setup-node@v4 with: - path: | - .pnpm-store - node_modules - key: ${{ runner.os }}-pnpm-v1-${{ hashFiles('**/pnpm-lock.yaml') }} - restore-keys: | - ${{ runner.os }}-pnpm-v1- - continue-on-error: true - - # fixes permission issues on docker - - name: Chown workspace - run: chown -R $(whoami) . - - - name: Install dependencies - run: pnpm install --frozen-lockfile --prefer-offline - - - name: Set git config - run: | - git config user.name $GIT_USER - git config user.email $GIT_EMAIL - mkdir -p ~/.gnupg/ - printf $GPG_KEY | base64 -d > ~/.gnupg/private.key - gpg --import ~/.gnupg/private.key - git config commit.gpgsign true - git config user.signingkey $GIT_SIGNING_KEY - env: - GIT_USER: ${{ secrets.GIT_USER }} - GIT_EMAIL: ${{ secrets.GIT_EMAIL }} - GPG_KEY: ${{ secrets.GPG_KEY }} - GIT_SIGNING_KEY: ${{ secrets.GIT_SIGNING_KEY }} + node-version: 18 - - name: Set pnpm config - run: pnpm config set "//registry.npmjs.org/:_authToken" "${NPM_TOKEN}" + - name: Authenticate with npm and show .npmrc env: NPM_TOKEN: ${{ secrets.NPM_TOKEN }} - - - name: Set current pnpm package version - id: extract-version run: | - PACKAGE_VERSION=$(cat package.json | grep version | head -1 | awk -F: '{ print $2 }' | sed 's/[",]//g' | tr -d '[[:space:]]') - echo ::set-output name=current-version::$PACKAGE_VERSION + echo "//registry.npmjs.org/:_authToken=${NPM_TOKEN}" > ~/.npmrc + cat ~/.npmrc | sed 's/:_authToken=.*/:_authToken=[SECURED]/' - - name: Release ${{ github.event.inputs.version }} - if: github.event_name == 'workflow_dispatch' - run: | - git reset --hard - pnpm release:${{ github.event.inputs.version }} --ci - pnpm publish - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - NPM_TOKEN: ${{ secrets.NPM_TOKEN }} - GIT_USER: ${{ secrets.GIT_USER }} - GIT_EMAIL: ${{ secrets.GIT_EMAIL }} - GPG_KEY: ${{ secrets.GPG_KEY }} - GIT_SIGNING_KEY: ${{ secrets.GIT_SIGNING_KEY }} + - name: Install pnpm + run: npm install -g pnpm + + - name: Install dependencies + run: pnpm install --frozen-lockfile --prefer-offline - - name: Release patch:beta - if: github.event_name == 'push' + - name: Configure Git run: | - git reset --hard + git config --global user.name "${{ secrets.GIT_USER }}" + git config --global user.email "${{ secrets.GIT_EMAIL }}" + echo "Configured Git user.name: $(git config --global user.name)" + echo "Configured Git user.email: $(git config --global user.email)" - echo ${{ steps.extract-version.outputs.current-version }} - if echo ${{ steps.extract-version.outputs.current-version }} | grep -q "beta"; then - pnpm release --ci --preRelease - pnpm publish - else - pnpm release:patch --ci --preRelease=beta - pnpm publish - fi + - name: Release with release-it + run: npx --ignore-existing release-it env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + GIT_AUTHOR_NAME: ${{ secrets.GIT_USER }} + GIT_AUTHOR_EMAIL: ${{ secrets.GIT_EMAIL }} + GITHUB_TOKEN: ${{ secrets.GIT_TOKEN }} NPM_TOKEN: ${{ secrets.NPM_TOKEN }} - GIT_USER: ${{ secrets.GIT_USER }} - GIT_EMAIL: ${{ secrets.GIT_EMAIL }} - GPG_KEY: ${{ secrets.GPG_KEY }} - GIT_SIGNING_KEY: ${{ secrets.GIT_SIGNING_KEY }} diff --git a/.release-it.json b/.release-it.json deleted file mode 100644 index 63e43d67e..000000000 --- a/.release-it.json +++ /dev/null @@ -1,14 +0,0 @@ -{ - "git": { - "commitMessage": "release: v${version}", - "tagName": "${version}", - "commitArgs": "-S -s", - "tagArgs": "-s" - }, - "github": { - "release": true - }, - "npm": { - "publish": false - } -} diff --git a/package.json b/package.json index 08206f79f..f35fbff94 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@agoric/synpress", - "version": "3.8.3-beta.2", + "version": "3.8.3", "description": "Synpress is e2e testing framework based around Cypress.io & playwright with included MetaMask support. Test your dapps with ease.", "keywords": [ "Synpress", @@ -34,6 +34,14 @@ "prettier --write --ignore-unknown" ] }, + "release-it": { + "git": { + "commitMessage": "release: v${version}", + "tagName": "${version}", + "tagAnnotation": "Release v${version}", + "push": true + } + }, "scripts": { "fix": "turbo fix:eslint fix:prettier --concurrency 1", "fix:eslint": "eslint . --ext .js,.ts,.jsx,.tsx --fix",