feat: v1
This commit is contained in:
@@ -1,19 +0,0 @@
|
||||
name: npm release
|
||||
on:
|
||||
workflow_dispatch: {}
|
||||
push:
|
||||
tags: [ "v*" ]
|
||||
branches: [ "feature/*" ]
|
||||
defaults:
|
||||
runs-on: pkgx
|
||||
container:
|
||||
volumes:
|
||||
- "/cache:/cache"
|
||||
run:
|
||||
shell: sh -Eeou pipefail -x {0}
|
||||
jobs:
|
||||
release:
|
||||
runs-on: pkgx
|
||||
container:
|
||||
volumes:
|
||||
- "/cache:/cache"
|
||||
3
.prettierrc.json
Normal file
3
.prettierrc.json
Normal file
@@ -0,0 +1,3 @@
|
||||
{
|
||||
"printWidth": 120
|
||||
}
|
||||
23
README.md
Normal file
23
README.md
Normal file
@@ -0,0 +1,23 @@
|
||||
# Сборка и публикация npm пакета какого-либо SDK для pulumi.
|
||||
|
||||
## Пример использования
|
||||
|
||||
```yaml
|
||||
on:
|
||||
workflow_dispatch: {}
|
||||
push:
|
||||
tags: [ "v*" ]
|
||||
branches: [ "feature/*" ]
|
||||
jobs:
|
||||
release:
|
||||
runs-on: docker
|
||||
container:
|
||||
volumes: [ "/cache:/cache" ]
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: pkgxdev/dev@v1
|
||||
- uses: https://git.it3.su/actions/pulumi-npm-release@v1
|
||||
with:
|
||||
package_dir: src/sdk
|
||||
npm_config_registry_auth: ${{ secrets.NPM_CONFIG_REGISTRY_AUTH }}
|
||||
```
|
||||
77
Taskfile.base.yml
Normal file
77
Taskfile.base.yml
Normal file
@@ -0,0 +1,77 @@
|
||||
# yaml-language-server: $schema=https://taskfile.dev/schema.json
|
||||
version: '3'
|
||||
set: [ e, pipefail, u, x ]
|
||||
|
||||
env:
|
||||
NPM_TAG:
|
||||
sh: |
|
||||
tag=dev
|
||||
if [[ "$GITHUB_REF_NAME" = "v*" ]]; then
|
||||
tag=latest
|
||||
fi
|
||||
echo "$tag"
|
||||
|
||||
tasks:
|
||||
base:release:
|
||||
desc: "Весь процесс борки и выпуска"
|
||||
cmds:
|
||||
- task: base:info
|
||||
- task: base:npm:auth
|
||||
- task: base:npm:audit
|
||||
- task: base:npm:install
|
||||
- task: base:npm:build
|
||||
- task: base:npm:version
|
||||
- task: base:npm:unpublish
|
||||
- task: base:npm:publish
|
||||
|
||||
base:info:
|
||||
desc: "Информация"
|
||||
cmds:
|
||||
- echo "GITHUB_REF_NAME=$GITHUB_REF_NAME"
|
||||
- echo "NPM_TAG=$NPM_TAG"
|
||||
- echo "PWD=$PWD"
|
||||
|
||||
base:npm:auth:
|
||||
desc: "Настройка аутентификации в npm registry"
|
||||
cmds:
|
||||
- echo "$NPM_CONFIG_REGISTRY_AUTH" >> .npmrc
|
||||
- cat .npmrc
|
||||
|
||||
base:npm:audit:
|
||||
desc: "Аудит проекта на безопасность"
|
||||
cmds:
|
||||
- npm audit --audit-level critical
|
||||
|
||||
base:npm:install:
|
||||
desc: "Установка зависимостей"
|
||||
cmds:
|
||||
- npm ci --prefer-offline --no-audit --no-fund --no-update-notifier --ignore-scripts
|
||||
|
||||
base:npm:build:
|
||||
desc: "Сборка"
|
||||
cmds:
|
||||
- npm run build
|
||||
|
||||
base:npm:version:
|
||||
desc: "Корректировка версии c учётом npm тега"
|
||||
if: '[ "$NPM_TAG" != "latest" ]'
|
||||
cmd: |
|
||||
echo "[INFO] Тег npm пакета: $NPM_TAG"
|
||||
version=$(npm pkg get version | tr -d '"')
|
||||
version="$version-$NPM_TAG"
|
||||
npm pkg set "version=$version"
|
||||
echo "[INFO] Задана версия пакета: $version"
|
||||
|
||||
base:npm:unpublish:
|
||||
desc: "Удаление текущей версии пакета c учётом npm тега"
|
||||
if: '[ "$NPM_TAG" != "latest" ]'
|
||||
cmd: |
|
||||
name=$(npm pkg get name | tr -d '"')
|
||||
version=$(npm pkg get version | tr -d '"')
|
||||
#npm dist-tag rm "$name" "$NPM_TAG" || true
|
||||
npm unpublish "$name@$version" --force || true
|
||||
|
||||
base:npm:publish:
|
||||
desc: "Публикация"
|
||||
cmd: |
|
||||
npm publish --tag "$NPM_TAG" --verbose
|
||||
23
action.yml
Normal file
23
action.yml
Normal file
@@ -0,0 +1,23 @@
|
||||
name: 'Release npm package'
|
||||
description: 'Сборка и публикация npm пакета'
|
||||
inputs:
|
||||
package_dir:
|
||||
description: 'Относительный путь к папке пакета внутри репозитория'
|
||||
required: false
|
||||
default: '.'
|
||||
npm_config_registry_auth:
|
||||
description: 'Часть .npmrc отвечающая за авторизацию'
|
||||
required: false
|
||||
default: ''
|
||||
runs:
|
||||
using: 'composite'
|
||||
steps:
|
||||
- name: "release"
|
||||
shell: bash
|
||||
env:
|
||||
PACKAGE_DIR: ${{ inputs.package_dir }}
|
||||
NPM_CONFIG_REGISTRY_AUTH: ${{ inputs.npm_config_registry_auth }}
|
||||
working-directory: ${{ inputs.package_dir }}
|
||||
run: |
|
||||
cp "$GITHUB_ACTION_PATH/Taskfile.base.yml" ./Taskfile.base.yml
|
||||
task -t "./Taskfile.base.yml" base:release
|
||||
Reference in New Issue
Block a user