Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

simplify publishing package #56

Draft
wants to merge 2 commits into
base: dev
Choose a base branch
from
Draft
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
feat: publish package to npm
rabi-siddique committed Nov 18, 2024
commit f2bee47debf78cb3a61d9629653fe4d21d598be9
119 changes: 27 additions & 92 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -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 }}
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",
@@ -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",