Skip to content

Pre-Release

Pre-Release #1015

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 'coremedia-ci@coremedia.com'
- 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