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

Changeset PRs #96

Merged
merged 24 commits into from
Jul 17, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
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
8 changes: 8 additions & 0 deletions .changeset/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# Changesets

Hello and welcome! This folder has been automatically generated by `@changesets/cli`, a build tool that works
with multi-package repos, or single-package repos to help you version and publish your code. You can
find the full documentation for it [in our repository](https://github.com/changesets/changesets)

We have a quick list of common questions to get you started engaging with this project in
[our documentation](https://github.com/changesets/changesets/blob/main/docs/common-questions.md)
11 changes: 11 additions & 0 deletions .changeset/config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"$schema": "https://unpkg.com/@changesets/[email protected]/schema.json",
"changelog": "@changesets/cli/changelog",
"commit": false,
"fixed": [],
"linked": [],
"access": "restricted",
"baseBranch": "main",
"updateInternalDependencies": "patch",
"ignore": []
}
40 changes: 40 additions & 0 deletions .github/workflows/changesets.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
name: Release

on:
push:
branches:
- main

concurrency: ${{ github.workflow }}-${{ github.ref }}

jobs:
release:
name: Release
runs-on: ubuntu-latest
steps:
- name: Checkout Repo
uses: actions/checkout@v3

- name: Install Node.js
uses: actions/setup-node@v3
with:
node-version: 16
cache: 'yarn'

- name: Install project dependencies
run: yarn

- name: Install Foundry
uses: foundry-rs/foundry-toolchain@v1
with:
version: nightly

- name: Create Release Pull Request or Publish to npm
id: changesets
uses: changesets/action@v1
with:
# This expects you to have a script called release which does a build for your packages and calls changeset publish
publish: yarn release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
29 changes: 29 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
name: Release

on:
push:
branches:
- main

concurrency: ${{ github.workflow }}-${{ github.ref }}

jobs:
release:
name: Release
runs-on: ubuntu-latest
steps:
- name: Checkout Repo
uses: actions/checkout@v3

- name: Setup Node.js 16
uses: actions/setup-node@v3
with:
node-version: 16

- name: Install Dependencies
run: npm install

- name: Create Release Pull Request
uses: changesets/action@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
13 changes: 0 additions & 13 deletions DEPLOYING.md

This file was deleted.

47 changes: 47 additions & 0 deletions DEVELOPING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
# Developer Workflow

## Deploying to a new chain

1. Setup new `chainConfigs` file setting 1. fee recipient, and 2. owner for factory contracts
2. Run forge/foundry deploy script
3. Update deployed addresses file `yarn run update-new-deployment-addresses`
4. Verify `addresses/CHAINID.json` exists.
5. Ensure contracts are verified on block explorer.
7. Add a changeset with `npx changeset`
6. Make PR with new addresses json files and changeset.

# Whats bundled in the published package

* `/package/wagmiGenerated.ts` - smart contract abis and deployment addresses
* `./package/chainConfigs.ts` - configuration of smart contracts by chainId

# Publishing the package; Generating changesets, versioning, building and Publishing.

Diagram of the deploying + publishing workflow:
![Deploying & Publishing Workflow](uml/generated/deployment.svg)

Publishing happens in the following steps:

* Some changes are made to the repo; this can include smart contract changes or additions, if smart contracts are changed, tests should be created or updated to reflect the changes.
* The changes are committed to a branch which is **pushed** to **github**.
* A **pr** is **opened** for this branch.
* The changes are reviewed, if they are **approved**:
* *If there are changes to the smart contracts that should be deployed*: the contract should be. Deploying the contract results in the addresses of the deployed contracts being updated in the corresponding `./addresses/{chainId}.json` file. This file should be committed and pushed to github.
* Running the command `npx changeset` will generate **a new changeset** in the `./changesets` directory. This changeset will be used to determine the next version of the bundled packages; this commit should then be pushed.
* The changeset and smart contract addresses are pushed to the branch.
* The pr is merged into main - any changesets in the PR are detected by a github action `release`, which will then **open a new PR** with proper the versions and readme updated in each each package. If more changesets are pushed to main before this branch is merged, the PR will continuously update the version of the packages according to the changeset specifiction.

7. That version is merged into main along with the new versions.

8. The package is the published to npm with the command: `yarn publish-packages` and the package is published.

In a future version, the when the version branch is merged into main, it can publish the new repos to github.

Some active questions:

* How do we ensure the contract version matches the package version? Or does it need to match? Sometimes there is a js package update without a smart contract update.

Future ideas:

* Allow deployment to happen via github actions:
* Deployments can be added to changesets through some command. If a changeset is pushed to main and a deployment is detected in it, a deployment task is added to the PR that's created. When that PR is merged, the deployment happens, and a new package is built and publised to npm with the new versions.
14 changes: 13 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,16 @@ Most controls exist on a per-contract and per-token level. Per contract level is

## Bug Bounty

5 ETH for any critical bugs that could result in loss of funds. Rewards will be given for smaller bugs or ideas.
5 ETH for any critical bugs that could result in loss of funds. Rewards will be given for smaller bugs or ideas.

## Publishing a new version to npm

Generate a new changeset in your branch with:

npx changeset

When the branch is merged to main, the versions will be automatically updated in the corresponding packages.

To publish the updated version:

yarn publish-packages
2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
"build": "tsup",
"bundle-configs": "node script/bundle-chainConfigs.mjs && yarn prettier",
"wagmi": "wagmi generate",
"publish-packages": "yarn prepack && changeset publish",
"storage-inspect:check": "./script/storage-check.sh check ZoraCreator1155Impl ZoraCreator1155FactoryImpl",
"storage-inspect:generate": "./script/storage-check.sh generate ZoraCreator1155Impl ZoraCreator1155FactoryImpl"
},
Expand All @@ -36,6 +37,7 @@
"forge-std": "https://github.com/foundry-rs/forge-std#cd7d533f9a0ee0ec02ad81e0a8f262bc4203c653"
},
"devDependencies": {
"@changesets/cli": "^2.26.1",
"@types/node": "^20.1.2",
"@wagmi/cli": "^1.0.1",
"es-main": "^1.2.0",
Expand Down
48 changes: 48 additions & 0 deletions uml/deployment.puml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
@startuml
actor Developer
actor AnotherDeveloper
actor Reviewer
entity LocalBranch
entity RemotePR
entity main
participant ReleaseGithubAction
entity VersionPackagesPR
participant blockchain
participant npm

Activate LocalBranch
Developer -> LocalBranch: Change smart contracts \nand commit
Developer -> LocalBranch: npx changeset - create a changeset \n& commit
Developer -> LocalBranch: Git push & open PR
LocalBranch --> RemotePR: Deltas and changeset
activate RemotePR
Reviewer -> RemotePR: Approve PR
Developer -> LocalBranch: Deploy to all chains
LocalBranch --> blockchain: Updated or new smart contracts
LocalBranch --> LocalBranch: Update addresses json files
Developer -> LocalBranch: push updated addresses json files
LocalBranch --> RemotePR: Updated addresses json files
deactivate LocalBranch
Developer -> RemotePR: Merge to main
RemotePR --> main: Code Deltas + Changesets + \nUpdated addresses
deactivate RemotePR
activate main
main --> ReleaseGithubAction: Changes to main \nincluding changeset
deactivate main
ReleaseGithubAction -> VersionPackagesPR: Create a PR with new versions \napplied to package.jsons from \ninstrucitons in new changesets
activate VersionPackagesPR
AnotherDeveloper -> main: Push a new changeset
activate main
main --> ReleaseGithubAction: new changeset
deactivate main
ReleaseGithubAction -> VersionPackagesPR: Update PR with new versions \napplied to package.jsons from \ninstrucitons in new changests
Developer -> VersionPackagesPR: merge to main
VersionPackagesPR --> main: Updated versions in packages.
deactivate VersionPackagesPR
activate main
main -> ReleaseGithubAction: new versions in package.jsons
ReleaseGithubAction -> npm: Build and publish packages
deactivate main
activate npm

@enduml
16 changes: 16 additions & 0 deletions uml/generateSvg.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#!/bin/sh
# converts all puml files to svg
# requires Docker to be installed and running

BASEDIR=$(dirname "$0")
# create output dir env var which is basedir/generated:
OUTPUT_DIR=$BASEDIR/generated
mkdir -p $OUTPUT_DIR
for FILE in $BASEDIR/*.puml; do
echo Converting $FILE..
FILE_SVG=${FILE//puml/svg}
cat $FILE | docker run --rm -i think/plantuml > $FILE_SVG
docker run --rm -v $PWD:/diagrams productionwentdown/ubuntu-inkscape inkscape /diagrams/$FILE_SVG --export-area-page --without-gui &> /dev/null
done
mv $BASEDIR/*.svg $OUTPUT_DIR
echo Done
1 change: 1 addition & 0 deletions uml/generated/deployment.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading