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

Add workflow to update dependencies on version change #82

Closed
wants to merge 5 commits into from
Closed
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: 4 additions & 4 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ jobs:
export PRIVATE_KEY=$ANVIL_PRIVATE_KEY # just needs to be in the correct format, no tx is sent in unit tests
export PRIVATE_KEY_GOERLI=$ANVIL_PRIVATE_KEY
pnpm test

client-tests:
name: Client Tests
runs-on: ubuntu-latest
Expand All @@ -73,7 +73,7 @@ jobs:

- name: Set all packages to local and build
working-directory: ./
run: pnpm local
run: node scripts/setLocal.js

- name: Run Unit Tests (Client)
working-directory: ./client
Expand All @@ -82,7 +82,7 @@ jobs:
- name: Run Integration Tests (Client)
working-directory: ./client
run: pnpm test test/integration

harness:
name: Harness Tests
runs-on: ubuntu-latest
Expand All @@ -106,7 +106,7 @@ jobs:

- name: Set all packages to local and build
working-directory: ./
run: pnpm local
run: node scripts/setLocal.js

- name: Run Integration Tests (Sepolia)
working-directory: ./harness
Expand Down
98 changes: 98 additions & 0 deletions .github/workflows/update-dependents.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
name: Update Dependent Repositories

on:
push:
branches:
- main
paths:
- 'package.json'

jobs:
update-dependents:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3

- name: Set up Node.js
uses: actions/setup-node@v3
with:
node-version: '20'

- name: Extract version from package.json
id: package_version
run: echo "::set-output name=VERSION::$(cat package.json | jq -r .version)"

- name: Check if version has changed
id: check_version
run: |
VERSION=$(cat package.json | jq -r .version)
LAST_VERSION=$(git tag --sort=-v:refname | head -n 1)
if [ "$VERSION" != "$LAST_VERSION" ]; then
echo "Version has changed from $LAST_VERSION to $VERSION"
echo "::set-output name=VERSION_CHANGED::true"
else
echo "Version has not changed"
echo "::set-output name=VERSION_CHANGED::false"
exit 78 # Neutral exit to stop the workflow
fi

- name: Check out axiom-quickstart repository
if: steps.check_version.outputs.VERSION_CHANGED == 'true'
uses: actions/checkout@v3
with:
repository: 'axiom-crypto/axiom-quickstart'
token: ${{ secrets.GITHUB_TOKEN }}
path: 'axiom-quickstart'

- name: Update @axiom-crypto/client in axiom-quickstart
if: steps.check_version.outputs.VERSION_CHANGED == 'true'
run: |
cd axiom-quickstart
jq '.dependencies["@axiom-crypto/client"] = "${{ steps.package_version.outputs.VERSION }}"' package.json > temp.json
mv temp.json package.json
git config user.name 'github-actions'
git config user.email '[email protected]'
git add package.json
git commit -m 'Update @axiom-crypto/client to ${{ steps.package_version.outputs.VERSION }}'
git push

- name: Check out axiom-scaffold-nextjs repository
if: steps.check_version.outputs.VERSION_CHANGED == 'true'
uses: actions/checkout@v3
with:
repository: 'axiom-crypto/axiom-scaffold-nextjs'
token: ${{ secrets.GITHUB_TOKEN }}
path: 'axiom-scaffold-nextjs'

- name: Update @axiom-crypto/react in axiom-scaffold-nextjs
if: steps.check_version.outputs.VERSION_CHANGED == 'true'
run: |
cd axiom-scaffold-nextjs
jq '.dependencies["@axiom-crypto/react"] = "${{ steps.package_version.outputs.VERSION }}"' package.json > temp.json
mv temp.json package.json
git config user.name 'github-actions'
git config user.email '[email protected]'
git add package.json
git commit -m 'Update @axiom-crypto/react to ${{ steps.package_version.outputs.VERSION }}'
git push

- name: Create Pull Request for axiom-quickstart
if: steps.check_version.outputs.VERSION_CHANGED == 'true'
uses: repo-sync/pull-request@v3
with:
source_branch: "main"
destination_branch: "update-dependency-${{ steps.package_version.outputs.VERSION }}"
github_token: ${{ secrets.GITHUB_TOKEN }}
pr_title: "Update @axiom-crypto/client to ${{ steps.package_version.outputs.VERSION }}"
pr_body: "This PR updates the @axiom-crypto/client package to version ${{ steps.package_version.outputs.VERSION }}."

- name: Create Pull Request for axiom-scaffold-nextjs
if: steps.check_version.outputs.VERSION_CHANGED == 'true'
uses: repo-sync/pull-request@v3
with:
source_branch: "main"
destination_branch: "update-dependency-${{ steps.package_version.outputs.VERSION }}"
github_token: ${{ secrets.GITHUB_TOKEN }}
pr_title: "Update @axiom-crypto/react to ${{ steps.package_version.outputs.VERSION }}"
pr_body: "This PR updates the @axiom-crypto/react package to version ${{ steps.package_version.outputs.VERSION }}."
47 changes: 37 additions & 10 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,18 +1,45 @@
{
"name": "axiom-sdk-client",
"version": "2.0.7",
"description": "Axiom client SDK",
"version": "2.0.8",
"description": "Axiom client SDK for interacting with Axiom blockchain services",
"scripts": {
"remote": "node -e 'require(\"./scripts/setRemote.js\").setRemote()'",
"local": "node scripts/setLocal.js",
"versions": "node scripts/setVersions.js",
"build-all": "node scripts/buildAll.js",
"publish-all": "node scripts/publishAll.js"
"test": "echo \"Error: no test specified\" && exit 1",
"build": "tsc",
"lint": "eslint . --ext .ts",
"prepare": "npm run build",
"prepublishOnly": "npm test && npm run lint",
"setLocal": "node scripts/setLocal.js",
"setRemote": "node scripts/setRemote.js",
"setVersions": "node scripts/setVersions.js",
"buildAll": "node scripts/buildAll.js",
"publishAll": "node scripts/publishAll.js"
},
"keywords": [],
"author": "Intrinsic Technologies",
"repository": {
"type": "git",
"url": "git+https://github.com/axiom-crypto/axiom-sdk-client.git"
},
"keywords": [
"axiom",
"sdk",
"client",
"blockchain",
"crypto"
],
"author": "Axiom Crypto",
"license": "MIT",
"bugs": {
"url": "https://github.com/axiom-crypto/axiom-sdk-client/issues"
},
"homepage": "https://github.com/axiom-crypto/axiom-sdk-client#readme",
"devDependencies": {
"ethers": "^6.11.1"
"@types/node": "^12.0.0",
"typescript": "^3.8.3",
"eslint": "^6.8.0",
"prettier": "^2.0.5"
},
"dependencies": {
"@axiom-crypto/base": "^1.0.0",
"axios": "^0.19.2",
"ethers": "^5.0.0"
}
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we don't want to delete the entire contents of package.json

Loading