diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..b14c491 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,40 @@ +name: CI + +on: + push: + branches: [main] + +jobs: + build-and-publish: + runs-on: node-latest + + steps: + - name: Install dependencies + run: npm ci --prefer-offline + + - name: Lint + run: npm run lint + + - name: Check formatting + run: npm run format:check + + - name: Run tests + run: npm test + + - name: Build CDN assets and npm package + run: | + npm run build + npm run build:raw + + - name: Publish to Gitea npm registry + if: success() + env: + GITEA_HOST: ${{ secrets.GITEA_HOST }} + GITEA_TOKEN: ${{ secrets.GITEA_TOKEN }} + run: | + set -e + OWNER="${{ github.repository_owner }}" + echo "//${GITEA_HOST}/api/packages/${OWNER}/npm/:_authToken=${GITEA_TOKEN}" > .npmrc + npm publish \ + --registry "https://${GITEA_HOST}/api/packages/${OWNER}/npm" \ + --ignore-scripts diff --git a/.github/workflows/ready.yml b/.github/workflows/ready.yml deleted file mode 100644 index f58f3af..0000000 --- a/.github/workflows/ready.yml +++ /dev/null @@ -1,47 +0,0 @@ -name: Build and Deploy to CDN - -on: - push: - branches: [main] - -jobs: - build: - runs-on: ubuntu-latest - steps: - - name: Checkout repository - uses: actions/checkout@v4 - - - name: Setup Node.js - uses: actions/setup-node@v4 - with: - node-version: '20' - cache: 'npm' - - - name: Install dependencies - run: npm ci - - - name: Run linter - run: npm run lint - - - name: Run tests - run: npm test - - - name: Build CDN assets - run: npm run build - - - name: Build npm package - run: npm run build:raw - - - name: Publish to Gitea npm registry - env: - GITEA_TOKEN: ${{ secrets.GITEA_TOKEN }} - run: | - echo "//${{ secrets.GITEA_HOST || 'git.db123.ir' }}/api/packages/${{ github.repository_owner }}/${{ github.event.repository.name }}/npm/:_authToken=${GITEA_TOKEN}" > .npmrc - npm publish --registry https://${{ secrets.GITEA_HOST || 'git.db123.ir' }}/api/packages/${{ github.repository_owner }}/${{ github.event.repository.name }}/npm - - - name: Upload CDN build as artifact - uses: actions/upload-artifact@v4 - with: - name: cdn-build - path: dist/ - retention-days: 7