Skip to content

Commit

Permalink
Use changesets to manager versioning and releasing
Browse files Browse the repository at this point in the history
  • Loading branch information
SamuelQZQ committed Jun 14, 2023
1 parent b2f4671 commit 5d3395d
Show file tree
Hide file tree
Showing 10 changed files with 1,379 additions and 33 deletions.
15 changes: 15 additions & 0 deletions .changeset/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# How to upgrade the version

- Run `yarn changesets`, and describe you change.
- Commit the `.md` file generated by `changeset` together with your code changes. And merge your change.
- Github Workflow will create a PR to change the version in `package.json`.
- Github Workflow will publish a new version to NPM after we merge the PR.

# 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)
5 changes: 5 additions & 0 deletions .changeset/brown-rabbits-taste.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@thalalabs/surf': patch
---

Add changeset as devDependency and use it to manage the versioning and releasing.
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": []
}
1 change: 0 additions & 1 deletion .github/workflows/nodejs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ jobs:
with:
node-version: 16.x
- run: yarn install --frozen-lockfile
- run: yarn lint
- run: yarn test
- run: yarn build
env:
Expand Down
31 changes: 31 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
name: Publish
on:
workflow_run:
workflows: ["CI"]
types:
- completed
push:
branches:
- "main"

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

jobs:
publish:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v3
with:
node-version: 16.x
- run: yarn install --frozen-lockfile
- run: yarn test
- name: Create Release Pull Request or Publish
id: changesets
uses: changesets/action@v1
with:
publish: yarn release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
1 change: 1 addition & 0 deletions .npmignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
images
example
tsconfig.json
tsconfig.release.json
Expand Down
10 changes: 2 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,19 +10,13 @@

<p align="center">
<a href="https://www.npmjs.com/package/@thalalabs/surf">
<picture>
<img src="https://img.shields.io/npm/v/@thalalabs/surf?colorA=2c8af7&colorB=2c8af7&style=flat" alt="Version">
</picture>
</a>
<a href="https://github.com/ThalaLabs/surf/blob/main/LICENSE">
<picture>
<img src="https://img.shields.io/npm/l/@thalalabs/surf?colorA=2c8af7&colorB=2c8af7&style=flat" alt="MIT License">
</picture>
</a>
<a href="https://bundlephobia.com/package/@thalalabs/surf">
<picture>
<img src="https://img.shields.io/bundlephobia/minzip/@thalalabs/surf?colorA=2c8af7&colorB=2c8af7&style=flat" alt="MIT License">
</picture>
</a>
</p>

Expand Down Expand Up @@ -170,9 +164,9 @@ const { hash } = await client.simulateTransaction(
);
```

### Hooks
### React Hooks

Surf currently offers two React Hooks: `useWalletClient` and `useSubmitTransaction`. Both require the `@aptos-labs/wallet-adapter-react`. Check out our [example NextJS package](https://github.com/ThalaLabs/surf/blob/main/example/app/page.tsx) for more information.
Surf currently offers two React Hooks: `useWalletClient` and `useSubmitTransaction`. Both require the `@aptos-labs/wallet-adapter-react`. Check out the [example NextJS package](https://github.com/ThalaLabs/surf/blob/main/example/app/page.tsx) for more information.

## Motivation

Expand Down
14 changes: 7 additions & 7 deletions example/app/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,9 @@ export default function Home() {
data: submitResult } = useSubmitTransaction();
const { client } = useWalletClient({ nodeUrl: "https://fullnode.testnet.aptoslabs.com/v1" });

const [result2, setResult2] = useState("");
const [result, setResult] = useState("");

const onSubmit = async () => {
const onSubmitForUseSubmitTransaction = async () => {
try {
const payload = createEntryPayload(COIN_ABI, {
function: "transfer",
Expand All @@ -55,13 +55,13 @@ export default function Home() {
}
}

const onSubmit2 = async () => {
const onSubmitForUseWalletClient = async () => {
try {
const result = await client.useABI(COIN_ABI).transfer({
arguments: ["0x1", BigInt(1)],
type_arguments: ["0x1::aptos_coin::AptosCoin"]
});
setResult2(result.hash);
setResult(result.hash);
onRefresh();
}
catch (e) {
Expand Down Expand Up @@ -92,7 +92,7 @@ export default function Home() {
margin: "50px",
fontSize: "20px"
}}
onClick={onSubmit}>
onClick={onSubmitForUseSubmitTransaction}>
Submit transaction: transfer 1 coin to 0x1 on testnet <br /> (useSubmitTransaction)
</button>}
{!isIdle && <button style={{
Expand All @@ -108,13 +108,13 @@ export default function Home() {
margin: "50px",
fontSize: "20px"
}}
onClick={onSubmit2}>
onClick={onSubmitForUseWalletClient}>
Submit transaction: transfer 1 coin to 0x1 on testnet <br /> (useWalletClient)
</button>
{submitIsLoading && <div>running</div>}
{submitResult && <div>{`Success: ${submitResult.hash}`}</div>}
{submitError && <div>{`Failed: ${submitError}`}</div>}
{result2 && <div>{`Submission with useWalletClient Success: ${result2}`}</div>}
{result && <div>{`Submission with useWalletClient Success: ${result}`}</div>}
</div>
}
</main>
Expand Down
13 changes: 10 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,14 @@
},
"typesVersions": {
"*": {
"hooks": ["./build/types/hooks/index.d.ts"]
"hooks": [
"./build/types/hooks/index.d.ts"
]
}
},
"devDependencies": {
"@aptos-labs/wallet-adapter-react": "^1.1.0",
"@changesets/cli": "^2.26.1",
"@types/jest": "~29.5",
"@types/node": "~18",
"@types/react": "^18.2.8",
Expand Down Expand Up @@ -74,13 +77,17 @@
"test": "jest --coverage",
"prettier": "prettier --config .prettierrc --write .",
"test:watch": "jest --watch",
"prepublishOnly": "yarn build"
"release": "yarn build && changeset publish"
},
"keywords": [
"move",
"blockchain",
"aptos"
],
"repository": {
"type": "git",
"url": "git+https://github.com/ThalaLabs/surf"
},
"license": "MIT",
"dependencies": {}
}
}
Loading

0 comments on commit 5d3395d

Please sign in to comment.