PO-UI Publish Next #29
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: PO-UI Publish Next | |
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: | |
jobs: | |
build-and-publish: | |
runs-on: ubuntu-latest | |
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: Install and Build | |
run: npm install && npm run build:ui | |
working-directory: ${{env.WORKING_DIR}} | |
# Pega a última versão dos pacotes publicados no npm e armazena em variáveis | |
- run: echo "COMPONENTS_LAST_PUBLISHED_VERSION=$(npm view @${{ env.COMPONENTS_NPM_PATH }} dist-tags.next)" >> $GITHUB_ENV | |
- 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 | |
- 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 | |
# DEBUG | |
- name: ECHO | |
run: | | |
echo "${{ toJSON(steps) }}" | |
echo "${{ toJSON(env) }}" | |
# PUBLISH NG-COMPONENTS | |
- name: ng-components - publish | |
if: contains(steps.version.outputs.publish, 'yes') | |
run: npm publish ${{env.WORKING_DIR}}/dist/ng-components --tag next --ignore-scripts | |
env: | |
PACKAGE_VERSION: ${{ steps.package-version.outputs.current-version }} | |
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} | |
- name: ng-components - add "next" tag | |
if: contains(steps.version.outputs.publish, 'no') | |
run: npm dist-tags add @${{ env.COMPONENTS_NPM_PATH }}@${{ env.PACKAGE_VERSION }} | |
working-directory: ${{env.WORKING_DIR}} | |
env: | |
PACKAGE_VERSION: ${{ steps.package-version.outputs.current-version }} | |
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} |