Skip to content

Commit 51f618e

Browse files
authored
Merge pull request #47 from api3dao/npm-release
Update configuration similar to @api3/commons
2 parents e004e8b + 46e6963 commit 51f618e

File tree

4 files changed

+438
-13
lines changed

4 files changed

+438
-13
lines changed

.github/workflows/continuous-build.yml

Lines changed: 66 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,17 @@
1+
########################################################################################
2+
# The following secrets are required:
3+
#
4+
# 1. GH_ACCESS_TOKEN - A "fine-grained personal access token" generated through the
5+
# Github UI. It seems like these tokens are scoped to a user, rather than an
6+
# organisation.
7+
#
8+
# The following minimum permissions are required:
9+
# Read - access to metadata
10+
# Read & write - access to actions and code
11+
# 2. GH_USER_NAME - The name (not username) associated with the Git user. e.g. John Smith
12+
# 3. GH_USER_EMAIL - The email associated with the Git user
13+
# 4. NPM_TOKEN - A token for publishing to npm
14+
########################################################################################
115
name: Continuous build
216

317
on:
@@ -32,9 +46,60 @@ jobs:
3246

3347
- name: Build
3448
run: pnpm build
35-
49+
3650
- name: Verify vendor contracts
3751
run: pnpm verify-vendor-contracts
3852

3953
- name: Test
4054
run: pnpm test
55+
56+
tag-and-release:
57+
runs-on: ubuntu-latest
58+
# Only tag and release on pushes to main (or the release branch)
59+
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
60+
steps:
61+
- name: Clone @api3/data-feed-proxy-combinators
62+
uses: actions/checkout@v5
63+
64+
- name: Set up pnpm
65+
uses: pnpm/action-setup@v3
66+
67+
- name: Set up Node
68+
uses: actions/setup-node@v5
69+
with:
70+
node-version: '20.17.0'
71+
cache: 'pnpm'
72+
73+
# TODO: Are these necessary?
74+
# - name: Configure Git credentials
75+
# run: |
76+
# git config --global user.name '${{ secrets.GH_USER_NAME }}'
77+
# git config --global user.email '${{ secrets.GH_USER_EMAIL }}'
78+
79+
- name: Install Dependencies
80+
run: pnpm install
81+
82+
- name: Build
83+
run: pnpm run build
84+
85+
- name: Get package.json version
86+
id: get-version
87+
run: echo "version=$(cat package.json | jq -r '.version' | sed 's/^/v/')" >> $GITHUB_OUTPUT
88+
89+
- name: Validate tag
90+
id: validate-tag
91+
run: test "$(git tag -l '${{ steps.get-version.outputs.version }}' | awk '{print $NF}')" = "${{ steps.get-version.outputs.version }}" || echo "new-tag=true" >> $GITHUB_OUTPUT
92+
93+
- name: Tag and release on Github
94+
if: ${{ steps.validate-tag.outputs.new-tag }}
95+
run: pnpm run release:tag
96+
env:
97+
GH_ACCESS_TOKEN: ${{ secrets.GH_ACCESS_TOKEN }}
98+
99+
- name: Publish to npm
100+
if: ${{ steps.validate-tag.outputs.new-tag }}
101+
run: |
102+
npm config set "//registry.npmjs.org/:_authToken=${{ secrets.NPM_TOKEN }}"
103+
pnpm publish --access public
104+
env:
105+
NPM_CONFIG_PROVENANCE: true

package.json

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
"oev"
99
],
1010
"license": "MIT",
11-
"version": "0.0.1",
11+
"version": "0.1.0",
1212
"repository": {
1313
"type": "git",
1414
"url": "https://github.com/api3dao/data-feed-proxy-combinators.git"
@@ -25,23 +25,25 @@
2525
".": "./dist/src/index.js"
2626
},
2727
"scripts": {
28-
"build": "pnpm build:hardhat && tsc -p tsconfig.build.json",
2928
"build:hardhat": "hardhat --config hardhat.build.config.ts compile",
29+
"build": "pnpm build:hardhat && tsc -p tsconfig.build.json",
3030
"coverage": "hardhat coverage",
3131
"deploy:InverseApi3ReaderProxyV1": "hardhat deploy --network $NETWORK --tags InverseApi3ReaderProxyV1",
3232
"deploy:NormalizedApi3ReaderProxyV1": "hardhat deploy --network $NETWORK --tags NormalizedApi3ReaderProxyV1",
33-
"deploy:ProductApi3ReaderProxyV1": "hardhat deploy --network $NETWORK --tags ProductApi3ReaderProxyV1",
3433
"deploy:PriceCappedApi3ReaderProxyV1": "hardhat deploy --network $NETWORK --tags PriceCappedApi3ReaderProxyV1",
34+
"deploy:ProductApi3ReaderProxyV1": "hardhat deploy --network $NETWORK --tags ProductApi3ReaderProxyV1",
3535
"deploy:ScaledApi3FeedProxyV1": "hardhat deploy --network $NETWORK --tags ScaledApi3FeedProxyV1",
36-
"lint": "pnpm run prettier:check && pnpm run lint:eslint && pnpm run lint:solhint",
37-
"lint:solhint": "solhint ./contracts/**/*.sol",
3836
"lint:eslint": "eslint . --ext .js,.ts",
37+
"lint:solhint": "solhint ./contracts/**/*.sol",
38+
"lint": "pnpm run prettier:check && pnpm run lint:eslint && pnpm run lint:solhint",
3939
"prettier:check": "prettier --check \"./**/*.{js,ts,md,json,sol}\"",
4040
"prettier": "prettier --write \"./**/*.{js,ts,md,json,sol}\"",
41-
"verify-vendor-contracts": "hardhat run scripts/verify-vendor-contracts.ts",
42-
"test": "hardhat test --parallel"
41+
"release:tag": "ts-node scripts/tag-and-release.ts",
42+
"test": "hardhat test --parallel",
43+
"verify-vendor-contracts": "hardhat run scripts/verify-vendor-contracts.ts"
4344
},
4445
"devDependencies": {
46+
"@api3/commons": "^1.0.1",
4547
"@api3/contracts": "^30.0.0",
4648
"@api3/eslint-plugin-commons": "^3.0.0",
4749
"@api3/promise-utils": "^0.4.0",

0 commit comments

Comments
 (0)