Skip to content

new 23.01.17 LTS

new 23.01.17 LTS #1038

name: Publish to Dotcms Webcomponents
on:
push:
branches:
- release-*
- master
jobs:
changes:
runs-on: ubuntu-latest
outputs:
dotcms-webcomponents: ${{ steps.filter.outputs.dotcms-webcomponents }}
steps:
- name: Checkout core
uses: actions/checkout@v3
- name: Get specific changed files
uses: dorny/paths-filter@v2
id: filter
with:
base: ${{ github.ref }}
list-files: "json"
working-directory: "core-web"
filters: |
dotcms-webcomponents:
- 'core-web/libs/dotcms-webcomponents/**'
- name: Changes found
if: steps.filter.outputs.dotcms-webcomponents == 'true'
run: |
echo "Found Dotcms-webcomponent files changed."
echo ${{ steps.filter.outputs.dotcms-webcomponents_files }}
- name: No changes found
if: steps.filter.outputs.dotcms-webcomponents == 'false'
run: |
echo "No changes found in dotcms-webcomponents"
publish:
needs: changes
if: ${{ needs.changes.outputs.dotcms-webcomponents == 'true' }}
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
with:
persist-credentials: false
fetch-depth: 1
ref: ${{ github.ref_name }}
- name: Configuring Node.js
uses: actions/setup-node@v2-beta
with:
node-version: "16.13.2"
- name: Installing dependencies
run: |
cd core-web
npm install
- name: Version Bump - dotcms-webcomponents - if it's Master/Release Branch
run: |
# Get Branch Name
if [[ "${{ github.event_name }}" == "pull_request" ]]; then
branchName="${{ github.head_ref }}"
else
branchName=$(basename "${{ github.ref }}")
fi
# Checks if branch is release or master
if [[ $branchName == *master* ]]; then
preReleaseTag=next
elif [[ $branchName == *release* ]]; then
preReleaseTag=rc
fi
cd core-web
# Get version from package.json
cd libs/dotcms-webcomponents
pkgVersion=`awk -F'"' '/"version": ".+"/{ print $4; exit; }' package.json`
arrIN=(${pkgVersion//./ })
# Bump version
if [[ $pkgVersion == *$preReleaseTag* ]]; then
preReleaseVersion=${arrIN[-1]}
pkgVersion="${arrIN[0]}.${arrIN[1]}.0-$preReleaseTag.$((preReleaseVersion+1))"
else
pkgVersion="${arrIN[0]}.${arrIN[1]}.0-$preReleaseTag.0"
fi
sed -i -E "s/\"version\": \".*\"/\"version\": \"$pkgVersion\"/g" ./package.json
# Commits new version
git config --global user.email "victor.alfaro@dotcms.com"
git config --global user.name "victoralfaro-dotcms"
git add package.json
git commit -m "CI: bumps version to $pkgVersion [skip ci]"
git push https://victoralfaro-dotcms:${{ secrets.CICD_GITHUB_TOKEN }}@github.com/dotcms/core
- name: Build dotcms-webcomponents with deps
run: |
cd core-web
npm run nx build dotcms-webcomponents && npm run nx build dotcms-ui -- --prod
- name: "Publish to npm"
run: |
cd core-web
npm set //registry.npmjs.org/:_authToken ${{ secrets.NPM_ORG_TOKEN }}
cd dist/libs/dotcms-webcomponents
npm publish --access public