From e0e6e92fde1889f78d2fde49ab1dfbcc7934649a Mon Sep 17 00:00:00 2001 From: Vrunda Kansara Date: Wed, 2 Oct 2024 12:45:57 +0530 Subject: [PATCH 1/5] Testing commit --- src/components/sidebar/sidebar.stories.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/sidebar/sidebar.stories.js b/src/components/sidebar/sidebar.stories.js index 982adec4..5961b5c4 100644 --- a/src/components/sidebar/sidebar.stories.js +++ b/src/components/sidebar/sidebar.stories.js @@ -183,4 +183,4 @@ DefaultSidebar.args = { collapsible: true, }; -DefaultSidebar.storyName = 'Sidebar'; +DefaultSidebar.storyName = 'Sidebar'; \ No newline at end of file From d92384f3acdcc9d4c8f9dab4bdcfa34a49dd9155 Mon Sep 17 00:00:00 2001 From: Vrunda Kansara Date: Wed, 2 Oct 2024 12:47:14 +0530 Subject: [PATCH 2/5] Fixed storybook build issue --- .github/workflows/chromatic.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/chromatic.yml b/.github/workflows/chromatic.yml index ef46c069..3f3c9da7 100644 --- a/.github/workflows/chromatic.yml +++ b/.github/workflows/chromatic.yml @@ -19,7 +19,7 @@ jobs: node-version: 20 - name: Install dependencies # ⚠️ See your package manager's documentation for the correct command to install dependencies in a CI environment. - run: npm install + run: npm install && npm run build - name: Run Chromatic uses: chromaui/action@latest with: From ec86f904120ce9be8fdb52ae4479fe6ed0a01ab5 Mon Sep 17 00:00:00 2001 From: Vrunda Kansara Date: Wed, 2 Oct 2024 15:12:06 +0530 Subject: [PATCH 3/5] Deployment changes --- .github/workflows/tag-release.yml | 54 +++++++++++++++++ .gitignore | 3 +- bin/build.sh | 12 ++++ bin/release.sh | 99 +++++++++++++++++++++++++++++++ changelog.txt | 8 +++ package.json | 6 +- version.json | 3 + 7 files changed, 182 insertions(+), 3 deletions(-) create mode 100644 .github/workflows/tag-release.yml create mode 100644 bin/build.sh create mode 100644 bin/release.sh create mode 100644 changelog.txt create mode 100644 version.json diff --git a/.github/workflows/tag-release.yml b/.github/workflows/tag-release.yml new file mode 100644 index 00000000..7edb6909 --- /dev/null +++ b/.github/workflows/tag-release.yml @@ -0,0 +1,54 @@ +name: Create a tag + +on: + push: + branches: + - master + +# Cancels all previous workflow runs for pull requests that have not completed. +concurrency: + # The concurrency group contains the workflow name and the branch name for pull requests + # or the commit hash for any other events. + group: ${{ github.workflow }}-${{ github.event_name == 'pull_request' && github.head_ref || github.sha }} + cancel-in-progress: true + +jobs: + build: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Setup PHP + uses: shivammathur/setup-php@v2 + with: + php-version: 8.1 + coverage: none + tools: composer, cs2pr + + - name: Use desired version of NodeJS + uses: actions/setup-node@v4 + with: + node-version: 18.15 + cache: 'npm' + + - name: Composer Install + uses: ramsey/composer-install@v3 + + - name: Build the release + run: npm install && npm run release + + - name: Maybe create a tag + run: bash bin/release.sh + + - name: Release + if: ${{ env.TAG_CREATED == 'true' }} + uses: softprops/action-gh-release@v2 + with: + tag_name: ${{ env.BRAINSTORM_FORCE_RELEASE }} + body: '' + name: v${{ env.BRAINSTORM_FORCE_RELEASE }} + draft: false + files: force-ui.zip + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.gitignore b/.gitignore index 44a94ec0..50e262bb 100644 --- a/.gitignore +++ b/.gitignore @@ -2,4 +2,5 @@ node_modules dist/* .DS_Store *storybook.log -storybook-static/* \ No newline at end of file +storybook-static/* +*.zip \ No newline at end of file diff --git a/bin/build.sh b/bin/build.sh new file mode 100644 index 00000000..baa49209 --- /dev/null +++ b/bin/build.sh @@ -0,0 +1,12 @@ +#!/bin/bash + +echo "💃 Time to build the force-ui plugin ZIP file 🕺" + +echo "Creating archive... 🎁" + +zip -r force-ui.zip \ + dist \ + version.json \ + changelog.txt + +echo "Done. You've built force-ui! 🎉 " \ No newline at end of file diff --git a/bin/release.sh b/bin/release.sh new file mode 100644 index 00000000..1d20fea3 --- /dev/null +++ b/bin/release.sh @@ -0,0 +1,99 @@ +#!/bin/bash -e +# +# Deploy your branch. +# + +DEPLOY_SUFFIX="${DEPLOY_SUFFIX:--built}" +GIT_USER="${DEPLOY_GIT_USER:-GitHub Actions}" +GIT_EMAIL="${DEPLOY_GIT_EMAIL:-hello@bsf.io}" + +BRANCH="${GITHUB_REF:-master}" +SRC_DIR="$PWD" +BUILD_DIR="/tmp/brainstormforce-build" + +if [[ -d "$BUILD_DIR" ]]; then + echo "WARNING: ${BUILD_DIR} already exists. You may have accidentally cached this" + echo "directory. This will cause issues with deploying." + exit 1 +fi + +COMMIT=$(git rev-parse HEAD) +VERSION=$(grep 'Version: ' $PWD/ai-builder.php | grep -oEi '[0-9\.a-z\+-]+$') + +# Check if the tag exists in the remote GitHub repository. +TAG_EXISTS=$(git ls-remote --tags origin | grep -c "refs/tags/$VERSION") + +# If tag is already found, exit by setting env variables. +# exit 0 to exit with a success. +if [ $TAG_EXISTS != 0 ]; then + echo "BRAINSTORM_FORCE_RELEASE=$VERSION" >>$GITHUB_ENV + echo "TAG_CREATED=false" >>$GITHUB_ENV + exit 0 +fi + +if [[ $VERSION != "null" ]]; then + DEPLOY_BRANCH="release/${VERSION}" + DEPLOY_AS_RELEASE="${DEPLOY_AS_RELEASE:-yes}" +else + DEPLOY_BRANCH="${BRANCH}${DEPLOY_SUFFIX}" + DEPLOY_AS_RELEASE="${DEPLOY_AS_RELEASE:-no}" +fi + +echo "Deploying $BRANCH to $DEPLOY_BRANCH" + +# If the deploy branch doesn't already exist, create it from the empty root. +if ! git rev-parse --verify "remotes/origin/$DEPLOY_BRANCH" >/dev/null 2>&1; then + echo -e "\nCreating $DEPLOY_BRANCH..." + git worktree add --detach "$BUILD_DIR" + cd "$BUILD_DIR" + git checkout --orphan "$DEPLOY_BRANCH" +else + echo "Using existing $DEPLOY_BRANCH" + git worktree add --detach "$BUILD_DIR" "remotes/origin/$DEPLOY_BRANCH" + cd "$BUILD_DIR" + git checkout "$DEPLOY_BRANCH" +fi + +# Ensure we're in the right dir +cd "$BUILD_DIR" + +# Remove existing files +git rm -rfq . + +# Sync built files +echo -e "\nSyncing files..." + +rsync -av "$SRC_DIR/" "$BUILD_DIR" --exclude-from "$SRC_DIR/.distignore" + +# Add changed files +git add . + +if [ -z "$(git status --porcelain)" ]; then + echo "No changes to built files." + exit +fi + +# Print status! +echo -e "\nSynced files. Changed:" +git status -s + +# Double-check our user/email config +if ! git config user.email; then + git config user.name "$GIT_USER" + git config user.email "$GIT_EMAIL" +fi + +# Commit it. +MESSAGE=$(printf 'Build changes from %s\n\n%s' "${COMMIT}" "${CIRCLE_BUILD_URL}") +git commit -m "$MESSAGE" + +# Push it (real good). +git push origin "$DEPLOY_BRANCH" + +# Make a release if one doesn't exist. +if [[ $DEPLOY_AS_RELEASE = "yes" && $(git tag -l "$VERSION") != $VERSION ]]; then + git tag "$VERSION" + git push origin "$VERSION" + echo "BRAINSTORM_FORCE_RELEASE=$VERSION" >>$GITHUB_ENV + echo "TAG_CREATED=true" >>$GITHUB_ENV +fi diff --git a/changelog.txt b/changelog.txt new file mode 100644 index 00000000..98f2edaa --- /dev/null +++ b/changelog.txt @@ -0,0 +1,8 @@ +Version 0.0.3 - 2nd October, 2024 +- New - Breadcrumb +- New - Grid Container +- New - Dialog Component +- New - Drawer Component +- New - Menu & Menu Item Component +- New - Sidebar +- New - Topbar \ No newline at end of file diff --git a/package.json b/package.json index 78b1cbd6..1274f574 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@bsf/force-ui", - "version": "0.0.2", + "version": "0.0.3", "description": "Library of components for the BSF project", "main": "dist/force-ui.js", "scripts": { @@ -16,7 +16,9 @@ "lint:css-fix": "wp-scripts lint-style ./src/**/*.{scss,css} --fix", "storybook": "storybook dev -p 6006", "build-storybook": "storybook build", - "chromatic": "npx chromatic --project-token CHROMATIC_PROJECT_TOKEN" + "chromatic": "npx chromatic --project-token CHROMATIC_PROJECT_TOKEN", + "package": "sh bin/build.sh", + "release": "npm run build && npm run package " }, "repository": { "type": "git", diff --git a/version.json b/version.json new file mode 100644 index 00000000..92a052d3 --- /dev/null +++ b/version.json @@ -0,0 +1,3 @@ +{ + "force-ui": "0.0.3" +} From 4898fcd6357530aaf9fa010f868add513028306c Mon Sep 17 00:00:00 2001 From: Vrunda Kansara Date: Wed, 2 Oct 2024 15:12:41 +0530 Subject: [PATCH 4/5] Build and lint --- .github/workflows/tag-release.yml | 84 +++++++++++------------ src/components/sidebar/sidebar.stories.js | 2 +- 2 files changed, 43 insertions(+), 43 deletions(-) diff --git a/.github/workflows/tag-release.yml b/.github/workflows/tag-release.yml index 7edb6909..8930a2f0 100644 --- a/.github/workflows/tag-release.yml +++ b/.github/workflows/tag-release.yml @@ -1,9 +1,9 @@ name: Create a tag on: - push: - branches: - - master + push: + branches: + - master # Cancels all previous workflow runs for pull requests that have not completed. concurrency: @@ -13,42 +13,42 @@ concurrency: cancel-in-progress: true jobs: - build: - runs-on: ubuntu-latest - steps: - - name: Checkout - uses: actions/checkout@v4 - - - name: Setup PHP - uses: shivammathur/setup-php@v2 - with: - php-version: 8.1 - coverage: none - tools: composer, cs2pr - - - name: Use desired version of NodeJS - uses: actions/setup-node@v4 - with: - node-version: 18.15 - cache: 'npm' - - - name: Composer Install - uses: ramsey/composer-install@v3 - - - name: Build the release - run: npm install && npm run release - - - name: Maybe create a tag - run: bash bin/release.sh - - - name: Release - if: ${{ env.TAG_CREATED == 'true' }} - uses: softprops/action-gh-release@v2 - with: - tag_name: ${{ env.BRAINSTORM_FORCE_RELEASE }} - body: '' - name: v${{ env.BRAINSTORM_FORCE_RELEASE }} - draft: false - files: force-ui.zip - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + build: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Setup PHP + uses: shivammathur/setup-php@v2 + with: + php-version: 8.1 + coverage: none + tools: composer, cs2pr + + - name: Use desired version of NodeJS + uses: actions/setup-node@v4 + with: + node-version: 18.15 + cache: 'npm' + + - name: Composer Install + uses: ramsey/composer-install@v3 + + - name: Build the release + run: npm install && npm run release + + - name: Maybe create a tag + run: bash bin/release.sh + + - name: Release + if: ${{ env.TAG_CREATED == 'true' }} + uses: softprops/action-gh-release@v2 + with: + tag_name: ${{ env.BRAINSTORM_FORCE_RELEASE }} + body: '' + name: v${{ env.BRAINSTORM_FORCE_RELEASE }} + draft: false + files: force-ui.zip + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/src/components/sidebar/sidebar.stories.js b/src/components/sidebar/sidebar.stories.js index 5961b5c4..982adec4 100644 --- a/src/components/sidebar/sidebar.stories.js +++ b/src/components/sidebar/sidebar.stories.js @@ -183,4 +183,4 @@ DefaultSidebar.args = { collapsible: true, }; -DefaultSidebar.storyName = 'Sidebar'; \ No newline at end of file +DefaultSidebar.storyName = 'Sidebar'; From ddb2b6a2af7be5dbae27a027402971b8b67b62cf Mon Sep 17 00:00:00 2001 From: Vrunda Kansara Date: Wed, 2 Oct 2024 15:20:07 +0530 Subject: [PATCH 5/5] Updated version --- bin/release.sh | 2 +- package.json | 2 +- version.json | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/bin/release.sh b/bin/release.sh index 1d20fea3..d38042e9 100644 --- a/bin/release.sh +++ b/bin/release.sh @@ -18,7 +18,7 @@ if [[ -d "$BUILD_DIR" ]]; then fi COMMIT=$(git rev-parse HEAD) -VERSION=$(grep 'Version: ' $PWD/ai-builder.php | grep -oEi '[0-9\.a-z\+-]+$') +VERSION=$(grep '"force-ui": " ' $PWD/version.json | grep -oEi '[0-9\.a-z\+-]+$"') # Check if the tag exists in the remote GitHub repository. TAG_EXISTS=$(git ls-remote --tags origin | grep -c "refs/tags/$VERSION") diff --git a/package.json b/package.json index 1274f574..8ce1f473 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@bsf/force-ui", - "version": "0.0.3", + "version": "1.0.0", "description": "Library of components for the BSF project", "main": "dist/force-ui.js", "scripts": { diff --git a/version.json b/version.json index 92a052d3..d73890aa 100644 --- a/version.json +++ b/version.json @@ -1,3 +1,3 @@ { - "force-ui": "0.0.3" + "force-ui": "1.0.0" }