Files
svg-sprites/.github/workflows/release.yml
S.Gromov df096126a7 fix: настроить OIDC-публикацию npm
- release job переведён на checkout и setup-node v6
- npm registry настроен явно без кеширования release job
- пакет публикуется из корня через стандартный npm publish
2026-07-11 11:10:31 +03:00

116 lines
3.0 KiB
YAML

name: Release
on:
release:
types:
- published
workflow_dispatch:
inputs:
tag:
description: Existing release tag to publish
required: true
type: string
permissions:
contents: write
id-token: write
concurrency:
group: release-${{ github.event.release.tag_name || inputs.tag }}
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@v6
with:
ref: ${{ github.event.release.tag_name || inputs.tag }}
- name: Setup Node.js
uses: actions/setup-node@v6
with:
node-version: 24
registry-url: https://registry.npmjs.org
package-manager-cache: false
- name: Update npm
run: npm install --global npm@latest
- name: Check release version
env:
RELEASE_TAG: ${{ github.event.release.tag_name || inputs.tag }}
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: Upload GitHub Release assets
uses: softprops/action-gh-release@v2
with:
tag_name: ${{ github.event.release.tag_name || inputs.tag }}
files: |
release/*.tgz
release/*.zip
release/SHA256SUMS
overwrite_files: true
- name: Publish npm package
env:
IS_PRERELEASE: ${{ github.event.release.prerelease || false }}
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 --ignore-scripts --access public --tag "$DIST_TAG"