Skip to content

Commit

Permalink
chore: publish automatically to NPM (#4)
Browse files Browse the repository at this point in the history
Publish automatically to NPM using
[semantic-release](https://github.com/semantic-release/semantic-release)

Similar to what we did in valora-inc/logging#5

Fixes RET-1037
  • Loading branch information
jeanregisser committed Apr 19, 2024
1 parent a9ebe09 commit c07c154
Show file tree
Hide file tree
Showing 7 changed files with 2,618 additions and 60 deletions.
35 changes: 20 additions & 15 deletions .github/workflows/workflow.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -62,35 +62,40 @@ jobs:
# path: coverage/lcov-report
# - name: 'Upload coverage to Codecov'
# uses: codecov/codecov-action@v3
deploy:
name: Deploy
publish:
name: Publish to NPM
if: github.ref == 'refs/heads/main'
needs:
- check-for-sh
- lint
- knip
- test
runs-on: ubuntu-latest
steps:
# Repo needs to be given access to the MAINNET_SERVICE_ACCOUNT_KEY secret to access the slack webhook
# https://github.com/organizations/valora-inc/settings/secrets/actions/MAINNET_SERVICE_ACCOUNT_KEY
- uses: google-github-actions/auth@v2
# actions/checkout MUST come before auth
- uses: actions/checkout@v4
- id: auth
uses: google-github-actions/auth@v2
with:
project_id: celo-mobile-mainnet
credentials_json: ${{ secrets.MAINNET_SERVICE_ACCOUNT_KEY }}
- name: Fetch Secrets
id: slack-webhook
uses: google-github-actions/get-secretmanager-secrets@v2.1.0
# From valora-viem-hsm-test
credentials_json: ${{ secrets.GOOGLE_SERVICE_ACCOUNT_KEY }}
- id: google-secrets
uses: google-github-actions/get-secretmanager-secrets@v2
with:
# This can point to any slack webhook URL stored in GC Secret Manager
# valora-viem-hsm-test service account has access to these specific secrets
secrets: |-
SLACK_WEBHOOK_URL:projects/1027349420744/secrets/SLACK_ONCALL_WEBHOOK_URL
- uses: actions/checkout@v4
NPM_TOKEN:celo-mobile-mainnet/NPM_TOKEN
SLACK_WEBHOOK_URL:celo-mobile-mainnet/SLACK_ONCALL_WEBHOOK_URL
- uses: actions/setup-node@v4
with:
node-version-file: 'package.json'
check-latest: true
- run: yarn
- run: yarn deploy
- run: yarn build
- run: yarn release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NPM_TOKEN: ${{ steps.google-secrets.outputs.NPM_TOKEN }}
- uses: ravsamhq/notify-slack-action@v2
if: always()
with:
Expand All @@ -103,4 +108,4 @@ jobs:
mention_groups: 'S0277QUM4KB'
mention_groups_when: 'failure'
env:
SLACK_WEBHOOK_URL: ${{ steps.slack-webhook.outputs.SLACK_WEBHOOK_URL }}
SLACK_WEBHOOK_URL: ${{ steps.google-secrets.outputs.SLACK_WEBHOOK_URL }}
6 changes: 5 additions & 1 deletion .knip.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
{
"entry": ["src/index.ts"],
"project": ["src/**/*/.ts"],
"ignoreDependencies": ["@types/jest", "@valora/prettier-config"]
"ignoreDependencies": [
"@types/jest",
"@valora/prettier-config",
"conventional-changelog-conventionalcommits"
]
}
42 changes: 33 additions & 9 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,14 +1,27 @@
{
"name": "typescript-starter",
"version": "0.0.1",
"main": "dist/index.js",
"repository": "git@github.com:valora-inc/typescript-starter.git",
"name": "@valora/viem-account-hsm-gcp",
"version": "0.0.0-semantic-release",
"main": "dist/gcpHsmToAccount.js",
"typings": "dist/gcpHsmToAccount.d.ts",
"repository": "https://github.com/valora-inc/viem-account-hsm-gcp",
"author": "Valora Inc",
"license": "Apache-2.0",
"private": true,
"engines": {
"node": "^20"
},
"files": [
"dist"
],
"keywords": [
"viem",
"hsm",
"evm",
"blockchain",
"signing",
"cloud",
"google cloud",
"google kms"
],
"scripts": {
"build": "tsc",
"build:scripts": "tsc --project scripts/tsconfig.json",
Expand All @@ -21,9 +34,9 @@
"test:watch": "yarn test --watch",
"test:ci": "yarn test --ci --coverage",
"supercheck": "yarn format && yarn lint:fix && yarn typecheck && yarn knip && yarn test",
"example": "ts-node ./scripts/example.ts",
"deploy": "echo 'Deployed!'",
"knip": "knip"
"send": "ts-node ./scripts/send.ts",
"knip": "knip",
"release": "semantic-release"
},
"peerDependencies": {
"viem": "^2.9.20"
Expand All @@ -38,6 +51,7 @@
"@typescript-eslint/eslint-plugin": "^7.3.1",
"@valora/eslint-config-typescript": "^1.0.2",
"@valora/prettier-config": "^0.0.1",
"conventional-changelog-conventionalcommits": "^7.0.2",
"eslint": "^8.57.0",
"eslint-plugin-import": "^2.29.1",
"eslint-plugin-jest": "^27.9.0",
Expand All @@ -47,10 +61,20 @@
"jest": "^29.7.0",
"knip": "^5.2.2",
"prettier": "^3.2.5",
"semantic-release": "^23.0.8",
"ts-jest": "^29.1.2",
"ts-node": "^10.9.2",
"typescript": "^5.4.4",
"viem": "^2.9.20"
},
"prettier": "@valora/prettier-config"
"prettier": "@valora/prettier-config",
"release": {
"branches": [
"main"
],
"preset": "conventionalcommits"
},
"publishConfig": {
"access": "public"
}
}
2 changes: 1 addition & 1 deletion scripts/send.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/* eslint-disable no-console */
import { gcpHsmToAccount } from '../src'
import { gcpHsmToAccount } from '../src/gcpHsmToAccount'
import {
createWalletClient,
formatUnits,
Expand Down
2 changes: 1 addition & 1 deletion src/index.test.ts → src/gcpHsmToAccount.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import {
} from 'viem'
import { privateKeyToAccount } from 'viem/accounts'
import * as asn1 from 'asn1js'
import { gcpHsmToAccount } from './index'
import { gcpHsmToAccount } from './gcpHsmToAccount'

const PRIVATE_KEY1 =
'0x1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef'
Expand Down
File renamed without changes.
Loading

0 comments on commit c07c154

Please sign in to comment.