Merge pull request #261 from CoreMedia/removed-dev-blog-files #340
This file contains hidden or 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: Release | |
| # concurrency: Ensures that for one branch the workflow is not running multiple | |
| # times at the same time as we will get trouble with the versions and pushes. | |
| concurrency: ci-${{ github.ref }} | |
| on: | |
| push: | |
| branches: | |
| - main | |
| - 'maintenance/**' | |
| workflow_dispatch: | |
| inputs: | |
| release_type: | |
| description: 'Release type.' | |
| required: true | |
| default: 'patch' | |
| type: choice | |
| options: | |
| - major | |
| - minor | |
| - patch | |
| permissions: | |
| contents: write | |
| env: | |
| NODE_VERSION: 24 | |
| # https://github.com/actions/runner-images/issues/70 | |
| NODE_OPTIONS: "--max_old_space_size=4096" | |
| PNPM_VERSION: ^11.7 | |
| jobs: | |
| build: | |
| name: Build | |
| runs-on: ubuntu-latest | |
| timeout-minutes: 30 | |
| if: github.actor != 'coremedia-ci' && github.actor != 'github-action[bot]' | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v5 | |
| - name: Manual workflow trigger precondition check | |
| if: github.event_name == 'workflow_dispatch' && (github.ref != 'refs/heads/main' && !startsWith(github.ref, 'refs/heads/maintenance/')) | |
| run: | | |
| echo "github.ref=$GITHUB_REF" | |
| echo "::error Building a release is only allowed from main- or maintenance- branches!" | |
| exit 1 | |
| #Make sure the release type is one of the allowed inputs. | |
| - name: Workflow Dispatch release type check | |
| if: github.event_name == 'workflow_dispatch' && !(github.event.inputs.release_type == 'major' || github.event.inputs.release_type == 'minor' || github.event.inputs.release_type == 'patch') | |
| run: | | |
| echo "Expected a release type due to the manual build execution on main branch." | |
| echo "Allowed release types are: major, minor, patch" | |
| exit 1 | |
| - name: Maintenance release type check | |
| if: github.event_name == 'workflow_dispatch' && startsWith(github.ref, 'refs/heads/maintenance/') && !(github.event.inputs.release_type == 'patch') | |
| run: | | |
| echo "For maintenance branches only patch versions are allowed." | |
| exit 1 | |
| - name: Use PNPM ${{ env.PNPM_VERSION }} | |
| uses: pnpm/action-setup@v5 | |
| with: | |
| version: ${{ env.PNPM_VERSION }} | |
| run_install: false | |
| - name: Use Node.js ${{ env.NODE_VERSION }} | |
| uses: actions/setup-node@6044e13b5dc448c55e2357c09f80417699197238 # v6.2.0 | |
| with: | |
| node-version: ${{ env.NODE_VERSION }} | |
| cache: pnpm | |
| - name: Configure NPM | |
| run: | | |
| NPM_AUTH_TOKEN=$(curl -s -H "Accept: application/json" -H "Content-Type:application/json" -X PUT --data '{"name": "${{ secrets.PLUGINS_NEXUS_USER }}", "password": "${{ secrets.PLUGINS_NEXUS_PASSWORD }}"}' https://repository.coremedia.com/nexus/repository/coremedia-npm/-/user/org.couchdb.user:${{ secrets.PLUGINS_NEXUS_USER }} | jq -r .token) | |
| echo "::add-mask::$NPM_AUTH_TOKEN" | |
| echo "NPM_AUTH_TOKEN=$NPM_AUTH_TOKEN" >> $GITHUB_ENV | |
| echo "PNPM_CONFIG_//repository.coremedia.com/nexus/repository/coremedia-npm/:_authToken=$NPM_AUTH_TOKEN" >> $GITHUB_ENV | |
| echo "@coremedia:registry=https://repository.coremedia.com/nexus/repository/coremedia-npm/" >> .npmrc | |
| echo "@coremedia-internal:registry=https://repository.coremedia.com/nexus/repository/coremedia-npm/" >> .npmrc | |
| - name: Setup Git | |
| run: | | |
| git config --global user.name 'coremedia-ci' | |
| git config --global user.email 'coremedia-ci@coremedia.com' | |
| git pull | |
| - name: Install | |
| run: pnpm install | |
| # BY MANUAL TRIGGER ONLY! | |
| # Set the release version to actual MAJOR.MINOR.PATCH version. | |
| # If a prerelease is triggered manually, we keep the prerelease version for this workflow. | |
| - name: Create Release Version | |
| 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 | |
| # Also updates .release-version | |
| next_version=$(pnpm --silent "script:version" --release ${{ github.event.inputs.release_type }} --write) | |
| echo "Next version: ${next_version}" | |
| pnpm run setversion ${next_version} --filter=coremedia/* --dependencyVersion=workspace:${next_version} | |
| git commit -am "ci: Set next release version to: ${next_version}" | |
| pnpm install --no-frozen-lockfile | |
| git commit -am "ci: Update pnpm-lock.yaml for version ${next_version}" | |
| - name: Create env file | |
| run: | | |
| touch .env | |
| echo CKEDITOR_LICENSE_KEY=${{ secrets.CKEDITOR_LICENSE}}>> .env | |
| - name: Build | |
| run: | | |
| pnpm build | |
| - name: Lint | |
| run: pnpm -r lint | |
| - name: Test | |
| env: | |
| CKEDITOR_LICENSE_KEY: ${{ secrets.CKEDITOR_LICENSE }} | |
| run: pnpm test | |
| - name: Playwright Tests | |
| working-directory: tests/playwright | |
| run: | | |
| pnpm exec playwright install --with-deps chromium | |
| pnpm run ui-test | |
| - name: TypeDoc | |
| run: | | |
| if [ -n "$(git status --porcelain)" ]; then | |
| git status | |
| echo "error:: There are unexpected changes in git!"; | |
| exit 1 | |
| fi | |
| pnpm doc | |
| git add --all | |
| git commit -am "doc(typedoc): Update typedoc" | |
| - name: Install for Production | |
| run: pnpm install --production | |
| # Publishes a release with tag "latest" | |
| - name: Publish Release | |
| if: github.event_name == 'workflow_dispatch' | |
| run: | | |
| echo '//repository.coremedia.com/nexus/repository/coremedia-npm/:_authToken=${NPM_AUTH_TOKEN}' > .npmrc | |
| pnpm publishall --registry=https://repository.coremedia.com/nexus/repository/coremedia-npm/ --no-git-checks | |
| git reset --hard | |
| # The "Create Release Version" step pinned all @coremedia/* interdependencies | |
| # to concrete versions so they could be published. Now that publishing is done, | |
| # restore the workspace protocol ("workspace:^<version>") in the committed | |
| # sources, so ongoing development resolves against the local workspace packages. | |
| - name: Restore workspace dependency versions | |
| if: github.event_name == 'workflow_dispatch' | |
| run: | | |
| version=$(cat .release-version) | |
| echo "Restoring workspace dependency versions for: ${version}" | |
| pnpm run setversion ${version} --filter=coremedia/* --dependencyVersion=workspace:^${version} | |
| pnpm install --no-frozen-lockfile | |
| git commit -am "ci: Restore workspace dependency versions for ${version}" | |
| - name: Push commits | |
| run: git push | |
| - name: Create git tag | |
| if: github.event_name == 'workflow_dispatch' | |
| run: | | |
| git tag $(cat .release-version) | |
| git push origin $(cat .release-version) |