From ef639241d487473dee7ffd54d8b782dbfa84dc45 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michalina=20Ciencia=C5=82a?= Date: Thu, 13 Jan 2022 19:24:54 +0100 Subject: [PATCH 1/4] Add a GH Actions workflow publishing npm package with contracts Contracts stored in the `thesis/solidity-contracts` repository are used as a dependency in other projects. Currently they are pulled from the GitHub and referenced to by commit hash. In this commit we add a GH Actions workflow that will publish npm packages containing `*.sol` contracts and version them using `-dev.X` suffix. --- .github/workflows/npm.yml | 36 ++++++++++++++++++++++++++++++++++++ package.json | 15 +++++++++++++-- 2 files changed, 49 insertions(+), 2 deletions(-) create mode 100644 .github/workflows/npm.yml diff --git a/.github/workflows/npm.yml b/.github/workflows/npm.yml new file mode 100644 index 0000000..46c674e --- /dev/null +++ b/.github/workflows/npm.yml @@ -0,0 +1,36 @@ +name: NPM + +on: + push: + branches: + - main + paths: + - "contracts/**" + - "package.json" + - "package-lock.json" + workflow_dispatch: + +jobs: + npm-compile-publish-contracts: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + + - uses: actions/setup-node@v2 + with: + node-version: "14.x" + cache: "npm" + registry-url: "https://registry.npmjs.org" + + - name: Bump up package version + id: npm-version-bump + uses: keep-network/npm-version-bump@v2 + with: + environment: dev + branch: ${{ github.ref }} + commit: ${{ github.sha }} + + - name: Publish package + env: + NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} + run: npm publish --access public --tag development diff --git a/package.json b/package.json index b9a4849..d5df8a6 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,18 @@ { - "name": "@thesis/solidity-contracts", - "version": "0.0.1", + "name": "@thesis-co/solidity-contracts", + "version": "0.0.1-dev", "license": "MIT", + "files": [ + "contracts/**/*.sol" + ], + "repository": { + "type": "git", + "url": "ssh://git@github.com/thesis/solidity-contracts" + }, + "bugs": { + "url": "https://github.com/thesis/solidity-contracts/issues" + }, + "homepage": "https://github.com/thesis/solidity-contracts", "scripts": { "build": "hardhat compile", "format": "npm run lint && prettier --check .", From 42e9809ff0c649a066cc53fdbe881e810e0e15c8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michalina=20Ciencia=C5=82a?= Date: Mon, 7 Feb 2022 14:53:58 +0100 Subject: [PATCH 2/4] Change npm -> yarn For this project we build using yarn, not npm. --- .github/workflows/npm.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/npm.yml b/.github/workflows/npm.yml index 46c674e..b405e92 100644 --- a/.github/workflows/npm.yml +++ b/.github/workflows/npm.yml @@ -7,7 +7,7 @@ on: paths: - "contracts/**" - "package.json" - - "package-lock.json" + - "yarn.json" workflow_dispatch: jobs: @@ -19,7 +19,7 @@ jobs: - uses: actions/setup-node@v2 with: node-version: "14.x" - cache: "npm" + cache: "yarn" registry-url: "https://registry.npmjs.org" - name: Bump up package version From 196ed307ec3419845aa84c2dd9cd00d9d19f00fc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michalina=20Ciencia=C5=82a?= Date: Mon, 7 Feb 2022 14:56:01 +0100 Subject: [PATCH 3/4] Use `pre` suffix & tag instead of `dev` We'll be useing a `pre` tag for this package with contracts. We decided to use 'dev` suffix for projects where we deploy contracts (and there is a need for distinction between environments). Here we don't deploy contracts, so we can use `pre` suffix/tag. --- .github/workflows/npm.yml | 4 ++-- package.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/npm.yml b/.github/workflows/npm.yml index b405e92..495b742 100644 --- a/.github/workflows/npm.yml +++ b/.github/workflows/npm.yml @@ -26,11 +26,11 @@ jobs: id: npm-version-bump uses: keep-network/npm-version-bump@v2 with: - environment: dev + environment: pre branch: ${{ github.ref }} commit: ${{ github.sha }} - name: Publish package env: NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} - run: npm publish --access public --tag development + run: npm publish --access public --tag pre diff --git a/package.json b/package.json index d5df8a6..5fbbd3a 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@thesis-co/solidity-contracts", - "version": "0.0.1-dev", + "version": "0.0.1-pre", "license": "MIT", "files": [ "contracts/**/*.sol" From 179d6d804d699e54780dcffd433e4d58af725411 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michalina=20Ciencia=C5=82a?= Date: Fri, 4 Mar 2022 13:25:13 +0100 Subject: [PATCH 4/4] Fix extension of file in `paths` trigger --- .github/workflows/npm.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/npm.yml b/.github/workflows/npm.yml index 495b742..a5706ed 100644 --- a/.github/workflows/npm.yml +++ b/.github/workflows/npm.yml @@ -7,7 +7,7 @@ on: paths: - "contracts/**" - "package.json" - - "yarn.json" + - "yarn.lock" workflow_dispatch: jobs: