Skip to content

Cms 25281 update to 42.x #948

Cms 25281 update to 42.x

Cms 25281 update to 42.x #948

Workflow file for this run

name: Pre-Release
on:
# On push on a PR we want to trigger a normal build without publishing anything
pull_request:
branches: [ main ]
types:
- opened
- reopened
- synchronize
- ready_for_review
# Manual trigger means we want to produce published prerelease artifacts for retesting purposes
workflow_dispatch:
env:
NODE_VERSION: 20
# https://github.com/actions/runner-images/issues/70
NODE_OPTIONS: "--max_old_space_size=4096"
PNPM_VERSION: ^9.4
NPM_CONFIG_@coremedia:registry: 'https://npm.coremedia.io'
jobs:
build:
name: Build
runs-on: ubuntu-latest
timeout-minutes: 13
# do not run when if it is a manual trigger on the main branch as we have other CI for this. This one is only for feature branches
if: (github.event_name != 'workflow_dispatch' || github.ref != 'refs/heads/main') && !github.event.pull_request.draft
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Allocate PR Number for manual trigger
id: read-prnumber
if: github.event_name == 'workflow_dispatch'
run: |
prnumber=$(curl -s -H "Accept: application/vnd.github.v3+json" -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" https://api.github.com/repos/${{github.repository}}/pulls?head=${{github.repository_owner}}:${{github.ref}} | jq -r '.[] | .number' )
echo "Allocated Pull Request number ${prnumber}"
echo "::set-output name=prnumber::${prnumber}"
- name: Use Node.js ${{ env.NODE_VERSION }}
uses: actions/setup-node@v4
with:
node-version: ${{ env.NODE_VERSION }}
- name: Configure NPM
run: |
NPM_AUTH_TOKEN=$(curl -s -H "Accept: application/json" -H "Content-Type:application/json" -X PUT --data '{"name": "${{ secrets.CM_NPM_USER }}", "password": "${{ secrets.CM_NPM_PASSWORD }}"}' https://npm.coremedia.io/-/user/org.couchdb.user:${{ secrets.CM_NPM_USER }} | jq -r .token)
echo "::add-mask::$NPM_AUTH_TOKEN"
echo "NPM_AUTH_TOKEN=$NPM_AUTH_TOKEN" >> $GITHUB_ENV
echo "NPM_CONFIG_//npm.coremedia.io/:_authToken=$NPM_AUTH_TOKEN" >> $GITHUB_ENV
npm install -g pnpm@${{ env.PNPM_VERSION }}
- name: Setup Git
run: |
git config --global user.name 'coremedia-ci'
git config --global user.email '[email protected]'
- name: Install
run: pnpm install
- name: "Validate peerDependencies"
run: pnpm script:validate-peers
- name: Set prerelease version (if triggered manually)
if: github.event_name == 'workflow_dispatch'
run: |
if [ -n "$(git status --porcelain)" ]; then
git status
echo "error:: There are unexpected changes in git!";
exit 1
fi
actual_version=$(cat .release-version)
prnumber=${{ steps.read-prnumber.outputs.prnumber }}
next_version=$(pnpm --silent "script:version" --pull-request ${prnumber} --run-number ${{ github.run_number }})
pnpm run setversion ${next_version} --filter=coremedia/* --dependencyVersion=${next_version}
git commit -am "Set next pre-release version to: ${next_version}"
pnpm install --no-frozen-lockfile
git commit -am "ci: Update pnpm-lock.yaml for version ${next_version}"
echo "**Pre-Release Version:** ${next_version}" >> $GITHUB_STEP_SUMMARY
- name: Build
run: pnpm build
- name: Lint
run: pnpm lint
- name: Test
run: pnpm jest
- name: Playwright Tests
run: pnpm playwright
- name: TypeDoc
run: pnpm doc
- name: Publish prerelease
if: github.event_name == 'workflow_dispatch'
run: |
pnpm install --production
echo '//npm.coremedia.io/:_authToken=${NPM_AUTH_TOKEN}' > .npmrc
pnpm publishall --registry=https://npm.coremedia.io --no-git-checks --tag pullrequest