|
| 1 | +name: PO-UI Publish Angular@20 |
| 2 | + |
| 3 | +# URL para os pacotes po-ui no npm |
| 4 | +env: |
| 5 | + SCHEMATICS_NPM_PATH: po-ui/ng-schematics |
| 6 | + STORAGE_NPM_PATH: po-ui/ng-storage |
| 7 | + SYNC_NPM_PATH: po-ui/ng-sync |
| 8 | + COMPONENTS_NPM_PATH: po-ui/ng-components |
| 9 | + TEMPLATES_NPM_PATH: po-ui/ng-templates |
| 10 | + CODE_EDITOR_NPM_PATH: po-ui/ng-code-editor |
| 11 | + WORKING_DIR: /home/runner/work/po-angular/po-angular/po-angular |
| 12 | + |
| 13 | +on: |
| 14 | + workflow_dispatch: |
| 15 | + |
| 16 | +jobs: |
| 17 | + build-and-publish: |
| 18 | + runs-on: ubuntu-latest |
| 19 | + if: github.ref == 'refs/heads/20.x.x' |
| 20 | + steps: |
| 21 | + - uses: actions/setup-node@v3 |
| 22 | + with: |
| 23 | + node-version: '20.x' |
| 24 | + registry-url: 'https://registry.npmjs.org' |
| 25 | + |
| 26 | + - name: Check out po-angular |
| 27 | + uses: actions/checkout@v4 |
| 28 | + with: |
| 29 | + path: po-angular |
| 30 | + |
| 31 | + - name: Check out style |
| 32 | + uses: actions/checkout@v4 |
| 33 | + with: |
| 34 | + repository: po-ui/po-style |
| 35 | + path: po-style |
| 36 | + |
| 37 | + - name: Check out lint |
| 38 | + uses: actions/checkout@v4 |
| 39 | + with: |
| 40 | + repository: po-ui/po-tslint |
| 41 | + path: po-tslint |
| 42 | + |
| 43 | + - name: Install and Build |
| 44 | + run: npm install && npm run build |
| 45 | + working-directory: ${{env.WORKING_DIR}} |
| 46 | + |
| 47 | + # Pega as versões publicadas no NPM e salva no arquivo versions.json |
| 48 | + - name: Obter todas as versões publicadas |
| 49 | + run: npm show @${{ env.COMPONENTS_NPM_PATH }} versions --json > versions.json |
| 50 | + |
| 51 | + # Pega a versão no package.json |
| 52 | + - name: Get package.json version. |
| 53 | + id: package-version |
| 54 | + uses: martinbeentjes/npm-get-version-action@main |
| 55 | + with: |
| 56 | + path: po-angular |
| 57 | + |
| 58 | + # Verifica se a versão a ser publicada já existe no NPM |
| 59 | + - name: Verificar se a versão existe |
| 60 | + id: version |
| 61 | + run: | |
| 62 | + VERSION_TO_CHECK=${{ steps.package-version.outputs.current-version }} |
| 63 | + if jq -e --arg version "$VERSION_TO_CHECK" '.[] | select(. == $version)' versions.json; then |
| 64 | + echo "publish=no" >> "$GITHUB_OUTPUT" |
| 65 | + else |
| 66 | + echo "publish=yes" >> "$GITHUB_OUTPUT" |
| 67 | + fi |
| 68 | +
|
| 69 | + # PUBLISH NG-SCHEMATICS |
| 70 | + - name: ng-schematics - publish |
| 71 | + if: contains(steps.version.outputs.publish, 'yes') |
| 72 | + run: npm publish ${{env.WORKING_DIR}}/dist/ng-schematics --tag "v20-ng" --ignore-scripts |
| 73 | + env: |
| 74 | + PACKAGE_VERSION: ${{ steps.package-version.outputs.current-version }} |
| 75 | + NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} |
| 76 | + |
| 77 | + - name: ng-schematics - add "v20-ng" tag |
| 78 | + if: contains(steps.version.outputs.publish, 'no') |
| 79 | + run: npm dist-tags add @${{ env.SCHEMATICS_NPM_PATH }}@${{ env.PACKAGE_VERSION }} "v20-ng" |
| 80 | + working-directory: ${{env.WORKING_DIR}} |
| 81 | + env: |
| 82 | + PACKAGE_VERSION: ${{ steps.package-version.outputs.current-version }} |
| 83 | + NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} |
| 84 | + |
| 85 | + # PUBLISH NG-STORAGE |
| 86 | + - name: ng-storage - publish |
| 87 | + if: contains(steps.version.outputs.publish, 'yes') |
| 88 | + run: npm publish ${{env.WORKING_DIR}}/dist/ng-storage --tag "v20-ng" --ignore-scripts |
| 89 | + env: |
| 90 | + PACKAGE_VERSION: ${{ steps.package-version.outputs.current-version }} |
| 91 | + NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} |
| 92 | + |
| 93 | + - name: ng-storage - add "v20-ng" tag |
| 94 | + if: contains(steps.version.outputs.publish, 'no') |
| 95 | + run: npm dist-tags add @${{ env.STORAGE_NPM_PATH }}@${{ env.PACKAGE_VERSION }} "v20-ng" |
| 96 | + working-directory: ${{env.WORKING_DIR}} |
| 97 | + env: |
| 98 | + PACKAGE_VERSION: ${{ steps.package-version.outputs.current-version }} |
| 99 | + NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} |
| 100 | + |
| 101 | + # PUBLISH NG-SYNC |
| 102 | + - name: ng-sync - publish |
| 103 | + if: contains(steps.version.outputs.publish, 'yes') |
| 104 | + run: npm publish ${{env.WORKING_DIR}}/dist/ng-sync --tag "v20-ng" --ignore-scripts |
| 105 | + env: |
| 106 | + PACKAGE_VERSION: ${{ steps.package-version.outputs.current-version }} |
| 107 | + NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} |
| 108 | + |
| 109 | + - name: ng-sync - add "v20-ng" tag |
| 110 | + if: contains(steps.version.outputs.publish, 'no') |
| 111 | + run: npm dist-tags add @${{ env.SYNC_NPM_PATH }}@${{ env.PACKAGE_VERSION }} "v20-ng" |
| 112 | + working-directory: ${{env.WORKING_DIR}} |
| 113 | + env: |
| 114 | + PACKAGE_VERSION: ${{ steps.package-version.outputs.current-version }} |
| 115 | + NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} |
| 116 | + |
| 117 | + # PUBLISH NG-COMPONENTS |
| 118 | + - name: ng-components - publish |
| 119 | + if: contains(steps.version.outputs.publish, 'yes') |
| 120 | + run: npm publish ${{env.WORKING_DIR}}/dist/ng-components --tag "v20-ng" --ignore-scripts |
| 121 | + env: |
| 122 | + PACKAGE_VERSION: ${{ steps.package-version.outputs.current-version }} |
| 123 | + NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} |
| 124 | + |
| 125 | + - name: ng-components - add "v20-ng" tag |
| 126 | + if: contains(steps.version.outputs.publish, 'no') |
| 127 | + run: npm dist-tags add @${{ env.COMPONENTS_NPM_PATH }}@${{ env.PACKAGE_VERSION }} "v20-ng" |
| 128 | + working-directory: ${{env.WORKING_DIR}} |
| 129 | + env: |
| 130 | + PACKAGE_VERSION: ${{ steps.package-version.outputs.current-version }} |
| 131 | + NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} |
| 132 | + |
| 133 | + # PUBLISH NG-TEMPLATES |
| 134 | + - name: ng-templates - publish |
| 135 | + if: contains(steps.version.outputs.publish, 'yes') |
| 136 | + run: npm publish ${{env.WORKING_DIR}}/dist/ng-templates --tag "v20-ng" --ignore-scripts |
| 137 | + env: |
| 138 | + PACKAGE_VERSION: ${{ steps.package-version.outputs.current-version }} |
| 139 | + NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} |
| 140 | + |
| 141 | + - name: ng-templates - add "v20-ng" tag |
| 142 | + if: contains(steps.version.outputs.publish, 'no') |
| 143 | + run: npm dist-tags add @${{ env.TEMPLATES_NPM_PATH }}@${{ env.PACKAGE_VERSION }} "v20-ng" |
| 144 | + working-directory: ${{env.WORKING_DIR}} |
| 145 | + env: |
| 146 | + PACKAGE_VERSION: ${{ steps.package-version.outputs.current-version }} |
| 147 | + NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} |
| 148 | + |
| 149 | + # PUBLISH NG-CODE-EDITOR |
| 150 | + - name: ng-code-editor - publish |
| 151 | + if: contains(steps.version.outputs.publish, 'yes') |
| 152 | + run: npm publish ${{env.WORKING_DIR}}/dist/ng-code-editor --tag "v20-ng" --ignore-scripts |
| 153 | + env: |
| 154 | + PACKAGE_VERSION: ${{ steps.package-version.outputs.current-version }} |
| 155 | + NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} |
| 156 | + |
| 157 | + - name: ng-code-editor - add "v20-ng" tag |
| 158 | + if: contains(steps.version.outputs.publish, 'no') |
| 159 | + run: npm dist-tags add @${{ env.CODE_EDITOR_NPM_PATH }}@${{ env.PACKAGE_VERSION }} "v20-ng" |
| 160 | + working-directory: ${{env.WORKING_DIR}} |
| 161 | + env: |
| 162 | + PACKAGE_VERSION: ${{ steps.package-version.outputs.current-version }} |
| 163 | + NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} |
0 commit comments