Skip to content

Commit 41d2b16

Browse files
committed
chore: migrate from dfx to icp-cli
1 parent 61dc24e commit 41d2b16

File tree

7 files changed

+48
-91
lines changed

7 files changed

+48
-91
lines changed

.github/workflows/cd.yml

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -34,28 +34,30 @@ jobs:
3434
with:
3535
node-version: 18
3636

37-
- name: Install DFX
38-
uses: dfinity/setup-dfx@main
39-
with:
40-
dfx-version: 0.29.2
37+
- name: Install ICP-CLI
38+
run: |
39+
curl --proto '=https' --tlsv1.2 -LsSf https://github.com/dfinity/icp-cli/releases/download/v0.1.0-beta.6/icp-cli-installer.sh | sh
40+
echo "$HOME/.cargo/bin" >> $GITHUB_PATH
4141
42-
- name: Dump Identity
42+
- name: Setup Identity
4343
run: |
44-
mkdir -p ~/.config/dfx/identity/default
45-
echo $DFX_IDENTITY_DESIGN_TEAM | base64 -d > ~/.config/dfx/identity/default/identity.pem
46-
sed -i 's/\\r\\n/\r\n/g' ~/.config/dfx/identity/default/identity.pem
44+
mkdir -p ~/.local/share/icp-cli/identity/keys
45+
echo $ICP_IDENTITY_PORTAL_DEPLOY | base64 -d > ~/.local/share/icp-cli/identity/keys/portal-deploy.pem
46+
sed -i 's/\\r\\n/\r\n/g' ~/.local/share/icp-cli/identity/keys/portal-deploy.pem
47+
icp identity import portal-deploy --from-pem ~/.local/share/icp-cli/identity/keys/portal-deploy.pem --storage plaintext
48+
icp identity default portal-deploy
4749
env:
48-
DFX_IDENTITY_DESIGN_TEAM: ${{ secrets.DFX_IDENTITY_DESIGN_TEAM }}
50+
ICP_IDENTITY_PORTAL_DEPLOY: ${{ secrets.DFX_IDENTITY_DESIGN_TEAM }}
4951

5052
- name: Check Canister Balance
5153
run: |
52-
balance=$(dfx canister --network ic status portal 2>&1 >/dev/null | grep Balance: | sed 's/[^0-9]//g')
54+
balance=$(icp canister status portal -e ic 2>&1 >/dev/null | grep Balance: | sed 's/[^0-9]//g')
5355
LANG=en_US.UTF-8
5456
balance_formatted=$(echo $balance | awk '{printf "%'\''d\n", $0}')
5557
echo "Canister balance: $balance_formatted"
5658
if [ "5000000000000" -gt "$balance" ]; then
57-
canister_id=$(cat "$GITHUB_WORKSPACE/canister_ids.json" | jq -r '.portal.ic')
58-
template="{ \"channel\": \"C04EGHHU9U2\", \"blocks\": [ { \"type\": \"section\", \"text\": { \"type\": \"mrkdwn\", \"text\": \"@channel internetcomputer.org canister \`$canister_id\` balance is \`$balance_formatted\`.\n\nTop it up by\n- running \`dfx ledger --network ic top-up $canister_id --amount 5.0\`\n- or by adding the canister on the NNS and sending cycles to it.\" } } ]}"
59+
canister_id=$(cat "$GITHUB_WORKSPACE/.icp/data/mappings/ic.ids.json" | jq -r '.portal')
60+
template="{ \"channel\": \"C04EGHHU9U2\", \"blocks\": [ { \"type\": \"section\", \"text\": { \"type\": \"mrkdwn\", \"text\": \"@channel internetcomputer.org canister \`$canister_id\` balance is \`$balance_formatted\`.\n\nTop it up by\n- running \`icp canister top-up $canister_id --amount 5t -e ic\`\n- or by adding the canister on the NNS and sending cycles to it.\" } } ]}"
5961
curl --data "$template" -H "Content-type: application/json" -H "Authorization: Bearer $SLACK_TOKEN" -X POST https://slack.com/api/chat.postMessage -o /dev/null
6062
fi
6163
env:
@@ -65,12 +67,10 @@ jobs:
6567
run: npm install
6668

6769
- name: Deploy to Mainnet
68-
run: dfx deploy --network=ic --no-wallet portal --verbose --yes
69-
env:
70-
DFX_WARNING: -mainnet_plaintext_identity
70+
run: icp deploy portal -e ic
7171

7272
- name: Get URL
7373
id: get-url
7474
run: |
75-
URL="https://$(cat "$GITHUB_WORKSPACE/canister_ids.json" | jq -r '.portal.ic').icp0.io"
75+
URL="https://$(cat "$GITHUB_WORKSPACE/.icp/data/mappings/ic.ids.json" | jq -r '.portal').icp0.io"
7676
echo "url=$URL" >> $GITHUB_OUTPUT

.github/workflows/preview-deployment.yml

Lines changed: 15 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -33,46 +33,28 @@ jobs:
3333
with:
3434
python-version: "3.10"
3535

36-
- name: Install DFX
37-
uses: dfinity/setup-dfx@main
38-
with:
39-
dfx-version: 0.29.2
40-
41-
- name: Cache icx-asset binary
42-
id: cache-icx-asset-bin
43-
uses: actions/cache@v3
44-
with:
45-
path: sdk/target/release/icx-asset
46-
key: icxassetbin-master
47-
restore-keys: |
48-
icxassetbin-
49-
50-
- name: Install icx-asset
51-
if: steps.cache-icx-asset-bin.outputs.cache-hit != 'true'
36+
- name: Install ICP-CLI
5237
run: |
53-
rm -rf sdk
54-
git clone --depth 1 https://github.com/dfinity/sdk.git
55-
cd sdk
56-
cargo build -p icx-asset --release
57-
58-
- name: Add icx-asset to path
59-
run: |
60-
echo "`pwd`/sdk/target/release/" >> $GITHUB_PATH
38+
curl --proto '=https' --tlsv1.2 -LsSf https://github.com/dfinity/icp-cli/releases/download/v0.1.0-beta.6/icp-cli-installer.sh | sh
39+
echo "$HOME/.cargo/bin" >> $GITHUB_PATH
6140
6241
- name: "Build & Deploy"
6342
run: |
64-
mkdir -p ~/.config/dfx/identity/default
65-
66-
echo $DFX_IDENTITY_PREVIEW | base64 -d > ~/.config/dfx/identity/default/identity.pem
67-
sed -i 's/\\r\\n/\r\n/g' ~/.config/dfx/identity/default/identity.pem
43+
# Setup identity
44+
mkdir -p ~/.local/share/icp-cli/identity/keys
45+
echo $ICP_IDENTITY_PREVIEW | base64 -d > ~/.local/share/icp-cli/identity/keys/preview-deploy.pem
46+
sed -i 's/\\r\\n/\r\n/g' ~/.local/share/icp-cli/identity/keys/preview-deploy.pem
47+
icp identity import preview-deploy --from-pem ~/.local/share/icp-cli/identity/keys/preview-deploy.pem --storage plaintext
48+
icp identity default preview-deploy
6849
6950
# request preview canister from the pool
7051
pull_number=$(jq --raw-output .pull_request.number "$GITHUB_EVENT_PATH")
7152
pip install ic-py
7253
canister_id=$(python3 .github/workflows/scripts/request-canister.py $pull_number)
7354
74-
# overwrite canister id in dfx.json
75-
echo "{\"portal\":{\"ic\":\"$canister_id\"}}" > canister_ids.json
55+
# Create icp-cli canister ID mapping for ic environment
56+
mkdir -p .icp/data/mappings
57+
echo "{\"portal\":\"$canister_id\"}" > .icp/data/mappings/ic.ids.json
7658
7759
echo "PREVIEW_CANISTER_ID=$canister_id" >> $GITHUB_ENV
7860
@@ -82,15 +64,11 @@ jobs:
8264
8365
export PREVIEW_CANISTER_ID=$canister_id
8466
85-
dfx canister --network ic create --all
86-
time dfx build --network ic portal
87-
dfx canister --network ic install portal --mode=reinstall --yes --wasm .dfx/ic/canisters/portal/assetstorage.wasm.gz || true
88-
89-
time icx-asset --replica https://icp0.io --pem ~/.config/dfx/identity/default/identity.pem sync $canister_id build
67+
# Deploy the canister (build + install in one step)
68+
time icp deploy portal -e ic --mode reinstall
9069
9170
env:
92-
DFX_IDENTITY_PREVIEW: ${{ secrets.DFX_IDENTITY_PREVIEW }}
93-
DFX_WARNING: -mainnet_plaintext_identity
71+
ICP_IDENTITY_PREVIEW: ${{ secrets.DFX_IDENTITY_PREVIEW }}
9472
POOL_CANISTER_ID: ${{ secrets.POOL_CANISTER_ID }}
9573
SLACK_TOKEN: ${{ secrets.SLACK_TOKEN }}
9674

.gitignore

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,4 +31,7 @@ unlighthouse.config.ts
3131
# Local Netlify folder
3232
.netlify
3333
/roadmap/roadmap.json
34-
/roadmap/roadmap.d.ts
34+
/roadmap/roadmap.d.ts
35+
36+
# ICP-CLI local/cache files (keep .icp/data/mappings/ for IC mainnet IDs)
37+
.icp/cache/

.icp/data/mappings/ic.ids.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"portal": "23pwq-taaaa-aaaaa-qdepa-cai"
3+
}

canister_ids.json

Lines changed: 0 additions & 5 deletions
This file was deleted.

dfx.json

Lines changed: 0 additions & 32 deletions
This file was deleted.

icp.yaml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
canisters:
2+
- name: portal
3+
recipe:
4+
type: '@dfinity/asset-canister'
5+
configuration:
6+
version: 0.30.2
7+
build:
8+
- npm install
9+
- npm run build
10+
dir: build

0 commit comments

Comments
 (0)