From 1ff20e76d3cf5edf04034feaf4508242a0cb9452 Mon Sep 17 00:00:00 2001 From: Dmitriy Chudnyi Date: Wed, 1 Apr 2026 18:52:34 +0300 Subject: [PATCH] feat: v1 --- .gitea/workflows/npm-release.yml | 19 -------- .prettierrc.json | 3 ++ README.md | 23 ++++++++++ Taskfile.base.yml | 77 ++++++++++++++++++++++++++++++++ action.yml | 23 ++++++++++ 5 files changed, 126 insertions(+), 19 deletions(-) delete mode 100644 .gitea/workflows/npm-release.yml create mode 100644 .prettierrc.json create mode 100644 README.md create mode 100644 Taskfile.base.yml create mode 100644 action.yml diff --git a/.gitea/workflows/npm-release.yml b/.gitea/workflows/npm-release.yml deleted file mode 100644 index a1111f4..0000000 --- a/.gitea/workflows/npm-release.yml +++ /dev/null @@ -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" diff --git a/.prettierrc.json b/.prettierrc.json new file mode 100644 index 0000000..963354f --- /dev/null +++ b/.prettierrc.json @@ -0,0 +1,3 @@ +{ + "printWidth": 120 +} diff --git a/README.md b/README.md new file mode 100644 index 0000000..30fd37c --- /dev/null +++ b/README.md @@ -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 }} +``` \ No newline at end of file diff --git a/Taskfile.base.yml b/Taskfile.base.yml new file mode 100644 index 0000000..7094750 --- /dev/null +++ b/Taskfile.base.yml @@ -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 diff --git a/action.yml b/action.yml new file mode 100644 index 0000000..9968c9a --- /dev/null +++ b/action.yml @@ -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