Skip to content

PO-UI Publish Beta

PO-UI Publish Beta #18

name: PO-UI Publish Beta
env:
COMPONENTS_NPM_PATH: teste2-poui-deploy/ng-components
WORKING_DIR: /home/runner/work/po-angular-copy/po-angular-copy/po-angular
on:
workflow_dispatch:
inputs:
versao-beta:
description: Informe a versão do Beta do PO-UI
required: true
versao-po-style:
description: Informe a versão do @po-ui/style
required: true
jobs:
build-and-publish:
runs-on: ubuntu-latest
if: github.ref == 'refs/heads/development'
steps:
- uses: actions/setup-node@v3
with:
node-version: '16.x'
registry-url: 'https://registry.npmjs.org'
- name: Check out po-angular
uses: actions/checkout@v4
with:
path: po-angular
- name: Check out style
uses: actions/checkout@v4
with:
repository: po-ui/po-style
path: po-style
- name: Check out lint
uses: actions/checkout@v4
with:
repository: po-ui/po-tslint
path: po-tslint
- name: Update Version
run: node ./scripts/update-version.js ${{ github.event.inputs.versao-beta }} ${{ github.event.inputs.versao-po-style }}
working-directory: ${{env.WORKING_DIR}}
- name: Install and Build
run: npm install && npm run build:ui
working-directory: ${{env.WORKING_DIR}}
# Pega as versões publicadas no NPM e salva no arquivo versions.json
- name: Obter todas as versões publicadas
run: npm show @${{ env.COMPONENTS_NPM_PATH }} versions --json > versions.json
# Pega a versão no package.json
- name: Get package.json version.
id: package-version
uses: martinbeentjes/npm-get-version-action@main
with:
path: po-angular
# Verifica se a versão a ser publicada já existe no NPM
- name: Verificar se a versão existe
id: version
run: |
VERSION_TO_CHECK=${{ steps.package-version.outputs.current-version }}
if jq -e --arg version "$VERSION_TO_CHECK" '.[] | select(. == $version)' versions.json; then
echo "publish=no" >> "$GITHUB_OUTPUT"
else
echo "publish=yes" >> "$GITHUB_OUTPUT"
fi
# PUBLISH NG-COMPONENTS
- name: ng-components - publish
if: contains(steps.version.outputs.publish, 'yes')
run: npm publish ${{env.WORKING_DIR}}/dist/ng-components --tag beta --ignore-scripts
env:
PACKAGE_VERSION: ${{ steps.package-version.outputs.current-version }}
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
- name: ng-components - add "beta" tag
if: contains(steps.version.outputs.publish, 'no')
run: npm dist-tags add @${{ env.COMPONENTS_NPM_PATH }}@${{ env.PACKAGE_VERSION }} "beta"
working-directory: ${{env.WORKING_DIR}}
env:
PACKAGE_VERSION: ${{ steps.package-version.outputs.current-version }}
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}