Files
contracts/.github/workflows/publish.yml
Дмитрий 7e1b70125a
Some checks failed
Publish / Publish Job (push) Failing after 2m34s
fix: --ignoreConfig
2026-04-03 13:40:46 +03:00

79 lines
3.1 KiB
YAML
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
name: Publish
on:
push:
branches:
- main
jobs:
publish:
name: Publish Job
runs-on: ubuntu-latest
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: 20
registry-url: "https://git.lendry.ru/api/packages/lendry-erp/npm/"
scope: "@lendry-erp"
# 1. Устанавливаем Go (нужен для скачивания плагинов генерации)
- name: Setup Go
uses: actions/setup-go@v5
with:
go-version: "1.22" # Можно указать нужную тебе версию
# 2. Устанавливаем плагины генерации для Go и добавляем их в PATH
- name: Install Go Protoc Plugins
run: |
go install google.golang.org/protobuf/cmd/protoc-gen-go@latest
go install google.golang.org/grpc/cmd/protoc-gen-go-grpc@latest
echo "$(go env GOPATH)/bin" >> $GITHUB_PATH
- name: Install protoc
run: sudo apt-get update && sudo apt-get install -y protobuf-compiler
- name: Install deps
run: npm ci
# 1. СНАЧАЛА генерируем .ts и .go файлы (переместили шаг выше)
- name: Generate Protobuf
run: |
npm install -g ts-proto
mkdir -p ./gen/go
protoc -I ./proto ./proto/*.proto \
--ts_proto_out=nestJs=true,addGrpcMetadata=true,package=omit:./gen \
--go_out=paths=source_relative:./gen/go \
--go-grpc_out=paths=source_relative:./gen/go
# 2. ЗАТЕМ собираем основной проект (если у вас есть другая логика в src/)
- name: Build
run: npm run build
# 3. НОВЫЙ ШАГ: Компилируем протобуфы в JS прямо внутри папки gen/
# Это гарантирует, что рядом с account.ts появится account.js и account.d.ts,
# и NestJS найдет их по точному пути без изменения импортов!
- name: Compile generated TS to JS in-place
run: |
cd gen
npx tsc *.ts --declaration --module commonjs --target es2021 --esModuleInterop --skipLibCheck --ignoreConfig
- name: Commit and push changes
run: |
# Представляемся Git-ботом
git config --global user.name "github-actions[bot]"
git config --global user.email "github-actions[bot]@users.noreply.github.com"
# Добавляем папку gen в индекс
git add ./gen
# Проверяем, есть ли изменения. Если есть — коммитим и пушим.
git diff --quiet && git diff --staged --quiet || (git commit -m "chore: auto-generate protobuf files [skip ci]" && git push)
- name: Publish package
run: npm publish