Skip to content

createFormStore-workspace #238

createFormStore-workspace

createFormStore-workspace #238

name: Usetheform CI
on:
push:
pull_request:
workflow_dispatch:
inputs:
run_publish:
description: "Publish on NPM?"
required: false
default: "false"
env:
NODE_VERSION: 20.19.0
jobs:
tests:
name: Unit Tests 🧪 - React
runs-on: ubuntu-latest
strategy:
matrix:
react-version: ['17.0.0', '18.2.0', '19.0.0'] # Specify the React versions here
steps:
- name: Checkout repository 🛎️
uses: actions/checkout@v4
- name: Set up Node.js and Yarn 📦
uses: actions/setup-node@v4
with:
node-version: ${{ env.NODE_VERSION }}
cache: 'yarn'
- name: Install dependencies with Yarn 📥
run: yarn install --immutable
- name: Install react@${{ matrix.react-version }} 📦
run: yarn add react@${{ matrix.react-version }} react-dom@${{ matrix.react-version }} -D
working-directory: workspaces/usetheform
- name: React testing-library version 📦
if: matrix.react-version == '17.0.0'
run: yarn add --dev @testing-library/react@^12 @testing-library/jest-dom@^5.16.5
working-directory: workspaces/usetheform
- name: Run Lint 🔍
run: yarn lint
- name: Run tests 🧪
run: yarn test
coveralls:
needs: [tests]
name: Coveralls 📈
runs-on: ubuntu-latest
steps:
- name: Checkout repository 🛎️
uses: actions/checkout@v4
- name: Set up Node.js and Yarn 📦
uses: actions/setup-node@v4
with:
node-version: ${{ env.NODE_VERSION }}
cache: 'yarn'
- name: Install dependencies with Yarn 📥
run: yarn install --immutable
- name: Run tests 🧪
run: yarn test:cov
- name: Coveralls 📈
uses: coverallsapp/github-action@v2.3.6
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
base-path: workspaces/usetheform
cypress-test:
name: Automation Tests 🌐
runs-on: ubuntu-latest
strategy:
matrix:
browser: [chrome, firefox, edge, electron]
env:
TERM: xterm
CI: true
steps:
- name: Checkout repository 🛎️
uses: actions/checkout@v4
- name: Setup Node.js and Yarn 📦
uses: actions/setup-node@v4
with:
node-version: ${{ env.NODE_VERSION }}
cache: 'yarn'
- name: Install dependencies with Yarn 📥
run: yarn install --immutable
- name: Start server 🚀
run: yarn cy:server &
- name: Wait for server ⏳
run: npx wait-on http://localhost:3000/index_react_16.13.0.html --timeout 120000
- name: Run Cypress Tests on ${{ matrix.browser }} 🧪
uses: cypress-io/github-action@v6
env:
CI: true
with:
browser: ${{ matrix.browser }}
command: yarn cy:run --browser ${{ matrix.browser }}
- name: Upload Cypress Artifacts 📂
if: always()
uses: actions/upload-artifact@v4
with:
name: cypress-artifacts-${{ matrix.browser }}-${{ github.run_number }}-${{ github.sha }}
path: |
cypress/videos
cypress/screenshots
build:
name: Build 🛠️
needs: [tests, cypress-test]
runs-on: ubuntu-latest
steps:
- name: Checkout repository 🛎️
uses: actions/checkout@v4
- name: Set up Node.js and Yarn 📦
uses: actions/setup-node@v4
with:
node-version: ${{ env.NODE_VERSION }}
cache: 'yarn'
- name: Install dependencies with Yarn 📥
run: yarn install --immutable
- name: Build 🔨
run: yarn build
publish-alpha:
name: NPM Publish Alpha Version 🔥
runs-on: ubuntu-latest
if: |
github.event_name == 'workflow_dispatch' &&
github.event.inputs.run_publish == 'true' &&
(github.ref != 'refs/heads/master' && github.ref != 'refs/heads/develop')
steps:
- name: Checkout repository 🛎️
uses: actions/checkout@v4
- name: Setup Node.js and Yarn 📦
uses: actions/setup-node@v4
with:
node-version: ${{ env.NODE_VERSION }}
registry-url: "https://registry.npmjs.org/"
- name: Install dependencies with Yarn 📥
run: yarn install --immutable
- name: Build 🔨
run: |
yarn build
cp README.md workspaces/usetheform/README.md
cp LICENSE.md workspaces/usetheform/LICENSE.md
- name: Extract current version 🏷️
run: echo "VERSION=$(node -p "require('./package.json').version")" >> $GITHUB_ENV
working-directory: workspaces/usetheform
- name: Update version for alpha release 📦
run: npm version $VERSION-alpha.${{ github.run_number }} --no-git-tag-version
working-directory: workspaces/usetheform
- name: Publish to npm as alpha 🚀
run: npm publish --tag alpha
working-directory: workspaces/usetheform
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
publish-stable:
name: NPM Publish Stable Version ⭐
runs-on: ubuntu-latest
needs: [tests, cypress-test]
if: |
github.event_name == 'workflow_dispatch' &&
github.event.inputs.run_publish == 'true' &&
github.ref == 'refs/heads/master'
permissions:
contents: write
steps:
- name: Checkout repository 🛎️
uses: actions/checkout@v4
- name: Setup Node.js and Yarn 📦
uses: actions/setup-node@v4
with:
node-version: ${{ env.NODE_VERSION }}
registry-url: "https://registry.npmjs.org/"
- name: Extract current version
id: version
run: echo "VERSION=$(node -p "require('./package.json').version")" >> $GITHUB_ENV
working-directory: workspaces/usetheform
- name: 🏷️ Check if tag already exists
run: |
TAG="v${{ env.VERSION }}"
echo "Checking if tag $TAG already exists..."
if git rev-parse "$TAG" >/dev/null 2>&1; then
echo "⚠️ Tag $TAG already exists. Skipping release."
exit 0
fi
- name: Install dependencies with Yarn 📥
run: yarn install --immutable
- name: Build 🔨
run: |
yarn build
cp README.md workspaces/usetheform/README.md
cp LICENSE.md workspaces/usetheform/LICENSE.md
- name: Publish to npm 🚀
run: npm publish
working-directory: workspaces/usetheform
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
- name: Publish new Tag 🚀
run: |
git config user.name "github-actions"
git config user.email "github-actions@github.com"
git remote set-url origin https://x-access-token:${{ secrets.GITHUB_TOKEN }}@github.com/${{ github.repository }}
git tag -a v${{ env.VERSION }} -m "Release version v${{ env.VERSION }}"
git push origin v${{ env.VERSION }}
- name: Extract Changelog for current version 📝
run: |
CHANGELOG_ENTRY=$(awk -v ver="${{ env.VERSION }}" '
/^## \[v?'${{ env.VERSION }}'\]/ {p=1;print;next}
p&&/^## \[/{p=0}
p{print}
' CHANGELOG.md)
if [ -z "$CHANGELOG_ENTRY" ]; then
echo "Error: Changelog entry not found for version ${{ env.VERSION }}"
exit 1
fi
echo "$CHANGELOG_ENTRY" > release-notes.txt
- name: Create GitHub Release 🎉
uses: softprops/action-gh-release@v2
with:
tag_name: v${{ env.VERSION }}
name: v${{ env.VERSION }}
body_path: release-notes.txt
generate_release_notes: false
token: ${{ secrets.GITHUB_TOKEN }}
deploy_docs:
name: Deploy Docs 📚
runs-on: ubuntu-latest
needs: [tests, cypress-test]
if: |
github.ref == 'refs/heads/master'
steps:
- name: Checkout 🛎️
uses: actions/checkout@v4
- name: Build Docs 🔨
uses: actions/setup-node@v4
with:
node-version: ${{ env.NODE_VERSION }}
- run: yarn install --immutable
- run: yarn docs:build
- run: rm .gitignore
- name: Deploy 🚀
uses: JamesIves/github-pages-deploy-action@v4.7.3
with:
folder: workspaces/docs/build