Skip to content

Commit

Permalink
cicd: release and ci
Browse files Browse the repository at this point in the history
  • Loading branch information
Callum Cunha committed Jan 8, 2025
1 parent f16b418 commit e314895
Show file tree
Hide file tree
Showing 19 changed files with 410 additions and 54 deletions.
29 changes: 29 additions & 0 deletions .github/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# .github/release.yml
changelog:
exclude:
labels:
- ignore-for-release
categories:
- title: Breaking Changes 🛠
labels:
- break
- breaking-change
- title: New Features 🎉
labels:
- feat
- enhancement
- title: Fixes 🐛
labels:
- fix
- bug
- title: Dependencies 📦
labels:
- deps
- dependencies
- title: Documentation 📚
labels:
- docs
- documentation
- title: Other Changes
labels:
- "*"
92 changes: 92 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
name: CI
on:
push:
branches: [main, dev]
pull_request:
branches: [main]

jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- uses: actions/setup-node@v4
with:
node-version: '20'

- uses: pnpm/action-setup@v3
with:
version: 8
run_install: false

- name: Get pnpm store directory
id: pnpm-cache
shell: bash
run: |
echo "STORE_PATH=$(pnpm store path)" >> $GITHUB_OUTPUT
- uses: actions/cache@v4
name: Setup pnpm cache
with:
path: ${{ steps.pnpm-cache.outputs.STORE_PATH }}
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
restore-keys: |
${{ runner.os }}-pnpm-store-
- name: Install dependencies
run: pnpm install --no-frozen-lockfile

- name: Type check
run: pnpm run type-check

- name: Lint
run: pnpm run lint

- name: Lint JSR
run: pnpm run lint:jsr

- name: Test
run: pnpm run test

- name: Build
run: pnpm run build

security:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- uses: actions/setup-node@v4
with:
node-version: '20'

- uses: pnpm/action-setup@v3
with:
version: 8
run_install: false

- name: Get pnpm store directory
id: pnpm-cache
shell: bash
run: |
echo "STORE_PATH=$(pnpm store path)" >> $GITHUB_OUTPUT
- uses: actions/cache@v4
name: Setup pnpm cache
with:
path: ${{ steps.pnpm-cache.outputs.STORE_PATH }}
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
restore-keys: |
${{ runner.os }}-pnpm-store-
- name: Install dependencies
run: pnpm install --no-frozen-lockfile

- name: Run Snyk to check for vulnerabilities
uses: snyk/actions/node@master
env:
SNYK_TOKEN: ${{ secrets.SNYK_TOKEN }}

- name: Run pnpm audit
run: pnpm audit
167 changes: 167 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,167 @@
name: Release

on:
push:
branches: [main]
paths-ignore:
- '**/*.md'
- '**/*.txt'

permissions:
contents: write # Needed for creating releases
pull-requests: write # Needed for creating version bump PRs
id-token: write # Needed for JSR OIDC authentication

jobs:
version:
runs-on: ubuntu-latest
outputs:
version: ${{ steps.version.outputs.version }}
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0

- uses: pnpm/action-setup@v3
with:
version: 8
run_install: false

- name: Set Git User
run: |
git config --global user.email "[email protected]"
git config --global user.name "CICD"
- name: Versions
uses: reecetech/[email protected]
id: version
with:
scheme: semver

- name: Debug version output
run: echo "new version ${{ steps.version.outputs.version }}"

- name: Update package.json version
run: pnpm version ${{ steps.version.outputs.version }} --no-git-tag-version

publish-npm:
needs: version
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Set Git User
run: |
git config --global user.email "[email protected]"
git config --global user.name "CICD"
- uses: actions/setup-node@v4
with:
node-version: '20'
registry-url: 'https://registry.npmjs.org'

- uses: pnpm/action-setup@v3
with:
version: 8
run_install: false

- name: Get pnpm store directory
id: pnpm-cache
shell: bash
run: |
echo "STORE_PATH=$(pnpm store path)" >> $GITHUB_OUTPUT
- uses: actions/cache@v4
name: Setup pnpm cache
with:
path: ${{ steps.pnpm-cache.outputs.STORE_PATH }}
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
restore-keys: |
${{ runner.os }}-pnpm-store-
- name: Install dependencies
run: pnpm install --no-frozen-lockfile

- name: Build
run: pnpm run build

- name: Update package.json version
run: pnpm version ${{ needs.version.outputs.version }} --no-git-tag-version

- name: Publish to NPM
run: pnpm publish --no-git-checks --access public
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}

publish-jsr:
needs: version
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Set Git User
run: |
git config --global user.email "[email protected]"
git config --global user.email "[email protected]"
git config --global user.name "CICD"
- uses: actions/setup-node@v4
with:
node-version: '20'
registry-url: 'https://registry.npmjs.org'

- uses: pnpm/action-setup@v3
with:
version: 8
run_install: false

- name: Get pnpm store directory
id: pnpm-cache
shell: bash
run: |
echo "STORE_PATH=$(pnpm store path)" >> $GITHUB_OUTPUT
- uses: actions/cache@v4
name: Setup pnpm cache
with:
path: ${{ steps.pnpm-cache.outputs.STORE_PATH }}
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
restore-keys: |
${{ runner.os }}-pnpm-store-
- name: Install dependencies
run: pnpm install --no-frozen-lockfile

- name: Build
run: pnpm run build

- name: Update jsr.json version
run: |
NEW_VERSION=${{ needs.version.outputs.version }}
jq --arg new_version "$NEW_VERSION" '.version = $new_version' jsr.json > temp.json && mv temp.json jsr.json
- name: Publish to JSR
run: pnpx jsr publish --allow-dirty
# No NODE_AUTH_TOKEN needed here as we're using OIDC

tag:
needs: [publish-npm, publish-jsr, version]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Set Git User
run: |
git config --global user.email "[email protected]"
git config --global user.name "CICD"
- name: Create GitHub Release
uses: softprops/action-gh-release@v1
with:
tag_name: ${{ needs.version.outputs.version }}
name: Release ${{ needs.version.outputs.version }}
generate_release_notes: true
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
/node_modules
/*-lock.yaml
/*-lock.yaml
dist
3 changes: 3 additions & 0 deletions .npmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
@org:registry=https://npm.jsr.io
shamefully-hoist=true
strict-peer-dependencies=false
12 changes: 12 additions & 0 deletions eslint.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import globals from "globals";
import pluginJs from "@eslint/js";
import tseslint from "typescript-eslint";


/** @type {import('eslint').Linter.Config[]} */
export default [
{files: ["**/*.{js,mjs,cjs,ts}"]},
{languageOptions: { globals: globals.node }},
pluginJs.configs.recommended,
...tseslint.configs.recommended,
];
6 changes: 6 additions & 0 deletions jsr.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"name": "@nexhub/vite-rspc-plugin",
"version": "1.0.0",
"exports": "./src/plugin.ts",
"license": "MIT"
}
30 changes: 25 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,25 @@
{
"name": "vite-rspc-plugin",
"name": "@nexhub/vite-rspc-plugin",
"version": "1.0.0",
"description": "A vite plugin for auto-generating dedicated functions for RSPC per query, mutation, and subscription with typescript",
"type": "module",
"scripts": {
"test": "vitest"
"build": "tsc --emitDeclarationOnly",
"prebuild": "rimraf dist",
"test": "vitest run",
"test:watch": "vitest",
"test:coverage": "vitest run --coverage",
"test:ui": "vitest --ui",
"type-check": "tsc --noEmit",
"type-check:watch": "tsc --noEmit --watch",
"lint": "eslint 'src/**/*.{js,ts}'",
"lint:jsr": "pnpx jsr publish --dry-run",
"lint:fix": "eslint 'src/**/*.{js,ts}' --fix",
"format": "prettier --write \"**/*.{ts,tsx,js,jsx,json,md}\"",
"format:check": "prettier --check \"**/*.{ts,tsx,js,jsx,json,md}\"",
"clean": "rimraf dist node_modules",
"clean:dist": "rimraf dist",
"reinstall": "pnpm clean && pnpm install"
},
"keywords": [
"vite",
Expand All @@ -12,17 +28,21 @@
"typescript"
],
"author": "NexRX",
"license": "ISC",
"license": "MIT",
"dependencies": {
"@rspc/client": "^0.3.1",
"typescript": "^5.7.2",
"vite": "^6.0.7"
},
"devDependencies": {
"@eslint/js": "^9.17.0",
"@types/node": "^22.10.5",
"@types/tmp": "^0.2.6",
"@vitest/coverage-v8": "2.1.8",
"tmp": "^0.2.3",
"eslint": "^9.17.0",
"globals": "^15.14.0",
"rimraf": "^6.0.1",
"typescript-eslint": "^8.19.1",
"vitest": "^2.1.8"
}
}
}
Loading

0 comments on commit e314895

Please sign in to comment.