v4.1.1 (#372) #103
This file contains hidden or 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: CI/CD Pipeline | |
| on: | |
| push: | |
| tags: | |
| - 'v*.*.*' | |
| branches: | |
| - master | |
| env: | |
| NODE_VERSION: '18' | |
| jobs: | |
| build-and-test: | |
| name: Build and Test | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| - name: Setup Node.js ${{ env.NODE_VERSION }} | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: ${{ env.NODE_VERSION }} | |
| - name: Install dependencies | |
| run: npm ci | |
| - name: Run build | |
| run: npm run build | |
| - name: Run lint | |
| run: npm run lint | |
| env: | |
| CI: true | |
| - name: Run unit tests | |
| run: npm run test:unit | |
| - name: Run integration tests | |
| run: npm run test:integration | |
| env: | |
| HOST: ${{ secrets.HOST }} | |
| EMAIL: ${{ secrets.EMAIL }} | |
| API_TOKEN: ${{ secrets.API_TOKEN }} | |
| publish-package: | |
| name: Publish Package | |
| needs: build-and-test | |
| runs-on: ubuntu-latest | |
| if: github.ref == 'refs/heads/master' | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| - name: Setup Node.js ${{ env.NODE_VERSION }} | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: ${{ env.NODE_VERSION }} | |
| registry-url: 'https://registry.npmjs.org' | |
| - name: Get and validate version | |
| id: version | |
| run: | | |
| # Get version from tag if exists | |
| if [[ $GITHUB_REF == refs/tags/v* ]]; then | |
| TAG_VERSION=${GITHUB_REF#refs/tags/v} | |
| echo "Using version from tag: $TAG_VERSION" | |
| CURRENT_VERSION=$(node -p "require('./package.json').version") | |
| if [ "$TAG_VERSION" != "$CURRENT_VERSION" ]; then | |
| echo "Updating package version to match tag..." | |
| npm version $TAG_VERSION --no-git-tag-version | |
| npm install | |
| git config user.name "GitHub Actions" | |
| git config user.email "actions@github.com" | |
| git add package.json package-lock.json | |
| git commit -m "Update version to $TAG_VERSION [skip ci]" | |
| git push | |
| fi | |
| else | |
| TAG_VERSION=$(node -p "require('./package.json').version") | |
| echo "Using version from package.json: $TAG_VERSION" | |
| fi | |
| echo "version=$TAG_VERSION" >> $GITHUB_OUTPUT | |
| echo "VERSION=$TAG_VERSION" >> $GITHUB_ENV | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.PAT }} | |
| - name: Install dependencies | |
| run: npm ci | |
| - name: Build package | |
| run: npm run build | |
| - name: Publish to NPM | |
| run: npm publish | |
| env: | |
| NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} | |
| deploy-documentation: | |
| name: Deploy Documentation | |
| needs: publish-package | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| with: | |
| ref: master | |
| - name: Setup Node.js ${{ env.NODE_VERSION }} | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: ${{ env.NODE_VERSION }} | |
| - name: Install dependencies | |
| run: npm ci | |
| - name: Generate documentation | |
| run: npm run doc | |
| - name: Deploy to docs branch | |
| uses: JamesIves/github-pages-deploy-action@v4 | |
| with: | |
| branch: docs | |
| folder: docs | |
| clean: true | |
| commit-message: "docs: Update documentation for v${{ needs.publish-package.outputs.version }} [skip ci]" |