#29254 include in 23.01.22 LTS #1081
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: 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 "[email protected]" | |
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 |