Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 20 additions & 9 deletions .github/workflows/qa.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,43 +5,54 @@ on:
branches:
- main

env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_AUTH_TOKEN_PUBLIC }}

jobs:
qa:
name: Code Quality Node ${{ matrix.node }}
runs-on: [self-hosted, Linux]
runs-on: ubuntu-latest
timeout-minutes: 30
strategy:
fail-fast: false
matrix:
node: [20, 22, 24]
steps:
- name: Checkout repository
uses: actions/checkout@v4
uses: actions/checkout@v6

- name: Clean pnpm setup cache
run: rm -rf ~/setup-pnpm

- name: Setup pnpm
uses: pnpm/action-setup@v5

- name: Setup Node ${{ matrix.node }}
uses: actions/setup-node@v4
uses: actions/setup-node@v6
with:
node-version: ${{ matrix.node }}
registry-url: https://registry.npmjs.org

- name: Install dependencies
run: npm ci
run: pnpm install --frozen-lockfile

- name: Run Format
if: matrix.node == 22
run: npm run format
run: pnpm run format

- name: Lint source files
if: matrix.node == 22
run: npm run lint
run: pnpm run lint

- name: Check types
if: matrix.node == 22
run: npm run typecheck
run: pnpm run typecheck

- name: Build package
run: npm run build
run: pnpm run build

- name: Run tests with coverage
run: npm run test:coverage
run: pnpm run test:coverage

- name: 'Report Coverage'
if: matrix.node == 22 && always()
Expand Down
132 changes: 100 additions & 32 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -1,48 +1,116 @@
name: Release CI
name: Release

on:
push:
branches:
- main

permissions:
contents: write
pull-requests: write
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_AUTH_TOKEN_PUBLIC }}
FORCE_COLOR: '3'

jobs:
ci:
name: CI Init
runs-on: [self-hosted, Linux]
outputs:
action: ${{ steps.init.outputs.action }}
release:
name: Create Release PR
runs-on: ubuntu-latest
if: "!contains(github.event.head_commit.message, '🚀 release:')"
timeout-minutes: 10
steps:
- id: init
uses: localazy/release/init@v2

prepare:
name: Prepare Release PR
needs: ci
if: needs.ci.outputs.action == 'prepare'
runs-on: [self-hosted, Linux]
steps:
- uses: localazy/release/prepare@v2
- name: Checkout repository
uses: actions/checkout@v6
with:
fetch-depth: 0

- name: Generate token
id: auth
uses: actions/create-github-app-token@v3
with:
node-version-file: .nvmrc
app-id: ${{ secrets.AUTH_APP_ID }}
app-key: ${{ secrets.AUTH_APP_KEY }}
badges: true
badges-size: dist/browser/localazy-api-client.umd.min.js
private-key: ${{ secrets.AUTH_APP_KEY }}

- name: Clean pnpm setup cache
run: rm -rf ~/setup-pnpm

- name: Setup pnpm
uses: pnpm/action-setup@v5

- name: Setup Node
uses: actions/setup-node@v6
with:
node-version-file: .nvmrc
registry-url: https://registry.npmjs.org

- name: Install dependencies
run: pnpm install --frozen-lockfile

- name: Run release script
run: pnpx @localazy/workflow-scripts create-release-pr .
env:
GITHUB_TOKEN: ${{ steps.auth.outputs.token }}

publish:
name: Publish Release
needs: ci
if: needs.ci.outputs.action == 'publish'
runs-on: [self-hosted, Linux]
name: Publish to npm
runs-on: ubuntu-latest
if: "contains(github.event.head_commit.message, '🚀 release:')"
timeout-minutes: 10
permissions:
contents: write
steps:
- uses: localazy/release/publish@v2
- name: Generate token
id: auth
uses: actions/create-github-app-token@v3
with:
node-version-file: .nvmrc
app-id: ${{ secrets.AUTH_APP_ID }}
app-key: ${{ secrets.AUTH_APP_KEY }}
npm-publish: public
npm-token: ${{ secrets.NPM_AUTH_TOKEN_PUBLIC }}
private-key: ${{ secrets.AUTH_APP_KEY }}

- name: Checkout repository
uses: actions/checkout@v6
with:
fetch-depth: 0

- name: Clean pnpm setup cache
run: rm -rf ~/setup-pnpm

- name: Setup pnpm
uses: pnpm/action-setup@v5

- name: Setup Node
uses: actions/setup-node@v6
with:
node-version-file: .nvmrc
registry-url: https://registry.npmjs.org

- name: Install dependencies
run: pnpm install --frozen-lockfile

- name: Build
run: pnpm run build

- name: Determine npm tag
id: npm-tag
run: |
VERSION=$(node -p "require('./package.json').version")
if echo "$VERSION" | grep -q '-'; then
echo "tag=${VERSION#*-}" | sed 's/\..*//' >> "$GITHUB_OUTPUT"
else
echo "tag=latest" >> "$GITHUB_OUTPUT"
fi

- name: Publish to npm
run: pnpm publish --no-git-checks --tag ${{ steps.npm-tag.outputs.tag }} --access public

- name: Create and push git tag
id: git-tag
run: |
NAME=$(node -p "require('./package.json').name")
VERSION=$(node -p "require('./package.json').version")
TAG="${NAME}@${VERSION}"
git tag "${TAG}"
git push origin "${TAG}"
echo "tag=${TAG}" >> "$GITHUB_OUTPUT"
echo "version=${VERSION}" >> "$GITHUB_OUTPUT"

- name: Create GitHub Release
run: pnpx @localazy/workflow-scripts create-github-release "${{ steps.git-tag.outputs.version }}"
env:
GITHUB_TOKEN: ${{ steps.auth.outputs.token }}
2 changes: 1 addition & 1 deletion .husky/pre-push
Original file line number Diff line number Diff line change
@@ -1 +1 @@
npm run check
pnpm run check
2 changes: 1 addition & 1 deletion .nvmrc
Original file line number Diff line number Diff line change
@@ -1 +1 @@
22
24
1 change: 1 addition & 0 deletions .oxlintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@
"unicorn/numeric-separators-style": "off",
"unicorn/prefer-module": "off",
"unicorn/catch-error-name": "off",
"typescript/no-unnecessary-type-arguments": "off",
// custom config
// "eslint/func-style": ["error", "declaration"],
"typescript/return-await": ["error", "error-handling-correctness-only"],
Expand Down
Loading