-
Notifications
You must be signed in to change notification settings - Fork 27
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: two steps CI CD deployment (#434)
* chore: two steps CI/CD deployment * chore: remove env and stagging * chore: fix comments * chore: fix workflow restore-build from cache paths * chore: remove deploy for now
- Loading branch information
Showing
2 changed files
with
198 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
name: Deploy Wallet-UI and Get-starknet | ||
|
||
on: | ||
workflow_dispatch: | ||
jobs: | ||
prepare-deployment: | ||
environment: production | ||
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") | ||
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" | ||
} >> "$GITHUB_OUTPUT" | ||
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 }}-UI_N_GET_STARKNET | ||
|
||
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" | ||
SNAP_VERSION="${VERSION}$" GET_STARKNET_PUBLIC_PATH=$GET_STARKNET_PUBLIC_PATH yarn workspace @consensys/get-starknet build | ||
env: | ||
VERSION: ${{ needs.prepare-deployment.outputs.VERSION }} | ||
GET_STARKNET_PUBLIC_PATH: ${{ needs.prepare-deployment.outputs.GET_STARKNET_PUBLIC_PATH }} | ||
- 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 }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,116 @@ | ||
name: Publish NPM | ||
|
||
on: | ||
workflow_dispatch: | ||
jobs: | ||
prepare-deployment: | ||
environment: production | ||
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") | ||
ENV=production | ||
{ | ||
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 }} | ||
ENV: ${{ steps.prepare_parameters.outputs.ENV }} | ||
CACHE_KEY: ${{ github.sha }}-${{ steps.prepare_parameters.outputs.ENV }}-SANP | ||
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 }} | ||
VOYAGER_API_KEY: ${{ secrets.VOYAGER_API_KEY }} | ||
ALCHEMY_API_KEY: ${{ secrets.ALCHEMY_API_KEY }} | ||
- 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 }} |