|
| 1 | +name: Version, Tag & Publish |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: [main] |
| 6 | + |
| 7 | +jobs: |
| 8 | + Version: |
| 9 | + runs-on: >- |
| 10 | + ${{ fromJSON(format('{{"cloudconformity": "ubuntu-latest", "v1-cspm-conformity": "ebf-pod-ubuntu-2004-slim@{0}-commitlint"}}', github.run_id))[github.repository_owner] }} |
| 11 | + outputs: |
| 12 | + tag_version: ${{ steps.version.outputs.version }} |
| 13 | + steps: |
| 14 | + - uses: actions/checkout@24cb9080177205b6e8c946b17badbe402adc938f # v3.4.0 |
| 15 | + - uses: actions/setup-node@64ed1c7eab4cce3362f8c340dee64e5eaeef8f7c # v3.6.0 |
| 16 | + with: |
| 17 | + node-version: 16 |
| 18 | + - run: npm i npm@8 -g |
| 19 | + - name: Version and tag |
| 20 | + id: version |
| 21 | + uses: cloudconformity/npm-version-action@v0.3.0 # no need to a specific hash because we trust internal repos. |
| 22 | + - name: Get the output version |
| 23 | + run: echo "The version was ${{ steps.version.outputs.version }}" |
| 24 | + |
| 25 | + Publish: |
| 26 | + needs: Version |
| 27 | + runs-on: >- |
| 28 | + ${{ fromJSON(format('{{"cloudconformity": "ubuntu-latest", "v1-cspm-conformity": "ebf-pod-ubuntu-2004-slim@{0}-commitlint"}}', github.run_id))[github.repository_owner] }} |
| 29 | + env: |
| 30 | + ARTIFACTORY_TOKEN: ${{ secrets.ARTIFACTORY_TOKEN }} |
| 31 | + ARTIFACTORY_TOKEN_EMAIL: ${{ secrets.ARTIFACTORY_TOKEN_EMAIL }} |
| 32 | + ARTIFACTORY_URL: ${{ secrets.ARTIFACTORY_URL_VIRTUAL }} |
| 33 | + ARTIFACTORY_URL_PUBLISH: ${{ secrets.ARTIFACTORY_URL }} |
| 34 | + steps: |
| 35 | + - uses: actions/checkout@24cb9080177205b6e8c946b17badbe402adc938f # v3.4.0 |
| 36 | + with: |
| 37 | + persist-credentials: false |
| 38 | + ref: ${{needs.Version.outputs.tag_version}} |
| 39 | + - uses: actions/setup-node@64ed1c7eab4cce3362f8c340dee64e5eaeef8f7c # v3.6.0 |
| 40 | + with: |
| 41 | + node-version: 16 |
| 42 | + - run: npm i npm@8 -g |
| 43 | + # Install |
| 44 | + - run: npm config set registry https://$ARTIFACTORY_URL |
| 45 | + - run: npm config set replace-registry-host npm.pkg.github.com |
| 46 | + - run: npm config set //$ARTIFACTORY_URL:_auth "$(echo -n $ARTIFACTORY_TOKEN_EMAIL:$ARTIFACTORY_TOKEN | base64 -w 0)" |
| 47 | + - run: npm config set //$ARTIFACTORY_URL:email "$ARTIFACTORY_TOKEN_EMAIL" |
| 48 | + - run: npm config set //$ARTIFACTORY_URL:always-auth true |
| 49 | + - run: npm ci |
| 50 | + - run: npm run build --if-present |
| 51 | + # Publish to Artifactory |
| 52 | + - run: npm config set registry https://$ARTIFACTORY_URL_PUBLISH |
| 53 | + - run: npm config set //$ARTIFACTORY_URL_PUBLISH:_auth "$(echo -n $ARTIFACTORY_TOKEN_EMAIL:$ARTIFACTORY_TOKEN | base64 -w 0)" |
| 54 | + - run: npm config set //$ARTIFACTORY_URL_PUBLISH:email "$ARTIFACTORY_TOKEN_EMAIL" |
| 55 | + - run: npm config set //$ARTIFACTORY_URL_PUBLISH:always-auth true |
| 56 | + - run: npm publish |
0 commit comments