Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update package.json #81

Closed
wants to merge 36 commits into from
Closed
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
43 changes: 27 additions & 16 deletions .github/workflows/snapshot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,74 +16,85 @@ jobs:
steps:
- name: 🤘 Checkout
uses: actions/checkout@v4
with:
path: sdk

- 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
run: |
echo "//registry.npmjs.org/:_authToken=${{ secrets.NPM_TOKEN }}" > ~/.npmrc
working-directory: sdk

- name: 🧩 Install dependencies
run: npm ci --ignore-scripts
working-directory: sdk

- name: 🖊️ Bump version
run: npm run changeset:snapshot -- --pr $PR --sha $COMMIT_SHA
working-directory: sdk
env:
PR: ${{ github.event.pull_request.number }}
COMMIT_SHA: ${{ github.event.pull_request.head.sha }}

- name: 🛠️ Build SDK
run: npm run build
working-directory: sdk

- name: 🚀 Publish snapshot
run: npm run changeset -- publish --no-git-tag --snapshot --tag beta
working-directory: sdk

- name: Check for package updates
id: check-updates
run: |
PACKAGE_NAME="@galacticcouncil/sdk"
CURRENT_VERSION=$(npm list $PACKAGE_NAME | grep $PACKAGE_NAME | cut -d@ -f2)
LATEST_VERSION=$(npm view $PACKAGE_NAME version)
CURRENT_VERSION="$(grep $PACKAGE_NAME package.json | cut -d '"' -f4)"
LATEST_VERSION="$(npm view $PACKAGE_NAME versions --json | jq -r '.[-1]')"
echo "PACKAGE_NAME: $PACKAGE_NAME"
echo "Current version: $CURRENT_VERSION"
echo "Latest version: $LATEST_VERSION"
if [ "$CURRENT_VERSION" != "$LATEST_VERSION" ]; then
echo "UPDATE_AVAILABLE=true" >> $GITHUB_ENV
echo "NEW_VERSION=$LATEST_VERSION" >> $GITHUB_ENV
echo "PACKAGE_NAME=$PACKAGE_NAME" >> $GITHUB_ENV
fi
working-directory: sdk

- name: Checkout hydration-ui repository
if: env.UPDATE_AVAILABLE == 'true'
uses: actions/checkout@v2
uses: actions/checkout@v4
with:
path: hydration-ui
repository: 'galacticcouncil/hydration-ui'
token: ${{ secrets.TARGET_REPO_PAT }}
path: 'hydration-ui'

- name: Update package.json in target repository
if: env.UPDATE_AVAILABLE == 'true'
run: |
cd hydration-ui
npm install ${{ env.PACKAGE_NAME }}@${{ env.NEW_VERSION }}
git config user.name "GitHub Action"
git config user.email "[email protected]"
git add package.json package-lock.json
cat package.json | grep @galacticcouncil
yarn add ${{ env.PACKAGE_NAME }}@${{ env.NEW_VERSION }}
cat package.json | grep @galacticcouncil
git config --global user.email "sdk@galacticcouncil"
git config --global user.name "SDK Action"
git add package.json
git commit -m "Update ${{ env.PACKAGE_NAME }} to version ${{ env.NEW_VERSION }}"
working-directory: hydration-ui

- name: Create Pull Request in target repository
if: env.UPDATE_AVAILABLE == 'true'
uses: peter-evans/create-pull-request@v7
with:
token: ${{ secrets.TARGET_REPO_PAT }}
commit-message: "Update ${{ env.PACKAGE_NAME }} to version ${{ env.NEW_VERSION }}"
title: "Update ${{ env.PACKAGE_NAME }} to version ${{ env.NEW_VERSION }}"
commit-message: 'Update ${{ env.PACKAGE_NAME }} to version ${{ env.NEW_VERSION }}'
title: 'Update ${{ env.PACKAGE_NAME }} to version ${{ env.NEW_VERSION }}'
body: |
This PR updates ${{ env.PACKAGE_NAME }} to the latest version ${{ env.NEW_VERSION }}.

Current version: ${{ env.CURRENT_VERSION }}
New version: ${{ env.NEW_VERSION }}
branch: update-sdk-${{ env.NEW_VERSION }}
base: main
base: master
path: 'hydration-ui'
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
"changeset": "changeset",
"changeset:version": "node ./scripts/changeset-version.mjs",
"changeset:snapshot": "node ./scripts/changeset-snapshot.mjs",
"prerelease": "npm run build",
"prerelease": "changeset",
"release": "changeset publish",
"postrelease": "bash ./scripts/changeset-push.sh"
},
Expand Down