|
| 1 | +# TODO move this run to buildkite |
| 2 | + |
| 3 | +name: Publish a Release |
| 4 | + |
| 5 | +on: |
| 6 | + workflow_dispatch: |
| 7 | + inputs: |
| 8 | + version_bump: |
| 9 | + description: 'Version bump type' |
| 10 | + required: true |
| 11 | + type: choice |
| 12 | + default: patch |
| 13 | + options: |
| 14 | + - patch |
| 15 | + - minor |
| 16 | + - major |
| 17 | + |
| 18 | +env: |
| 19 | + ECH_NODE_VERSION: '22.22.0' |
| 20 | + |
| 21 | +jobs: |
| 22 | + release: |
| 23 | + name: Release |
| 24 | + runs-on: ubuntu-latest |
| 25 | + permissions: |
| 26 | + contents: write # to be able to publish a GitHub release and push tags |
| 27 | + id-token: write # to enable use of OIDC for trusted publishing and npm provenance |
| 28 | + steps: |
| 29 | + - name: Check out repository |
| 30 | + uses: actions/checkout@v6.0.2 |
| 31 | + with: |
| 32 | + token: ${{ secrets.ADMIN_TOKEN_GH }} |
| 33 | + fetch-depth: 0 |
| 34 | + fetch-tags: true |
| 35 | + |
| 36 | + - name: Setup node |
| 37 | + uses: actions/setup-node@v6.4.0 |
| 38 | + with: |
| 39 | + node-version: ${{ env.ECH_NODE_VERSION }} |
| 40 | + registry-url: https://registry.npmjs.org |
| 41 | + |
| 42 | + - name: Install node_modules |
| 43 | + uses: bahmutov/npm-install@v1.12.1 |
| 44 | + with: |
| 45 | + useRollingCache: true |
| 46 | + |
| 47 | + - name: Build library |
| 48 | + run: yarn build |
| 49 | + |
| 50 | + - name: Upgrade npm for trusted publishing (OIDC) support |
| 51 | + run: npm install -g npm@11.5.1 |
| 52 | + |
| 53 | + - name: Bump version |
| 54 | + id: version |
| 55 | + working-directory: packages/charts |
| 56 | + run: | |
| 57 | + NEW_VERSION=$(npm version ${{ inputs.version_bump }} --no-git-tag-version) |
| 58 | + echo "version=${NEW_VERSION#v}" >> "$GITHUB_OUTPUT" |
| 59 | + echo "tag=${NEW_VERSION}" >> "$GITHUB_OUTPUT" |
| 60 | +
|
| 61 | + - name: Copy package files |
| 62 | + run: node ./packages/charts/scripts/move_txt_files.js |
| 63 | + |
| 64 | + - name: Configure git |
| 65 | + run: | |
| 66 | + git config user.name "github-actions[bot]" |
| 67 | + git config user.email "41898282+github-actions[bot]@users.noreply.github.com" |
| 68 | +
|
| 69 | + - name: Commit version bump |
| 70 | + run: | |
| 71 | + git add packages/charts/package.json |
| 72 | + git commit -m "chore(release): ${{ steps.version.outputs.tag }} [skip ci]" |
| 73 | +
|
| 74 | + - name: Create tag |
| 75 | + run: git tag ${{ steps.version.outputs.tag }} |
| 76 | + |
| 77 | + - name: Publish to npm |
| 78 | + working-directory: packages/charts |
| 79 | + run: npm publish --provenance --access public |
| 80 | + |
| 81 | + - name: Push commit and tag |
| 82 | + run: git push origin "${{ github.ref_name }}" --follow-tags |
| 83 | + |
| 84 | + - name: Create GitHub release |
| 85 | + env: |
| 86 | + GH_TOKEN: ${{ secrets.ADMIN_TOKEN_GH }} |
| 87 | + run: | |
| 88 | + gh release create "${{ steps.version.outputs.tag }}" \ |
| 89 | + --generate-notes \ |
| 90 | + --title "@elastic/charts ${{ steps.version.outputs.tag }}" |
| 91 | +
|
| 92 | + - name: Notify Slack |
| 93 | + if: success() |
| 94 | + env: |
| 95 | + SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK }} |
| 96 | + run: | |
| 97 | + if [ -n "$SLACK_WEBHOOK" ]; then |
| 98 | + curl -fsSL -X POST -H 'Content-type: application/json' \ |
| 99 | + --data "{\"text\":\"Released @elastic/charts@${{ steps.version.outputs.version }}\"}" \ |
| 100 | + "$SLACK_WEBHOOK" |
| 101 | + fi |
0 commit comments