v5.1.0 (#379) #109
Workflow file for this run
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*.*.*' | |
env: | |
NODE_VERSION: '20.x' | |
PNPM_VERSION: '10' | |
permissions: | |
contents: read | |
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 pnpm | |
uses: pnpm/action-setup@v4 | |
with: | |
version: ${{ env.PNPM_VERSION }} | |
- name: Install dependencies | |
run: pnpm install --frozen-lockfile | |
- name: Run build | |
run: pnpm run build | |
- name: Run lint | |
run: pnpm run lint | |
env: | |
CI: true | |
- name: Run unit tests | |
run: pnpm run test:unit | |
- name: Run integration tests | |
run: pnpm 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 | |
permissions: | |
contents: write | |
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: Install pnpm | |
uses: pnpm/action-setup@v4 | |
with: | |
version: ${{ env.PNPM_VERSION }} | |
- name: Get and validate version | |
id: version | |
run: | | |
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 | |
pnpm install | |
git config user.name "GitHub Actions" | |
git config user.email "[email protected]" | |
git add package.json pnpm-lock.yaml | |
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: pnpm install --frozen-lockfile | |
- name: Build package | |
run: pnpm run build | |
- name: Publish to NPM | |
run: pnpm publish --no-git-checks | |
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 pnpm | |
uses: pnpm/action-setup@v4 | |
with: | |
version: ${{ env.PNPM_VERSION }} | |
- name: Install dependencies | |
run: pnpm install --frozen-lockfile | |
- name: Generate documentation | |
run: pnpm 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]" |