Skip to content

Create snapshot release from 8c87f6034b4cadbbfdee116b06bc7c448d3a4437 by github-actions[bot] #161

Create snapshot release from 8c87f6034b4cadbbfdee116b06bc7c448d3a4437 by github-actions[bot]

Create snapshot release from 8c87f6034b4cadbbfdee116b06bc7c448d3a4437 by github-actions[bot] #161

Workflow file for this run

name: Release packages
run-name: "Create ${{ inputs.type }} release from ${{ inputs.release_ref }} by ${{ github.actor }}"
on:
workflow_dispatch:
inputs:
release_ref:
description: Upstream git ref to create the release from
required: true
type: string
type:
description: Release type
required: true
type: choice
options:
- snapshot
- official
workspaces:
description: A comma-separated list of workspaces to release
required: false
type: string
dry_run:
description: Dry run (do not publish the packages)
required: true
type: boolean
skip_tests:
description: Skip tests (snapshots only)
default: false
type: boolean
npm_tag:
description: "[Custom releases only] npm tag to use"
required: false
type: string
kibana_integration:
description: "[Snapshot only] Trigger the Kibana integration test chain after publishing"
default: false
type: boolean
kibana_pr_title:
description: "[Kibana integration only] Title for the Kibana PR"
required: false
type: string
kibana_pr_body:
description: "[Kibana integration only] Body for the Kibana PR"
required: false
type: string
kibana_source_pr_number:
description: "[Kibana integration only] Source EUI PR number that triggered the run"
required: false
type: string
kibana_nightly:
description: "[Kibana integration only] Whether this is a scheduled nightly run"
default: false
type: boolean
concurrency:
group: ${{ inputs.kibana_nightly && 'kibana-nightly' || format('release-{0}', github.run_id) }}
cancel-in-progress: false
queue: max
permissions:
id-token: write # Required for OIDC
contents: read
jobs:
lint_and_unit_tests:
name: Run lint and unit tests
runs-on: ubuntu-latest
if: ${{ !(inputs.type == 'snapshot' && inputs.skip_tests) }}
steps:
- uses: actions/checkout@v4
with:
ref: ${{ inputs.release_ref }}
persist-credentials: false
- uses: actions/setup-node@v6
with:
node-version-file: .nvmrc
cache: yarn
- name: Install dependencies
run: yarn install --immutable && yarn workspace @elastic/eui-test-helpers playwright install chromium
- name: Build local packages
run: yarn workspaces foreach --all --parallel --topological-dev --exclude @elastic/eui-website --exclude @elastic/eui-monorepo --exclude @elastic/eui-docgen run build
- name: Lint
run: yarn workspaces foreach --all --parallel --topological-dev --exclude @elastic/eui-website --exclude @elastic/eui-monorepo --exclude @elastic/eui-docgen run lint
- name: Unit tests
run: yarn workspaces foreach --all --parallel --topological-dev --exclude @elastic/eui-website --exclude @elastic/eui-monorepo --exclude @elastic/eui-docgen run test-unit
cypress_tests:
name: Run cypress tests
runs-on: ubuntu-latest
if: ${{ !(inputs.type == 'snapshot' && inputs.skip_tests) }}
steps:
- uses: actions/checkout@v4
with:
ref: ${{ inputs.release_ref }}
persist-credentials: false
- uses: actions/setup-node@v6
with:
node-version-file: .nvmrc
cache: yarn
- name: Install dependencies
run: yarn install --immutable
- name: Build local packages
run: yarn workspaces foreach --all --parallel --topological-dev --exclude @elastic/eui-website --exclude @elastic/eui-monorepo --exclude @elastic/eui-docgen run build
- name: Cypress tests
run: yarn workspaces foreach --all --parallel --topological-dev --exclude @elastic/eui-website --exclude @elastic/eui-monorepo --exclude @elastic/eui-docgen run test-cypress
release_snapshot:
name: Create a snapshot release
runs-on: ubuntu-latest
if: |
always() &&
inputs.type == 'snapshot' &&
(needs.lint_and_unit_tests.result == 'success' || needs.lint_and_unit_tests.result == 'skipped') &&
(needs.cypress_tests.result == 'success' || needs.cypress_tests.result == 'skipped')
needs: [ lint_and_unit_tests, cypress_tests ]
permissions:
id-token: write # Required for OIDC (npm trusted publishing)
contents: read
actions: write # Required to dispatch the Kibana integration chain
steps:
- uses: actions/checkout@v4
with:
ref: ${{ inputs.release_ref }}
# This is needed for yarn version to work properly, but it increases fetch time.
# We can change this back to "1" if we replace yarn version with something else
fetch-depth: 0
- name: Configure git
run: |
git config --global user.name 'elasticmachine'
git config --global user.email 'elasticmachine@users.noreply.github.com'
- uses: actions/setup-node@v6
with:
node-version-file: .nvmrc
cache: yarn
registry-url: 'https://registry.npmjs.org'
- name: Install dependencies
run: npm install -g npm@11.6.2 && yarn install --immutable
- name: Build release scripts
run: yarn workspace @elastic/eui-release-cli run build
- name: Rename git remote to upstream
run: git remote rename origin upstream
- name: Prepare list of workspaces
id: prepare_workspaces_arg
uses: actions/github-script@v8
env:
WORKSPACES: ${{ inputs.workspaces }}
with:
# language=javascript
script: |
if (!process.env.WORKSPACES || typeof process.env.WORKSPACES !== 'string') {
return '';
}
return `--workspaces ${process.env.WORKSPACES.split(',').join(' ')}`;
result-encoding: string
- name: Prepare npm tag
id: prepare_npm_tag_arg
uses: actions/github-script@v8
env:
NPM_TAG: ${{ inputs.npm_tag }}
with:
# language=javascript
script: |
if (!process.env.NPM_TAG || typeof process.env.NPM_TAG !== 'string') {
return '';
}
if (process.env.NPM_TAG === 'latest') {
throw new Error('npm_tag cannot be set to "latest" for snapshot releases!');
}
return `--tag ${process.env.NPM_TAG}`;
result-encoding: string
- name: Release
run: yarn release run snapshot --skip-prompts --skip-auth-check --use-auth-token --allow-custom ${{ inputs.dry_run && '--dry-run' || ''}} ${{ steps.prepare_npm_tag_arg.outputs.result }} ${{ steps.prepare_workspaces_arg.outputs.result }}
- name: Trigger Kibana integration test
# Keep `release.yml` as the npm trusted-publishing entry point; continue
# the Kibana chain only after the snapshot package metadata exists.
if: ${{ inputs.type == 'snapshot' && inputs.kibana_integration && !inputs.dry_run }}
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
PR_TITLE: ${{ inputs.kibana_pr_title }}
PR_BODY: ${{ inputs.kibana_pr_body }}
SOURCE_PR_NUMBER: ${{ inputs.kibana_source_pr_number }}
NIGHTLY: ${{ inputs.kibana_nightly }}
EUI_REF: ${{ inputs.release_ref }}
# language=bash
run: |
set -euo pipefail
dependencies="$(jq -c . .release/published_packages.json)"
eui_version=''
eui_last_release=''
if [[ "$NIGHTLY" == "true" ]]; then
eui_version="$(
jq -r '.[] | select(.name == "@elastic/eui") | .version' \
.release/published_packages.json
)"
if [[ -z "$eui_version" ]]; then
echo "::error::The snapshot did not publish @elastic/eui"
exit 1
fi
last_release="$(git describe --tags --abbrev=0 --match 'v[0-9]*' --exclude '*-*' "$EUI_REF")"
eui_last_release="$last_release"
fi
args=(
-f "dependencies=$dependencies"
-f "pr_title=$PR_TITLE"
-f "pr_body=$PR_BODY"
-f "nightly=$NIGHTLY"
-f "eui_ref=$EUI_REF"
-f "eui_last_release=$eui_last_release"
-f "eui_version=$eui_version"
)
if [[ -n "${SOURCE_PR_NUMBER:-}" ]]; then
args+=( -f "source_pr_number=$SOURCE_PR_NUMBER" )
fi
gh workflow run update_kibana_dependencies__prepare_changes.yml --repo "$GITHUB_REPOSITORY" "${args[@]}"
release_official:
name: Create an official release
runs-on: ubuntu-latest
if: |
inputs.type == 'official' &&
needs.lint_and_unit_tests.result == 'success' &&
needs.cypress_tests.result == 'success'
needs: [ lint_and_unit_tests, cypress_tests ]
steps:
- uses: actions/checkout@v4
with:
ref: ${{ inputs.release_ref }}
# This is needed for yarn version to work properly, but it increases fetch time.
# We can change this back to "1" if we replace yarn version with something else
fetch-depth: 0
- name: Verify release commit is tagged
run: |
tag=$(git tag --points-at ${{ inputs.release_ref }})
if [[ "$?" -ne 0 ]] || [[ -z "$tag" ]]; then
echo "::error:: Release ref does not point to any tag. Please tag the merge commit of the release PR and try again"
exit 1
else
echo "Release commit verified - $tag"
fi
- name: Configure git
run: |
git config --global user.name 'elasticmachine'
git config --global user.email 'elasticmachine@users.noreply.github.com'
- uses: actions/setup-node@v6
with:
node-version-file: .nvmrc
cache: yarn
registry-url: 'https://registry.npmjs.org'
- name: Install dependencies
run: npm install -g npm@11.6.2 && yarn install --immutable
- name: Build release scripts
run: yarn workspace @elastic/eui-release-cli run build
- name: Rename git remote to upstream
run: git remote rename origin upstream
- name: Prepare list of workspaces
id: prepare_workspaces_arg
uses: actions/github-script@v8
env:
WORKSPACES: ${{ inputs.workspaces }}
with:
# language=javascript
script: |
if (!process.env.WORKSPACES || typeof process.env.WORKSPACES !== 'string') {
return '';
}
return `--workspaces ${process.env.WORKSPACES.split(',').join(' ')}`;
result-encoding: string
- name: Prepare npm tag
id: prepare_npm_tag_arg
uses: actions/github-script@v8
env:
NPM_TAG: ${{ inputs.npm_tag }}
with:
# language=javascript
script: |
if (!process.env.NPM_TAG || typeof process.env.NPM_TAG !== 'string') {
return '';
}
return `--tag ${process.env.NPM_TAG}`;
result-encoding: string
- name: Release
run: yarn release run official --skip-prompts --skip-auth-check --use-auth-token --allow-custom --skip-update-versions ${{ inputs.dry_run && '--dry-run' || ''}} ${{ steps.prepare_npm_tag_arg.outputs.result }} ${{ steps.prepare_workspaces_arg.outputs.result }}