From 0ab4362e02613f76e867963876abd0ed6e16680e Mon Sep 17 00:00:00 2001 From: "S.Gromov" Date: Sat, 11 Jul 2026 09:27:46 +0300 Subject: [PATCH] =?UTF-8?q?ci:=20=D0=B4=D0=BE=D0=B1=D0=B0=D0=B2=D0=B8?= =?UTF-8?q?=D1=82=D1=8C=20=D0=BF=D1=80=D0=BE=D0=B2=D0=B5=D1=80=D0=BA=D1=83?= =?UTF-8?q?=20=D0=B8=20=D0=BF=D1=83=D0=B1=D0=BB=D0=B8=D0=BA=D0=B0=D1=86?= =?UTF-8?q?=D0=B8=D1=8E=20=D1=80=D0=B5=D0=BB=D0=B8=D0=B7=D0=BE=D0=B2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - добавлен CI для pull request и master - настроена OIDC-публикация npm из GitHub Release - добавлена упаковка локализованных скиллов и контрольных сумм --- .github/workflows/ci.yml | 42 +++++++++++++ .github/workflows/release.yml | 107 ++++++++++++++++++++++++++++++++++ 2 files changed, 149 insertions(+) create mode 100644 .github/workflows/ci.yml create mode 100644 .github/workflows/release.yml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..943b597 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,42 @@ +name: CI + +on: + push: + branches: + - master + pull_request: + branches: + - master + workflow_dispatch: + +permissions: + contents: read + +concurrency: + group: ci-${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + +jobs: + verify: + name: Verify and build + runs-on: ubuntu-latest + timeout-minutes: 30 + + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Setup Node.js + uses: actions/setup-node@v4 + with: + node-version: 24 + cache: npm + + - name: Install dependencies + run: npm ci + + - name: Verify + run: npm run verify + + - name: Build + run: npm run build diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..7bfa20f --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,107 @@ +name: Release + +on: + release: + types: + - published + +permissions: + contents: write + id-token: write + +concurrency: + group: release-${{ github.event.release.tag_name }} + cancel-in-progress: false + +jobs: + publish: + name: Publish package and skills + runs-on: ubuntu-latest + timeout-minutes: 30 + environment: npm + + steps: + - name: Checkout release tag + uses: actions/checkout@v4 + with: + ref: ${{ github.event.release.tag_name }} + + - name: Setup Node.js + uses: actions/setup-node@v4 + with: + node-version: 24 + cache: npm + + - name: Update npm + run: npm install --global npm@latest + + - name: Check release version + env: + RELEASE_TAG: ${{ github.event.release.tag_name }} + run: | + node --input-type=module -e ' + import { readFileSync } from "node:fs" + + const packageJson = JSON.parse(readFileSync("package.json", "utf8")) + const expectedTag = `v${packageJson.version}` + + if (process.env.RELEASE_TAG !== expectedTag) { + throw new Error( + `Release tag ${process.env.RELEASE_TAG} does not match package version ${expectedTag}`, + ) + } + ' + + - name: Install dependencies + run: npm ci + + - name: Verify + run: npm run verify + + - name: Build package + run: npm run build + + - name: Build skills + run: npm run build:skill + + - name: Prepare release files + run: mkdir release + + - name: Pack npm package + run: npm pack --ignore-scripts --pack-destination release + + - name: Pack skills + working-directory: skills/artifacts + run: | + zip -r ../../release/svg-sprites.zip svg-sprites + zip -r ../../release/svg-sprites-ru.zip svg-sprites-ru + + - name: Create checksums + run: sha256sum release/* > release/SHA256SUMS + + - name: Publish npm package + env: + IS_PRERELEASE: ${{ github.event.release.prerelease }} + run: | + PACKAGE_SPEC=$(node -p "const pkg = require('./package.json'); pkg.name + '@' + pkg.version") + + if npm view "$PACKAGE_SPEC" version --json > /dev/null 2>&1; then + echo "$PACKAGE_SPEC is already published" + exit 0 + fi + + DIST_TAG=latest + if [ "$IS_PRERELEASE" = "true" ]; then + DIST_TAG=next + fi + + npm publish release/*.tgz --access public --provenance --tag "$DIST_TAG" + + - name: Upload GitHub Release assets + uses: softprops/action-gh-release@v2 + with: + files: | + release/*.tgz + release/*.zip + release/SHA256SUMS + overwrite_files: true