Feat/add aave #131
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
name: Create SDK Snapshot | |
on: | |
pull_request: | |
branches: ['master'] | |
workflow_dispatch: | |
jobs: | |
release: | |
runs-on: ubuntu-latest | |
permissions: | |
contents: write | |
pull-requests: write | |
steps: | |
- name: π€ Checkout | |
uses: actions/checkout@v4 | |
- name: βοΈ Setup Node.js | |
uses: actions/setup-node@v4 | |
with: | |
node-version: 20.x | |
cache: 'npm' | |
- name: π Authenticate with NPM | |
run: echo "//registry.npmjs.org/:_authToken=${{ secrets.NPM_TOKEN }}" > ~/.npmrc | |
- name: 𧩠Install dependencies | |
run: npm ci --ignore-scripts | |
- name: ποΈ Bump version | |
run: npm run changeset:snapshot -- --pr $PR --sha $COMMIT_SHA --output release-plan.json | |
env: | |
PR: ${{ github.event.pull_request.number }} | |
COMMIT_SHA: ${{ github.event.pull_request.head.sha }} | |
- name: π οΈ Build SDK | |
run: npm run build | |
- name: π Publish snapshot | |
run: npm run changeset -- publish --no-git-tag --snapshot --tag beta | |
- name: β Verify release plan | |
id: verify | |
run: | | |
cat release-plan.json | |
if [ $(jq '.releases | length' release-plan.json) -eq 0 ]; then | |
printf "\nNo new releases available :(" | |
else | |
echo "upgrade_ui_deps=yes" >> $GITHUB_OUTPUT | |
fi | |
- name: β¬οΈ Upload release plan | |
uses: actions/upload-artifact@v4 | |
with: | |
name: release-plan | |
path: release-plan.json | |
outputs: | |
upgrade_ui_deps: ${{ steps.verify.outputs.upgrade_ui_deps }} | |
upgrade-ui-deps: | |
needs: | |
- release | |
if: needs.release.outputs.upgrade_ui_deps == 'yes' | |
runs-on: ubuntu-latest | |
permissions: | |
contents: write | |
pull-requests: write | |
steps: | |
- name: β¬οΈ Download release plan | |
uses: actions/download-artifact@v4 | |
with: | |
name: release-plan | |
- name: π€ Checkout hydration-ui repository | |
uses: actions/checkout@v4 | |
with: | |
repository: 'galacticcouncil/hydration-ui' | |
token: ${{ secrets.TARGET_REPO_PAT }} | |
path: 'hydration-ui' | |
- name: βοΈ Setup Node.js | |
uses: actions/setup-node@v4 | |
with: | |
node-version: 20.x | |
- name: π§ Upgrade hydration-ui sdk packages | |
run: | | |
cd hydration-ui | |
jq -c '.releases[]' ../release-plan.json | while read i; do | |
package_name=$(jq --raw-output '.name' <<< "$i") | |
package_version=$(jq --raw-output '.newVersion' <<< "$i") | |
echo Installing $package_name@$package_version | |
yarn add $package_name@$package_version | |
done | |
git config user.name "GitHub Action" | |
git config user.email "[email protected]" | |
git add package.json yarn.lock | |
git commit -m "$(jq '.releaseMessage' ../release-plan.json)" | |
- name: π§ Open hydration-ui PR with sdk upgrade | |
id: cpr | |
uses: peter-evans/create-pull-request@v7 | |
with: | |
token: ${{ secrets.TARGET_REPO_PAT }} | |
title: 'π§ SDK Preview: [${{ env.PR_TITLE }}]' | |
body: | | |
This PR was triggered by SDK upgrade no. ${{ env.PR }} | |
For details visit: https://github.com/galacticcouncil/sdk/pull/${{ env.PR }} | |
![Alt Text](https://media.tenor.com/DNCBqbguizsAAAAM/magic.gif) | |
branch: upgrade-sdk-pr${{ env.PR }} | |
base: master | |
path: 'hydration-ui' | |
draft: true | |
env: | |
PR: ${{ github.event.pull_request.number }} | |
PR_TITLE: ${{ github.event.pull_request.title }} | |
- name: π§ Print hydration-ui PR details | |
if: ${{ steps.cpr.outputs.pull-request-number }} | |
run: | | |
echo "Pull Request Number - ${{ steps.cpr.outputs.pull-request-number }}" | |
echo "Pull Request URL - ${{ steps.cpr.outputs.pull-request-url }}" | |
echo "Pull Request Action - ${{ steps.cpr.outputs.pull-request-operation }}" | |
- name: π§ Update sdk PR with live preview link | |
if: ${{ steps.cpr.outputs.pull-request-operation == 'created' }} | |
uses: actions/github-script@v7 | |
with: | |
script: | | |
github.rest.issues.createComment({ | |
issue_number: context.issue.number, | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
body: 'π§ Live preview: ${{ steps.cpr.outputs.pull-request-url }}' | |
}) |