From cd2889a5ce14a5f8269bf5b311375b5319418dae Mon Sep 17 00:00:00 2001 From: Florin Dzeladini Date: Sun, 24 Nov 2024 22:42:48 +0100 Subject: [PATCH 1/5] chore: two steps CI/CD deployment --- .../workflows/deploy-wallet-get-starknet.yml | 208 ++++++++++++++++++ .github/workflows/publish-npm.yml | 172 +++++++++++++++ 2 files changed, 380 insertions(+) create mode 100644 .github/workflows/deploy-wallet-get-starknet.yml create mode 100644 .github/workflows/publish-npm.yml diff --git a/.github/workflows/deploy-wallet-get-starknet.yml b/.github/workflows/deploy-wallet-get-starknet.yml new file mode 100644 index 00000000..d93aef66 --- /dev/null +++ b/.github/workflows/deploy-wallet-get-starknet.yml @@ -0,0 +1,208 @@ +name: Deploy Wallet-UI and Get-starknet + +on: + workflow_dispatch: + inputs: + environment: + description: 'Environment to deploy' + type: environment + required: true +jobs: + prepare-deployment: + environment: ${{ inputs.environment }} + permissions: + contents: write + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + with: + ref: ${{ github.sha }} + - name: Setup Node.js + uses: actions/setup-node@v3 + with: + node-version: 20.x + - name: Prepare Parameters + id: prepare_parameters + run: | + BASE=$(node -p "require('./packages/starknet-snap/package.json').version") + HASH=$(git rev-parse --short HEAD) + DATE=$(date +%Y%m%d) + ENV=${{ inputs.environment }} + + { + echo "AWS_CLOUDFRONT_DISTRIBUTIONS_ID=${{ vars.AWS_CLOUDFRONT_DISTRIBUTIONS_ID }}" + echo "AWS_S3_GET_STARKNET_URL=${{ vars.AWS_S3_GET_STARKNET_URL }}" + echo "AWS_S3_URL=${{ vars.AWS_S3_URL }}" + echo "GET_STARKNET_PUBLIC_PATH=${{ vars.GET_STARKNET_PUBLIC_PATH }}" + } >> "$GITHUB_OUTPUT" + + if [[ $ENV == "dev" ]]; then + { + echo "VERSION=${BASE}-dev-${HASH}-${DATE}" + echo "TAG=dev" + echo "ENV=dev" + echo "LOG_LEVEL=6" + } >> "$GITHUB_OUTPUT" + elif [[ $ENV == "staging" ]]; then + { + echo "VERSION=${BASE}-staging" + echo "TAG=staging" + echo "ENV=staging" + echo "LOG_LEVEL=0" + } >> "$GITHUB_OUTPUT" + elif [[ $ENV == "production" ]]; then + { + echo "VERSION=${BASE}" + echo "TAG=latest" + echo "ENV=prod" + echo "LOG_LEVEL=0" + } >> "$GITHUB_OUTPUT" + else + echo "Invalid environment" + exit 1 + fi + outputs: + VERSION: ${{ steps.prepare_parameters.outputs.VERSION }} + TAG: ${{ steps.prepare_parameters.outputs.TAG }} + ENV: ${{ steps.prepare_parameters.outputs.ENV }} + AWS_S3_GET_STARKNET_URL: ${{ steps.prepare_parameters.outputs.AWS_S3_GET_STARKNET_URL }} + AWS_CLOUDFRONT_DISTRIBUTIONS_ID: ${{ steps.prepare_parameters.outputs.AWS_CLOUDFRONT_DISTRIBUTIONS_ID }} + AWS_S3_URL: ${{ steps.prepare_parameters.outputs.AWS_S3_URL }} + GET_STARKNET_PUBLIC_PATH: ${{ steps.prepare_parameters.outputs.GET_STARKNET_PUBLIC_PATH }} + CACHE_KEY: ${{ github.sha }}-${{ steps.prepare_parameters.outputs.ENV }} + LOG_LEVEL: ${{ steps.prepare_parameters.outputs.LOG_LEVEL }} + + install-build: + needs: + - prepare-deployment + permissions: + contents: write + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + with: + ref: ${{ github.sha }} + - name: Setup Node.js + uses: actions/setup-node@v3 + with: + node-version: 20.x + - name: Install + run: | + yarn --no-immutable + yarn allow-scripts + - name: Build Snap + run: | + echo "Building UI with version $VERSION" + + REACT_APP_SNAP_VERSION="${VERSION}" yarn workspace wallet-ui build + + echo "Building Get Starknet with GET_STARKNET_PUBLIC_PATH=$GET_STARKNET_PUBLIC_PATH" + + GET_STARKNET_PUBLIC_PATH=$GET_STARKNET_PUBLIC_PATH yarn workspace @consensys/get-starknet build + env: + SNAP_ENV: ${{ needs.prepare-deployment.outputs.ENV }} + VERSION: ${{ needs.prepare-deployment.outputs.VERSION }} + VOYAGER_API_KEY: ${{ secrets.VOYAGER_API_KEY }} + ALCHEMY_API_KEY: ${{ secrets.ALCHEMY_API_KEY }} + GET_STARKNET_PUBLIC_PATH: ${{ needs.prepare-deployment.outputs.GET_STARKNET_PUBLIC_PATH }} + LOG_LEVEL: ${{ needs.prepare-deployment.outputs.LOG_LEVEL }} + - name: Cache Build + uses: actions/cache@v3 + id: cache + with: + path: | + ./packages/get-starknet/dist/webpack + ./packages/wallet-ui/build + ./node_modules/.yarn-state.yml + key: ${{ needs.prepare-deployment.outputs.CACHE_KEY }} + + deploy-wallet-ui: + runs-on: ubuntu-latest + needs: + - prepare-deployment + steps: + - name: Configure AWS credentials + uses: aws-actions/configure-aws-credentials@v1 + with: + aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} + aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} + aws-region: eu-central-1 + - uses: actions/checkout@v3 + with: + ref: ${{ github.sha }} + - name: Restore Cached Build + uses: actions/cache@v3 + id: restore-build + with: + path: | + ./packages/get-starknet/dist/webpack + ./packages/wallet-ui/build + ./packages/starknet-snap/package.json + ./packages/starknet-snap/dist + ./packages/starknet-snap/snap.manifest.json + ./node_modules/.yarn-state.yml + key: ${{ needs.prepare-deployment.outputs.CACHE_KEY }} + - name: Deploy to AWS + run: | + echo "Deployed Dapp to : $AWS_S3_URL" + aws s3 sync ./packages/wallet-ui/build "$AWS_S3_URL" + env: + AWS_S3_URL: ${{ needs.prepare-deployment.outputs.AWS_S3_URL }} + + deploy-get-starknet: + runs-on: ubuntu-latest + needs: + - prepare-deployment + - install-build + steps: + - name: Configure AWS credentials + uses: aws-actions/configure-aws-credentials@v1 + with: + aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} + aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} + aws-region: eu-central-1 + - uses: actions/checkout@v3 + with: + ref: ${{ github.sha }} + - name: Restore Cached Build + uses: actions/cache@v3 + id: restore-build + with: + path: | + ./packages/get-starknet/dist/webpack + ./packages/wallet-ui/build + ./node_modules/.yarn-state.yml + key: ${{ needs.prepare-deployment.outputs.CACHE_KEY }} + - name: Deploy to AWS + run: | + echo "Deployed get Starknet to : $AWS_S3_GET_STARKNET_URL" + aws s3 sync ./packages/get-starknet/dist/webpack "$AWS_S3_GET_STARKNET_URL" + env: + AWS_S3_GET_STARKNET_URL: ${{ needs.prepare-deployment.outputs.AWS_S3_GET_STARKNET_URL }} + + invalid-aws-cdn-cache: + runs-on: ubuntu-latest + needs: + - deploy-wallet-ui + - deploy-get-starknet + - prepare-deployment + steps: + - name: Configure AWS credentials + uses: aws-actions/configure-aws-credentials@v1 + with: + aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} + aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} + aws-region: eu-central-1 + - name: Invalid AWS CDN Cache + run: | + echo "Distribution ID : $AWS_CLOUDFRONT_DISTRIBUTIONS_ID" + echo "$AWS_CLOUDFRONT_DISTRIBUTIONS_ID" | tr ',' '\n' | while read -r DISTRIBUTIONS_ID + do + echo "Processing Distribution ID : $DISTRIBUTIONS_ID" + INVALIDED_ID="$(aws cloudfront create-invalidation --distribution-id "$DISTRIBUTIONS_ID" --paths "/starknet/*" | grep Id | awk -F'"' '{ print $4}')" + echo "Waiting for invalidation $INVALIDED_ID" + aws cloudfront wait invalidation-completed --id "$INVALIDED_ID" --distribution-id "$DISTRIBUTIONS_ID" + echo "Invalidation $INVALIDED_ID completed" + done + env: + AWS_CLOUDFRONT_DISTRIBUTIONS_ID: ${{ needs.prepare-deployment.outputs.AWS_CLOUDFRONT_DISTRIBUTIONS_ID }} \ No newline at end of file diff --git a/.github/workflows/publish-npm.yml b/.github/workflows/publish-npm.yml new file mode 100644 index 00000000..2167d01d --- /dev/null +++ b/.github/workflows/publish-npm.yml @@ -0,0 +1,172 @@ +name: Publish NPM + +on: + workflow_dispatch: + inputs: + environment: + description: 'Environment to deploy' + type: environment + required: true +jobs: + prepare-deployment: + environment: ${{ inputs.environment }} + permissions: + contents: write + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + with: + ref: ${{ github.sha }} + - name: Setup Node.js + uses: actions/setup-node@v3 + with: + node-version: 20.x + - name: Prepare Parameters + id: prepare_parameters + run: | + BASE=$(node -p "require('./packages/starknet-snap/package.json').version") + HASH=$(git rev-parse --short HEAD) + DATE=$(date +%Y%m%d) + ENV=${{ inputs.environment }} + + if [[ $ENV == "dev" ]]; then + { + echo "VERSION=${BASE}-dev-${HASH}-${DATE}" + echo "TAG=dev" + echo "ENV=dev" + echo "LOG_LEVEL=6" + } >> "$GITHUB_OUTPUT" + elif [[ $ENV == "staging" ]]; then + { + echo "VERSION=${BASE}-staging" + echo "TAG=staging" + echo "ENV=staging" + echo "LOG_LEVEL=0" + } >> "$GITHUB_OUTPUT" + elif [[ $ENV == "production" ]]; then + { + echo "VERSION=${BASE}" + echo "TAG=latest" + echo "ENV=prod" + echo "LOG_LEVEL=0" + } >> "$GITHUB_OUTPUT" + else + echo "Invalid environment" + exit 1 + fi + outputs: + VERSION: ${{ steps.prepare_parameters.outputs.VERSION }} + TAG: ${{ steps.prepare_parameters.outputs.TAG }} + ENV: ${{ steps.prepare_parameters.outputs.ENV }} + CACHE_KEY: ${{ github.sha }}-${{ steps.prepare_parameters.outputs.ENV }}-npm + LOG_LEVEL: ${{ steps.prepare_parameters.outputs.LOG_LEVEL }} + + install-build: + needs: + - prepare-deployment + permissions: + contents: write + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + with: + ref: ${{ github.sha }} + - name: Setup Node.js + uses: actions/setup-node@v3 + with: + node-version: 20.x + - name: Install + run: | + yarn --no-immutable + yarn allow-scripts + - name: Build Snap + run: | + echo "Building Snap with version $VERSION" + + npm --prefix ./packages/starknet-snap version --new-version "$VERSION" --no-git-tag-version --allow-same-version + + yarn workspace @consensys/starknet-snap build + + BUILD_VERSION=$(node -p "require('./packages/starknet-snap/package.json').version") + + if [[ "$VERSION" != "$BUILD_VERSION" ]]; then + echo "Version mismatch" + exit 1 + fi + env: + SNAP_ENV: ${{ needs.prepare-deployment.outputs.ENV }} + VERSION: ${{ needs.prepare-deployment.outputs.VERSION }} + LOG_LEVEL: ${{ needs.prepare-deployment.outputs.LOG_LEVEL }} + - name: Cache Build + uses: actions/cache@v3 + id: cache + with: + path: | + ./packages/starknet-snap/package.json + ./packages/starknet-snap/dist + ./packages/starknet-snap/snap.manifest.json + ./node_modules/.yarn-state.yml + key: ${{ needs.prepare-deployment.outputs.CACHE_KEY }} + + publish-npm-dry-run: + runs-on: ubuntu-latest + needs: + - prepare-deployment + - install-build + steps: + - uses: actions/checkout@v3 + with: + ref: ${{ github.sha }} + - name: Setup Node.js + uses: actions/setup-node@v3 + with: + node-version: 20.x + - name: Restore Cached Build + uses: actions/cache@v3 + id: restore-build + with: + # add /packages/snap/snap.manifest.json to include an updated shasum from build due to version update in auto PR + path: | + ./packages/starknet-snap/package.json + ./packages/starknet-snap/dist + ./packages/starknet-snap/snap.manifest.json + ./node_modules/.yarn-state.yml + key: ${{ needs.prepare-deployment.outputs.CACHE_KEY }} + - name: Dry Run Publish + run: | + npm pack ./packages/starknet-snap --tag "$TAG" --access public + env: + TAG: ${{ needs.prepare-deployment.outputs.TAG }} + + publish-npm: + runs-on: ubuntu-latest + needs: + - publish-npm-dry-run + - prepare-deployment + steps: + - uses: actions/checkout@v3 + with: + ref: ${{ github.sha }} + - uses: actions/setup-node@v3 + with: + node-version: '20.x' + registry-url: 'https://registry.npmjs.org' + - name: Restore Cached Build + uses: actions/cache@v3 + id: restore-build + with: + # add /packages/snap/snap.manifest.json to include an updated shasum from build due to version update in auto PR + path: | + ./packages/get-starknet/dist/webpack + ./packages/wallet-ui/build + ./packages/starknet-snap/package.json + ./packages/starknet-snap/dist + ./packages/starknet-snap/snap.manifest.json + ./node_modules/.yarn-state.yml + key: ${{ needs.prepare-deployment.outputs.CACHE_KEY }} + - name: Run Publish + run: | + npm publish ./packages/starknet-snap --tag "$TAG" --access public + env: + NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} + TAG: ${{ needs.prepare-deployment.outputs.TAG }} \ No newline at end of file From 934c382ad524393233e1520f612c9aa0c6058133 Mon Sep 17 00:00:00 2001 From: Florin Dzeladini Date: Mon, 25 Nov 2024 10:07:19 +0100 Subject: [PATCH 2/5] chore: remove env and stagging --- .../workflows/deploy-wallet-get-starknet.yml | 41 ++++--------------- .github/workflows/publish-npm.yml | 41 ++++--------------- 2 files changed, 15 insertions(+), 67 deletions(-) diff --git a/.github/workflows/deploy-wallet-get-starknet.yml b/.github/workflows/deploy-wallet-get-starknet.yml index d93aef66..8e28c53f 100644 --- a/.github/workflows/deploy-wallet-get-starknet.yml +++ b/.github/workflows/deploy-wallet-get-starknet.yml @@ -2,14 +2,9 @@ name: Deploy Wallet-UI and Get-starknet on: workflow_dispatch: - inputs: - environment: - description: 'Environment to deploy' - type: environment - required: true jobs: prepare-deployment: - environment: ${{ inputs.environment }} + environment: production permissions: contents: write runs-on: ubuntu-latest @@ -27,40 +22,18 @@ jobs: BASE=$(node -p "require('./packages/starknet-snap/package.json').version") HASH=$(git rev-parse --short HEAD) DATE=$(date +%Y%m%d) - ENV=${{ inputs.environment }} + ENV=production { echo "AWS_CLOUDFRONT_DISTRIBUTIONS_ID=${{ vars.AWS_CLOUDFRONT_DISTRIBUTIONS_ID }}" echo "AWS_S3_GET_STARKNET_URL=${{ vars.AWS_S3_GET_STARKNET_URL }}" echo "AWS_S3_URL=${{ vars.AWS_S3_URL }}" echo "GET_STARKNET_PUBLIC_PATH=${{ vars.GET_STARKNET_PUBLIC_PATH }}" + echo "VERSION=${BASE}" + echo "TAG=latest" + echo "ENV=prod" + echo "LOG_LEVEL=0" } >> "$GITHUB_OUTPUT" - - if [[ $ENV == "dev" ]]; then - { - echo "VERSION=${BASE}-dev-${HASH}-${DATE}" - echo "TAG=dev" - echo "ENV=dev" - echo "LOG_LEVEL=6" - } >> "$GITHUB_OUTPUT" - elif [[ $ENV == "staging" ]]; then - { - echo "VERSION=${BASE}-staging" - echo "TAG=staging" - echo "ENV=staging" - echo "LOG_LEVEL=0" - } >> "$GITHUB_OUTPUT" - elif [[ $ENV == "production" ]]; then - { - echo "VERSION=${BASE}" - echo "TAG=latest" - echo "ENV=prod" - echo "LOG_LEVEL=0" - } >> "$GITHUB_OUTPUT" - else - echo "Invalid environment" - exit 1 - fi outputs: VERSION: ${{ steps.prepare_parameters.outputs.VERSION }} TAG: ${{ steps.prepare_parameters.outputs.TAG }} @@ -98,7 +71,7 @@ jobs: echo "Building Get Starknet with GET_STARKNET_PUBLIC_PATH=$GET_STARKNET_PUBLIC_PATH" - GET_STARKNET_PUBLIC_PATH=$GET_STARKNET_PUBLIC_PATH yarn workspace @consensys/get-starknet build + SNAP_VERSION="${VERSION}$" GET_STARKNET_PUBLIC_PATH=$GET_STARKNET_PUBLIC_PATH yarn workspace @consensys/get-starknet build env: SNAP_ENV: ${{ needs.prepare-deployment.outputs.ENV }} VERSION: ${{ needs.prepare-deployment.outputs.VERSION }} diff --git a/.github/workflows/publish-npm.yml b/.github/workflows/publish-npm.yml index 2167d01d..d6e8b6da 100644 --- a/.github/workflows/publish-npm.yml +++ b/.github/workflows/publish-npm.yml @@ -2,14 +2,9 @@ name: Publish NPM on: workflow_dispatch: - inputs: - environment: - description: 'Environment to deploy' - type: environment - required: true jobs: prepare-deployment: - environment: ${{ inputs.environment }} + environment: production permissions: contents: write runs-on: ubuntu-latest @@ -27,33 +22,13 @@ jobs: BASE=$(node -p "require('./packages/starknet-snap/package.json').version") HASH=$(git rev-parse --short HEAD) DATE=$(date +%Y%m%d) - ENV=${{ inputs.environment }} - - if [[ $ENV == "dev" ]]; then - { - echo "VERSION=${BASE}-dev-${HASH}-${DATE}" - echo "TAG=dev" - echo "ENV=dev" - echo "LOG_LEVEL=6" - } >> "$GITHUB_OUTPUT" - elif [[ $ENV == "staging" ]]; then - { - echo "VERSION=${BASE}-staging" - echo "TAG=staging" - echo "ENV=staging" - echo "LOG_LEVEL=0" - } >> "$GITHUB_OUTPUT" - elif [[ $ENV == "production" ]]; then - { - echo "VERSION=${BASE}" - echo "TAG=latest" - echo "ENV=prod" - echo "LOG_LEVEL=0" - } >> "$GITHUB_OUTPUT" - else - echo "Invalid environment" - exit 1 - fi + ENV=${{ inputs.environment }} + { + echo "VERSION=${BASE}" + echo "TAG=latest" + echo "ENV=prod" + echo "LOG_LEVEL=0" + } >> "$GITHUB_OUTPUT" outputs: VERSION: ${{ steps.prepare_parameters.outputs.VERSION }} TAG: ${{ steps.prepare_parameters.outputs.TAG }} From db579b699f08a6e459837d8928928478461bea4f Mon Sep 17 00:00:00 2001 From: Florin Dzeladini Date: Mon, 25 Nov 2024 10:31:07 +0100 Subject: [PATCH 3/5] chore: fix comments --- .github/workflows/deploy-wallet-get-starknet.yml | 12 ++---------- .github/workflows/publish-npm.yml | 14 ++++++++------ 2 files changed, 10 insertions(+), 16 deletions(-) diff --git a/.github/workflows/deploy-wallet-get-starknet.yml b/.github/workflows/deploy-wallet-get-starknet.yml index 8e28c53f..441ebf41 100644 --- a/.github/workflows/deploy-wallet-get-starknet.yml +++ b/.github/workflows/deploy-wallet-get-starknet.yml @@ -20,8 +20,6 @@ jobs: id: prepare_parameters run: | BASE=$(node -p "require('./packages/starknet-snap/package.json').version") - HASH=$(git rev-parse --short HEAD) - DATE=$(date +%Y%m%d) ENV=production { @@ -32,7 +30,6 @@ jobs: echo "VERSION=${BASE}" echo "TAG=latest" echo "ENV=prod" - echo "LOG_LEVEL=0" } >> "$GITHUB_OUTPUT" outputs: VERSION: ${{ steps.prepare_parameters.outputs.VERSION }} @@ -42,8 +39,7 @@ jobs: AWS_CLOUDFRONT_DISTRIBUTIONS_ID: ${{ steps.prepare_parameters.outputs.AWS_CLOUDFRONT_DISTRIBUTIONS_ID }} AWS_S3_URL: ${{ steps.prepare_parameters.outputs.AWS_S3_URL }} GET_STARKNET_PUBLIC_PATH: ${{ steps.prepare_parameters.outputs.GET_STARKNET_PUBLIC_PATH }} - CACHE_KEY: ${{ github.sha }}-${{ steps.prepare_parameters.outputs.ENV }} - LOG_LEVEL: ${{ steps.prepare_parameters.outputs.LOG_LEVEL }} + CACHE_KEY: ${{ github.sha }}-${{ steps.prepare_parameters.outputs.ENV }}-UI_N_GET_STARKNET install-build: needs: @@ -73,12 +69,8 @@ jobs: SNAP_VERSION="${VERSION}$" GET_STARKNET_PUBLIC_PATH=$GET_STARKNET_PUBLIC_PATH yarn workspace @consensys/get-starknet build env: - SNAP_ENV: ${{ needs.prepare-deployment.outputs.ENV }} VERSION: ${{ needs.prepare-deployment.outputs.VERSION }} - VOYAGER_API_KEY: ${{ secrets.VOYAGER_API_KEY }} - ALCHEMY_API_KEY: ${{ secrets.ALCHEMY_API_KEY }} GET_STARKNET_PUBLIC_PATH: ${{ needs.prepare-deployment.outputs.GET_STARKNET_PUBLIC_PATH }} - LOG_LEVEL: ${{ needs.prepare-deployment.outputs.LOG_LEVEL }} - name: Cache Build uses: actions/cache@v3 id: cache @@ -178,4 +170,4 @@ jobs: echo "Invalidation $INVALIDED_ID completed" done env: - AWS_CLOUDFRONT_DISTRIBUTIONS_ID: ${{ needs.prepare-deployment.outputs.AWS_CLOUDFRONT_DISTRIBUTIONS_ID }} \ No newline at end of file + AWS_CLOUDFRONT_DISTRIBUTIONS_ID: ${{ needs.prepare-deployment.outputs.AWS_CLOUDFRONT_DISTRIBUTIONS_ID }} diff --git a/.github/workflows/publish-npm.yml b/.github/workflows/publish-npm.yml index d6e8b6da..ca5c02a5 100644 --- a/.github/workflows/publish-npm.yml +++ b/.github/workflows/publish-npm.yml @@ -20,20 +20,20 @@ jobs: id: prepare_parameters run: | BASE=$(node -p "require('./packages/starknet-snap/package.json').version") - HASH=$(git rev-parse --short HEAD) - DATE=$(date +%Y%m%d) - ENV=${{ inputs.environment }} + ENV=production + { echo "VERSION=${BASE}" echo "TAG=latest" echo "ENV=prod" echo "LOG_LEVEL=0" - } >> "$GITHUB_OUTPUT" + } >> "$GITHUB_OUTPUT" + outputs: VERSION: ${{ steps.prepare_parameters.outputs.VERSION }} TAG: ${{ steps.prepare_parameters.outputs.TAG }} ENV: ${{ steps.prepare_parameters.outputs.ENV }} - CACHE_KEY: ${{ github.sha }}-${{ steps.prepare_parameters.outputs.ENV }}-npm + CACHE_KEY: ${{ github.sha }}-${{ steps.prepare_parameters.outputs.ENV }}-SANP LOG_LEVEL: ${{ steps.prepare_parameters.outputs.LOG_LEVEL }} install-build: @@ -72,6 +72,8 @@ jobs: SNAP_ENV: ${{ needs.prepare-deployment.outputs.ENV }} VERSION: ${{ needs.prepare-deployment.outputs.VERSION }} LOG_LEVEL: ${{ needs.prepare-deployment.outputs.LOG_LEVEL }} + VOYAGER_API_KEY: ${{ secrets.VOYAGER_API_KEY }} + ALCHEMY_API_KEY: ${{ secrets.ALCHEMY_API_KEY }} - name: Cache Build uses: actions/cache@v3 id: cache @@ -144,4 +146,4 @@ jobs: npm publish ./packages/starknet-snap --tag "$TAG" --access public env: NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} - TAG: ${{ needs.prepare-deployment.outputs.TAG }} \ No newline at end of file + TAG: ${{ needs.prepare-deployment.outputs.TAG }} From 60fd7ed6144627b1d7486e2e54811ce049974084 Mon Sep 17 00:00:00 2001 From: Florin Dzeladini Date: Mon, 25 Nov 2024 11:40:30 +0100 Subject: [PATCH 4/5] chore: fix workflow restore-build from cache paths --- .github/workflows/deploy-wallet-get-starknet.yml | 3 --- .github/workflows/publish-npm.yml | 2 -- 2 files changed, 5 deletions(-) diff --git a/.github/workflows/deploy-wallet-get-starknet.yml b/.github/workflows/deploy-wallet-get-starknet.yml index 441ebf41..9ae20fcc 100644 --- a/.github/workflows/deploy-wallet-get-starknet.yml +++ b/.github/workflows/deploy-wallet-get-starknet.yml @@ -102,9 +102,6 @@ jobs: path: | ./packages/get-starknet/dist/webpack ./packages/wallet-ui/build - ./packages/starknet-snap/package.json - ./packages/starknet-snap/dist - ./packages/starknet-snap/snap.manifest.json ./node_modules/.yarn-state.yml key: ${{ needs.prepare-deployment.outputs.CACHE_KEY }} - name: Deploy to AWS diff --git a/.github/workflows/publish-npm.yml b/.github/workflows/publish-npm.yml index ca5c02a5..0699ccb2 100644 --- a/.github/workflows/publish-npm.yml +++ b/.github/workflows/publish-npm.yml @@ -134,8 +134,6 @@ jobs: with: # add /packages/snap/snap.manifest.json to include an updated shasum from build due to version update in auto PR path: | - ./packages/get-starknet/dist/webpack - ./packages/wallet-ui/build ./packages/starknet-snap/package.json ./packages/starknet-snap/dist ./packages/starknet-snap/snap.manifest.json From 70d5841d7adce7368e4f41066e9fcfc513b4bed0 Mon Sep 17 00:00:00 2001 From: Florin Dzeladini Date: Mon, 25 Nov 2024 16:03:11 +0100 Subject: [PATCH 5/5] chore: remove deploy for now --- .../workflows/deploy-wallet-get-starknet.yml | 90 +------------------ .github/workflows/publish-npm.yml | 33 +------ 2 files changed, 2 insertions(+), 121 deletions(-) diff --git a/.github/workflows/deploy-wallet-get-starknet.yml b/.github/workflows/deploy-wallet-get-starknet.yml index 9ae20fcc..7300d2b4 100644 --- a/.github/workflows/deploy-wallet-get-starknet.yml +++ b/.github/workflows/deploy-wallet-get-starknet.yml @@ -79,92 +79,4 @@ jobs: ./packages/get-starknet/dist/webpack ./packages/wallet-ui/build ./node_modules/.yarn-state.yml - key: ${{ needs.prepare-deployment.outputs.CACHE_KEY }} - - deploy-wallet-ui: - runs-on: ubuntu-latest - needs: - - prepare-deployment - steps: - - name: Configure AWS credentials - uses: aws-actions/configure-aws-credentials@v1 - with: - aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} - aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} - aws-region: eu-central-1 - - uses: actions/checkout@v3 - with: - ref: ${{ github.sha }} - - name: Restore Cached Build - uses: actions/cache@v3 - id: restore-build - with: - path: | - ./packages/get-starknet/dist/webpack - ./packages/wallet-ui/build - ./node_modules/.yarn-state.yml - key: ${{ needs.prepare-deployment.outputs.CACHE_KEY }} - - name: Deploy to AWS - run: | - echo "Deployed Dapp to : $AWS_S3_URL" - aws s3 sync ./packages/wallet-ui/build "$AWS_S3_URL" - env: - AWS_S3_URL: ${{ needs.prepare-deployment.outputs.AWS_S3_URL }} - - deploy-get-starknet: - runs-on: ubuntu-latest - needs: - - prepare-deployment - - install-build - steps: - - name: Configure AWS credentials - uses: aws-actions/configure-aws-credentials@v1 - with: - aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} - aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} - aws-region: eu-central-1 - - uses: actions/checkout@v3 - with: - ref: ${{ github.sha }} - - name: Restore Cached Build - uses: actions/cache@v3 - id: restore-build - with: - path: | - ./packages/get-starknet/dist/webpack - ./packages/wallet-ui/build - ./node_modules/.yarn-state.yml - key: ${{ needs.prepare-deployment.outputs.CACHE_KEY }} - - name: Deploy to AWS - run: | - echo "Deployed get Starknet to : $AWS_S3_GET_STARKNET_URL" - aws s3 sync ./packages/get-starknet/dist/webpack "$AWS_S3_GET_STARKNET_URL" - env: - AWS_S3_GET_STARKNET_URL: ${{ needs.prepare-deployment.outputs.AWS_S3_GET_STARKNET_URL }} - - invalid-aws-cdn-cache: - runs-on: ubuntu-latest - needs: - - deploy-wallet-ui - - deploy-get-starknet - - prepare-deployment - steps: - - name: Configure AWS credentials - uses: aws-actions/configure-aws-credentials@v1 - with: - aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} - aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} - aws-region: eu-central-1 - - name: Invalid AWS CDN Cache - run: | - echo "Distribution ID : $AWS_CLOUDFRONT_DISTRIBUTIONS_ID" - echo "$AWS_CLOUDFRONT_DISTRIBUTIONS_ID" | tr ',' '\n' | while read -r DISTRIBUTIONS_ID - do - echo "Processing Distribution ID : $DISTRIBUTIONS_ID" - INVALIDED_ID="$(aws cloudfront create-invalidation --distribution-id "$DISTRIBUTIONS_ID" --paths "/starknet/*" | grep Id | awk -F'"' '{ print $4}')" - echo "Waiting for invalidation $INVALIDED_ID" - aws cloudfront wait invalidation-completed --id "$INVALIDED_ID" --distribution-id "$DISTRIBUTIONS_ID" - echo "Invalidation $INVALIDED_ID completed" - done - env: - AWS_CLOUDFRONT_DISTRIBUTIONS_ID: ${{ needs.prepare-deployment.outputs.AWS_CLOUDFRONT_DISTRIBUTIONS_ID }} + key: ${{ needs.prepare-deployment.outputs.CACHE_KEY }} \ No newline at end of file diff --git a/.github/workflows/publish-npm.yml b/.github/workflows/publish-npm.yml index 0699ccb2..e58a152b 100644 --- a/.github/workflows/publish-npm.yml +++ b/.github/workflows/publish-npm.yml @@ -113,35 +113,4 @@ jobs: run: | npm pack ./packages/starknet-snap --tag "$TAG" --access public env: - TAG: ${{ needs.prepare-deployment.outputs.TAG }} - - publish-npm: - runs-on: ubuntu-latest - needs: - - publish-npm-dry-run - - prepare-deployment - steps: - - uses: actions/checkout@v3 - with: - ref: ${{ github.sha }} - - uses: actions/setup-node@v3 - with: - node-version: '20.x' - registry-url: 'https://registry.npmjs.org' - - name: Restore Cached Build - uses: actions/cache@v3 - id: restore-build - with: - # add /packages/snap/snap.manifest.json to include an updated shasum from build due to version update in auto PR - path: | - ./packages/starknet-snap/package.json - ./packages/starknet-snap/dist - ./packages/starknet-snap/snap.manifest.json - ./node_modules/.yarn-state.yml - key: ${{ needs.prepare-deployment.outputs.CACHE_KEY }} - - name: Run Publish - run: | - npm publish ./packages/starknet-snap --tag "$TAG" --access public - env: - NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} - TAG: ${{ needs.prepare-deployment.outputs.TAG }} + TAG: ${{ needs.prepare-deployment.outputs.TAG }} \ No newline at end of file