Skip to content

Commit

Permalink
feat: publish package to npm
Browse files Browse the repository at this point in the history
  • Loading branch information
rabi-siddique committed Nov 18, 2024
1 parent 221d49c commit f861592
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 105 deletions.
113 changes: 23 additions & 90 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -1,113 +1,46 @@
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: Set pnpm cache directory
run: pnpm config set store-dir .pnpm-store
continue-on-error: true
- name: Checkout code
uses: actions/checkout@v4

- 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
node-version: 18

# fixes permission issues on docker
- name: Chown workspace
run: chown -R $(whoami) .
- name: Install pnpm
run: npm install -g pnpm

- 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 }}

- name: Set pnpm config
run: pnpm config set "//registry.npmjs.org/:_authToken" "${NPM_TOKEN}"
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
- 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
- name: Authenticate with npm
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 }}
run: echo "//registry.npmjs.org/:_authToken=${NPM_TOKEN}" > ~/.npmrc

- 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 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 }}
14 changes: 0 additions & 14 deletions .release-it.json

This file was deleted.

10 changes: 9 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down Expand Up @@ -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",
Expand Down

0 comments on commit f861592

Please sign in to comment.