Publish a Release #31
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
| # TODO move this run to buildkite | |
| name: Publish a Release | |
| on: | |
| workflow_dispatch: | |
| inputs: | |
| version_bump: | |
| description: 'Version bump type' | |
| required: true | |
| type: choice | |
| default: patch | |
| options: | |
| - patch | |
| - minor | |
| - major | |
| env: | |
| ECH_NODE_VERSION: '22.22.0' | |
| jobs: | |
| checks: | |
| name: Release Checks | |
| runs-on: ubuntu-latest | |
| # needs: status # Not working atm | |
| # Runs checks when others running on main may be in process | |
| # This is likely an edge case unless published shortly following a merge | |
| # This also covers a case where main checks did not complete/succeed | |
| # if: needs.status.outputs.allSuccess | |
| steps: | |
| - name: Check out repository | |
| uses: actions/checkout@v4.1.7 | |
| with: | |
| persist-credentials: false | |
| - name: Setup node | |
| uses: actions/setup-node@v4.0.2 | |
| with: | |
| node-version: ${{ env.ECH_NODE_VERSION }} | |
| # TODO: fix unnecessary yarn installs | |
| - name: Install node_modules | |
| uses: bahmutov/npm-install@v1.10.9 | |
| with: | |
| useRollingCache: true | |
| - name: Install e2e node_modules | |
| uses: bahmutov/npm-install@v1.10.9 | |
| with: | |
| working-directory: e2e | |
| useRollingCache: true | |
| - name: Install e2e node_modules | |
| uses: bahmutov/npm-install@v1.10.9 | |
| with: | |
| working-directory: .buildkite | |
| useRollingCache: true | |
| - name: Install e2e node_modules | |
| uses: bahmutov/npm-install@v1.10.9 | |
| with: | |
| working-directory: github_bot | |
| useRollingCache: true | |
| # TODO: fix this to avoid requiring build to run linting | |
| # currently the storybook and others are loosely coupled to @elastic/charts/src | |
| # such that types point to the local source and not a packaged release | |
| - name: Build charts typescript lib | |
| run: yarn build:ts | |
| - name: Lint check | |
| run: yarn lint | |
| - name: Prettier check | |
| run: yarn prettier:check | |
| - name: TimeZone testing | |
| run: yarn test:tz --ci | |
| - name: Testing | |
| run: yarn test --ci | |
| release: | |
| name: Release | |
| needs: [checks] | |
| if: ${{ needs.checks.result == 'success' }} | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: write # to be able to publish a GitHub release and push tags | |
| id-token: write # to enable use of OIDC for trusted publishing and npm provenance | |
| steps: | |
| - name: Check out repository | |
| uses: actions/checkout@v6.0.2 | |
| with: | |
| token: ${{ secrets.ADMIN_TOKEN_GH }} | |
| fetch-depth: 0 | |
| fetch-tags: true | |
| - name: Setup node | |
| uses: actions/setup-node@v6.4.0 | |
| with: | |
| node-version: ${{ env.ECH_NODE_VERSION }} | |
| registry-url: https://registry.npmjs.org | |
| - name: Install node_modules | |
| uses: bahmutov/npm-install@v1.12.1 | |
| with: | |
| useRollingCache: true | |
| - name: Build library | |
| run: yarn build | |
| - name: Upgrade npm for trusted publishing (OIDC) support | |
| run: npm install -g npm@11.5.1 | |
| - name: Determine npm dist-tag | |
| id: npm_tag | |
| run: echo "dist_tag=release-${{ github.ref_name }}" >> "$GITHUB_OUTPUT" | |
| - name: Bump version | |
| id: version | |
| working-directory: packages/charts | |
| run: | | |
| npm version ${{ inputs.version_bump }} --no-git-tag-version > /dev/null | |
| VERSION=$(node -p "require('./package.json').version") | |
| echo "version=${VERSION}" >> "$GITHUB_OUTPUT" | |
| echo "tag=v${VERSION}" >> "$GITHUB_OUTPUT" | |
| - name: Copy package files | |
| run: node ./packages/charts/scripts/move_txt_files.js | |
| - name: Configure git | |
| run: | | |
| git config user.name "github-actions[bot]" | |
| git config user.email "41898282+github-actions[bot]@users.noreply.github.com" | |
| - name: Commit version bump | |
| run: | | |
| git add packages/charts/package.json | |
| git commit -m "chore(release): ${{ steps.version.outputs.tag }} [skip ci]" | |
| - name: Create tag | |
| run: git tag ${{ steps.version.outputs.tag }} | |
| - name: Publish to npm | |
| working-directory: packages/charts | |
| run: npm publish --provenance --access public --tag "${{ steps.npm_tag.outputs.dist_tag }}" | |
| - name: Push commit and tag | |
| run: | | |
| git push origin "${{ github.ref_name }}" | |
| git push origin "${{ steps.version.outputs.tag }}" | |
| - name: Create GitHub release | |
| env: | |
| GH_TOKEN: ${{ secrets.ADMIN_TOKEN_GH }} | |
| run: | | |
| gh release create "${{ steps.version.outputs.tag }}" \ | |
| --generate-notes \ | |
| --title "@elastic/charts ${{ steps.version.outputs.tag }}" | |
| - name: Notify Slack | |
| if: success() | |
| env: | |
| SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK }} | |
| run: | | |
| if [ -n "$SLACK_WEBHOOK" ]; then | |
| curl -fsSL -X POST -H 'Content-type: application/json' \ | |
| --data "{\"text\":\"Released @elastic/charts@${{ steps.version.outputs.version }} (npm tag: ${{ steps.npm_tag.outputs.dist_tag }})\"}" \ | |
| "$SLACK_WEBHOOK" | |
| fi |