From 57e6c2f13246e01ad27f9bc6e560b7150481234e Mon Sep 17 00:00:00 2001 From: Dehorla-Tech Date: Sun, 27 Apr 2025 09:56:38 +0100 Subject: [PATCH 1/3] fix: persist version updates during deployment workflow --- .github/workflows/deploy-contracts.yml | 152 +++++++++++++++++++++++++ 1 file changed, 152 insertions(+) create mode 100644 .github/workflows/deploy-contracts.yml diff --git a/.github/workflows/deploy-contracts.yml b/.github/workflows/deploy-contracts.yml new file mode 100644 index 0000000..a7e2009 --- /dev/null +++ b/.github/workflows/deploy-contracts.yml @@ -0,0 +1,152 @@ +name: Deploy Smart Contracts + +on: + push: + branches: + - master + paths: + - "contracts/**" + + workflow_dispatch: + inputs: + network: + description: "Network to deploy to (testnet/mainnet)" + required: true + default: "testnet" + type: choice + options: + - testnet + - mainnet + version: + description: "Custom version to use (e.g., 1.0.0). Leave empty for auto-increment." + required: false + type: string + default: "" + +jobs: + deploy: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v4 + + - name: Setup Node.js + uses: actions/setup-node@v4 + with: + node-version: "22" + cache: "npm" + cache-dependency-path: "package-lock.json" + + - name: Install dependencies + run: npm install --legacy-peer-deps + + - name: Compile contracts + run: npm run compile + + - name: Generate TypeChain types + run: npm run typechain + + - name: Deploy to Testnet + if: github.event_name == 'push' || (github.event_name == 'workflow_dispatch' && github.event.inputs.network == 'testnet') + run: npm run deploy:arbitrum-testnet + env: + ARBITRUM_SEPOLIA_RPC_URL: ${{ secrets.ARBITRUM_SEPOLIA_RPC_URL }} + PRIVATE_KEY: ${{ secrets.DEPLOYER_PRIVATE_KEY }} + ARBISCAN_API_KEY: ${{ secrets.ARBISCAN_API_KEY }} + + - name: Deploy to Mainnet + if: github.event_name == 'workflow_dispatch' && github.event.inputs.network == 'mainnet' + run: npm run deploy:arbitrum + env: + ARBITRUM_ONE_RPC_URL: ${{ secrets.ARBITRUM_ONE_RPC_URL }} + PRIVATE_KEY: ${{ secrets.DEPLOYER_PRIVATE_KEY }} + ARBISCAN_API_KEY: ${{ secrets.ARBISCAN_API_KEY }} + + - name: Verify Contracts on Testnet + if: github.event_name == 'push' || (github.event_name == 'workflow_dispatch' && github.event.inputs.network == 'testnet') + run: npm run verify:all-arbitrum-testnet + env: + ARBITRUM_SEPOLIA_RPC_URL: ${{ secrets.ARBITRUM_SEPOLIA_RPC_URL }} + ARBISCAN_API_KEY: ${{ secrets.ARBISCAN_API_KEY }} + + - name: Verify Contracts on Mainnet + if: github.event_name == 'workflow_dispatch' && github.event.inputs.network == 'mainnet' + run: npm run verify:all-arbitrum + env: + ARBITRUM_ONE_RPC_URL: ${{ secrets.ARBITRUM_ONE_RPC_URL }} + ARBISCAN_API_KEY: ${{ secrets.ARBISCAN_API_KEY }} + + - name: Upload Deployment Artifacts + uses: actions/upload-artifact@v4 + with: + name: deployment-artifacts + path: | + scripts/deployed_addresses_arbitrum.json + typechain-types/ + if-no-files-found: error + + publish-package: + needs: deploy + if: github.event_name != 'pull_request' + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v4 + + - name: Setup Node.js + uses: actions/setup-node@v4 + with: + node-version: "22" + cache: "npm" + cache-dependency-path: "package-lock.json" + registry-url: "https://registry.npmjs.org" + + - name: Download Deployment Artifacts + uses: actions/download-artifact@v4 + with: + name: deployment-artifacts + path: . + + - name: Install dependencies + run: npm install --legacy-peer-deps + + - name: Compile contracts + run: npm run compile + + - name: Update package version + id: version + run: | + VERSION=$(npx ts-node scripts/update-version.ts) + echo "version=$VERSION" >> $GITHUB_OUTPUT + echo "NEW_VERSION=$VERSION" >> $GITHUB_ENV + + - name: Commit version changes + run: | + git config --global user.name 'github-actions[bot]' + git config --global user.email 'github-actions[bot]@users.noreply.github.com' + git add package.json + git commit -m "chore: bump version to ${{ env.NEW_VERSION }}" + git push + + - name: Generate Package + run: npx ts-node scripts/generate-package.ts + + - name: Publish Package + run: | + cd package + npm config set //registry.npmjs.org/:_authToken ${{ secrets.NPM_TOKEN }} + npm publish --access public + env: + NPM_TOKEN: ${{ secrets.NPM_TOKEN }} + + # - name: Create GitHub Release + # uses: softprops/action-gh-release@v1 + # with: + # tag_name: v${{ env.NEW_VERSION }} + # name: Contracts v${{ env.NEW_VERSION }} + # body: | + # DeCleanup Network Smart Contracts Release + # - Deployed to ${{ github.event_name == 'workflow_dispatch' && github.event.inputs.network == 'mainnet' && 'Arbitrum Mainnet' || 'Arbitrum Testnet' }} + # - Published to npm as @decleanup/contracts@${{ env.NEW_VERSION }} + # env: + # GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} From 28e31f72f845c6d6b36fd7d1352f6d6035c265bd Mon Sep 17 00:00:00 2001 From: Dehorla-Tech Date: Thu, 1 May 2025 01:57:15 +0100 Subject: [PATCH 2/3] updated deploy-contracts --- .github/workflows/deploy-contracts.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/deploy-contracts.yml b/.github/workflows/deploy-contracts.yml index a7e2009..830ca2b 100644 --- a/.github/workflows/deploy-contracts.yml +++ b/.github/workflows/deploy-contracts.yml @@ -117,15 +117,15 @@ jobs: id: version run: | VERSION=$(npx ts-node scripts/update-version.ts) - echo "version=$VERSION" >> $GITHUB_OUTPUT - echo "NEW_VERSION=$VERSION" >> $GITHUB_ENV + echo 'version=$VERSION' >> $GITHUB_OUTPUT + echo 'NEW_VERSION=$VERSION' >> $GITHUB_ENV - name: Commit version changes run: | git config --global user.name 'github-actions[bot]' git config --global user.email 'github-actions[bot]@users.noreply.github.com' git add package.json - git commit -m "chore: bump version to ${{ env.NEW_VERSION }}" + git commit -m 'chore: bump version to ${{ env.NEW_VERSION }}' git push - name: Generate Package From bf8bea0acda2b9ccebbda0b170a007e8b4709fda Mon Sep 17 00:00:00 2001 From: Dehorla-Tech Date: Sun, 4 May 2025 13:11:30 +0100 Subject: [PATCH 3/3] updated to sigle qoute --- .github/{workflows => }/deploy-contracts.yml | 38 ++++++++++---------- .vscode/settings.json | 3 ++ 2 files changed, 22 insertions(+), 19 deletions(-) rename .github/{workflows => }/deploy-contracts.yml (84%) create mode 100644 .vscode/settings.json diff --git a/.github/workflows/deploy-contracts.yml b/.github/deploy-contracts.yml similarity index 84% rename from .github/workflows/deploy-contracts.yml rename to .github/deploy-contracts.yml index 830ca2b..844d6c8 100644 --- a/.github/workflows/deploy-contracts.yml +++ b/.github/deploy-contracts.yml @@ -5,23 +5,23 @@ on: branches: - master paths: - - "contracts/**" + - 'contracts/**' workflow_dispatch: inputs: network: - description: "Network to deploy to (testnet/mainnet)" + description: 'Network to deploy to (testnet/mainnet)' required: true - default: "testnet" + default: 'testnet' type: choice options: - testnet - mainnet version: - description: "Custom version to use (e.g., 1.0.0). Leave empty for auto-increment." + description: 'Custom version to use (e.g., 1.0.0). Leave empty for auto-increment.' required: false type: string - default: "" + default: '' jobs: deploy: @@ -33,9 +33,9 @@ jobs: - name: Setup Node.js uses: actions/setup-node@v4 with: - node-version: "22" - cache: "npm" - cache-dependency-path: "package-lock.json" + node-version: '22' + cache: 'npm' + cache-dependency-path: 'package-lock.json' - name: Install dependencies run: npm install --legacy-peer-deps @@ -96,10 +96,10 @@ jobs: - name: Setup Node.js uses: actions/setup-node@v4 with: - node-version: "22" - cache: "npm" - cache-dependency-path: "package-lock.json" - registry-url: "https://registry.npmjs.org" + node-version: '22' + cache: 'npm' + cache-dependency-path: 'package-lock.json' + registry-url: 'https://registry.npmjs.org' - name: Download Deployment Artifacts uses: actions/download-artifact@v4 @@ -109,7 +109,7 @@ jobs: - name: Install dependencies run: npm install --legacy-peer-deps - + - name: Compile contracts run: npm run compile @@ -117,17 +117,17 @@ jobs: id: version run: | VERSION=$(npx ts-node scripts/update-version.ts) - echo 'version=$VERSION' >> $GITHUB_OUTPUT - echo 'NEW_VERSION=$VERSION' >> $GITHUB_ENV - + echo "version=$VERSION" >> $GITHUB_OUTPUT + echo "NEW_VERSION=$VERSION" >> $GITHUB_ENV + - name: Commit version changes run: | git config --global user.name 'github-actions[bot]' git config --global user.email 'github-actions[bot]@users.noreply.github.com' git add package.json - git commit -m 'chore: bump version to ${{ env.NEW_VERSION }}' + git commit -m "chore: bump version to ${{ env.NEW_VERSION }}" git push - + - name: Generate Package run: npx ts-node scripts/generate-package.ts @@ -149,4 +149,4 @@ jobs: # - Deployed to ${{ github.event_name == 'workflow_dispatch' && github.event.inputs.network == 'mainnet' && 'Arbitrum Mainnet' || 'Arbitrum Testnet' }} # - Published to npm as @decleanup/contracts@${{ env.NEW_VERSION }} # env: - # GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + # GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} \ No newline at end of file diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 0000000..4be5a42 --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,3 @@ +{ + "prettier.singleQuote": true +} \ No newline at end of file