Skip to content

feat: save data in session storage #15

feat: save data in session storage

feat: save data in session storage #15

name: Deploy Package
on:
push:
branches:
- main
paths:
- "packages/msw-dev-tool/**"
- ".github/workflows/deploy-package.yml"
- "package.json"
- "pnpm-lock.yaml"
jobs:
release:
permissions:
contents: write
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Set up Node.js
uses: actions/setup-node@v3
with:
node-version: "20"
- name: Set up pnpm
uses: pnpm/action-setup@v2
with:
version: 9.10.0
- name: Config identity
run: |
git config --global user.email "${{ secrets.ADMIN_EMAIL }}"
git config --global user.name "${{ secrets.ADMIN_NAME }}"
- name: Install dependencies
working-directory: packages/msw-dev-tool
run: pnpm install
- name: Build
working-directory: packages/msw-dev-tool
run: npm run build
- name: Get NPM package version
id: get_version
working-directory: packages/msw-dev-tool
run: |
PACKAGE_NAME="msw-dev-tool"
VERSION=$(npm view $PACKAGE_NAME version)
echo "npm_version=$VERSION" >> $GITHUB_ENV
- name: Compare and Update package.json version
working-directory: packages/msw-dev-tool
run: |
CURRENT_VERSION=$(cat package.json | jq -r '.version')
REGISTRY_VERSION=${{ env.npm_version }}
# Compare version
function version_gt() {
test "$(printf '%s\n' "$1" "$2" | sort -V | head -n 1)" != "$1"
}
if version_gt "$CURRENT_VERSION" "$NPM_VERSION"; then
echo "Local version: ($CURRENT_VERSION) is higher then registry version: ($NPM_VERSION). Maintain local version."
elif [ "$CURRENT_VERSION" != "$NPM_VERSION" ]; then
echo "Registry version: ($NPM_VERSION) is higher then ($CURRENT_VERSION). Update local version."
npm version $NPM_VERSION --no-git-tag-version
else
echo "Versions are the same, no need to update."
fi
- name: Clean working tree
working-directory: packages/msw-dev-tool
run: |
if [ -z "$(git status --porcelain)" ]; then
echo "Working tree is clean. Skipping git add and commit."
else
git add .
git commit -m "fix: clean working tree"
fi
- name: Bump version and create new tag
working-directory: packages/msw-dev-tool
run: |
npm version patch -m "chore(release): bump version to %s"
- name: Create .npmrc file
working-directory: packages/msw-dev-tool
run: |
echo "//registry.npmjs.org/:_authToken=${{ secrets.NPM_TOKEN }}" > ~/.npmrc
- name: Publish to npm
working-directory: packages/msw-dev-tool
run: npm publish