Skip to content
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
152 changes: 152 additions & 0 deletions .github/deploy-contracts.yml
Original file line number Diff line number Diff line change
@@ -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 }}
3 changes: 3 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"prettier.singleQuote": true
}