93 lines
2.2 KiB
YAML
93 lines
2.2 KiB
YAML
name: CI / CD
|
|
|
|
on:
|
|
push:
|
|
branches:
|
|
- '**'
|
|
pull_request:
|
|
branches:
|
|
- main
|
|
|
|
jobs:
|
|
build:
|
|
name: Test Build
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
|
|
- uses: pnpm/action-setup@v4
|
|
|
|
- uses: actions/setup-node@v4
|
|
with:
|
|
node-version: '24'
|
|
|
|
- run: pnpm install --no-frozen-lockfile
|
|
- run: pnpm build
|
|
|
|
- name: Zip dist directory
|
|
run: zip -r dist.zip dist/
|
|
|
|
- name: Upload dist artifact
|
|
uses: actions/upload-artifact@v4
|
|
with:
|
|
name: dist-artifact
|
|
path: dist.zip
|
|
|
|
publish:
|
|
name: Publish to NPM
|
|
needs: build
|
|
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
|
|
- uses: pnpm/action-setup@v4
|
|
|
|
- uses: actions/setup-node@v4
|
|
with:
|
|
node-version: '24'
|
|
registry-url: 'https://registry.npmjs.org'
|
|
|
|
- name: Download dist artifact
|
|
uses: actions/download-artifact@v4
|
|
with:
|
|
name: dist-artifact
|
|
|
|
- run: unzip dist.zip
|
|
|
|
- run: pnpm publish --no-git-checks
|
|
env:
|
|
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
|
|
|
|
release:
|
|
name: Create GitHub Release
|
|
needs: publish
|
|
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
|
|
runs-on: ubuntu-latest
|
|
permissions:
|
|
contents: write
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
|
|
- name: Download dist artifact
|
|
uses: actions/download-artifact@v4
|
|
with:
|
|
name: dist-artifact
|
|
|
|
- name: Get version from package.json
|
|
id: package_version
|
|
run: |
|
|
pkg_version=$(node -p "require('./package.json').version")
|
|
echo "VERSION=$pkg_version" >> $GITHUB_OUTPUT
|
|
|
|
- name: Create Release
|
|
uses: softprops/action-gh-release@v2
|
|
with:
|
|
files: dist.zip
|
|
tag_name: v${{ steps.package_version.outputs.VERSION }}
|
|
name: Release v${{ steps.package_version.outputs.VERSION }}
|
|
draft: false
|
|
prerelease: false
|
|
env:
|
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|