Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

release: automate the release for this project #194

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 35 additions & 0 deletions .github/actions/npm-publish/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
---

name: npm/publish
description: common build tasks for npm publish

inputs:
node-version:
description: 'Nodejs version'
required: false
default: 'v18.20.2'
package:
description: 'The npm package'
required: true
npm-token:
description: 'The NPMJS token'
required: true

runs:
using: "composite"
steps:
- uses: actions/setup-node@v4
with:
node-version: 'v18.20.2'
registry-url: 'https://registry.npmjs.org'

- run: npm ci --ignore-scripts
shell: 'bash'

- name: npm publish
working-directory: ./packages/${{ inputs.package}}
run: npm publish
shell: 'bash'
env:
# https://docs.github.com/en/actions/publishing-packages/publishing-nodejs-packages#publishing-packages-to-the-npm-registry
NODE_AUTH_TOKEN: ${{ inputs.npm-token }}
36 changes: 36 additions & 0 deletions .github/workflows/release-ecs-helpers.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# Release a tagged version of the '@elastic/ecs-helpers' package.
name: release-ecs-helpers

on:
push:
tags:
- ecs-helpers-v*.*.*

# 'id-token' perm needed for npm publishing with provenance (see
# https://docs.npmjs.com/generating-provenance-statements#example-github-actions-workflow)
permissions:
contents: write
pull-requests: read
id-token: write

jobs:
release:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0

- uses: ./.github/actions/npm-publish
with:
node-version: 'v18.20.2'
npm-token: 'ecs-helpers'
package: ${{ matrix.package }}

- name: Notify in Slack
if: ${{ failure() }}
uses: elastic/oblt-actions/slack/notify-result@v1
with:
bot-token: ${{ secrets.SLACK_BOT_TOKEN }}
channel-id: "#apm-agent-node"
message: '[${{ github.repository }}] Release `@elastic/ecs-helpers` *${{ github.ref_name }}*'
50 changes: 50 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
# Release a tagged version of the '@elastic/ecs-[...]-format' packages.
name: release

on:
push:
tags:
- v*.*.*

# 'id-token' perm needed for npm publishing with provenance (see
# https://docs.npmjs.com/generating-provenance-statements#example-github-actions-workflow)
permissions:
contents: write
pull-requests: read
id-token: write

jobs:
release:
runs-on: ubuntu-latest
strategy:
matrix:
package: ["ecs-morgan-format", "ecs-pino-format", "ecs-winston-format"]
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0

- uses: ./.github/actions/npm-publish
with:
node-version: 'v18.20.2'
npm-token: ${{ secrets.NPM_TOKEN }}
package: ${{ matrix.package }}

notify:
runs-on: ubuntu-latest
needs: [release]
steps:
- id: check
uses: elastic/oblt-actions/check-dependent-jobs@v1
with:
jobs: ${{ toJSON(needs) }}
- name: Notify in Slack
# Only notify on failure, because on success the published GitHub
# Release will result in a notification from the GitHub Slack app
# (assuming '/github subscribe elastic/elastic-otel-node').
if: ${{ steps.check.outputs.status == 'failure' }}
uses: elastic/oblt-actions/slack/[email protected]
with:
bot-token: ${{ secrets.SLACK_BOT_TOKEN }}
channel-id: "#apm-agent-node"
message: '[${{ github.repository }}] Release `@elastic/ecs-[...]-format` packages *${{ github.ref_name }}*'
25 changes: 20 additions & 5 deletions RELEASING.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,18 +22,28 @@ Assuming "x.y.z" is the release version:
changes, then the commit/PR title should include mention of those
things as well.)
3. Get the PR approved and merged.
4. Tag the commit as follows, in a git clone with the merged commit:

4. Working on the elastic repo (not a fork), tag the commit as follows:
```
git tag ecs-helpers-vx.y.z
git push origin ecs-helpers-vx.y.z
```
5. Publish to npm, in a clean git clone:
The GitHub Actions "release-ecs-helpers" workflow will handle the release
steps -- including the `npm publish`. See the appropriate run at:
https://github.com/elastic/ecs-logging-nodehs/actions/workflows/release-ecs-helpers.yml

5. The automation will do the rest.

If for any reason you need to run the publish the package manually then run the
below command in a clean git clone:
```
git status # this should show "working tree clean"

cd packages/ecs-helpers
npm publish
```


## Releasing `@elastic/ecs-[...]-format`

1. Choose the appropriate version number. All `ecs-*-format` packages currently
Expand Down Expand Up @@ -62,18 +72,23 @@ Assuming "x.y.z" is the release version:

3. Get the PR approved and merged.

4. Tag the commit as follows, in a git clone with the merged commit:
4. Working on the elastic repo (not a fork), tag the commit as follows:
```
git tag vx.y.z
git push origin vx.y.z
```
The GitHub Actions "release" workflow will handle the release
steps -- including the `npm publish`. See the appropriate run at:
https://github.com/elastic/ecs-logging-nodehs/actions/workflows/release.yml

5. The automation will do the rest.

5. Publish to npm, in a clean git clone:
If for any reason you need to run the publish the package manually then run the
below command in a clean git clone:
```
git status # this should show "working tree clean"

# for each of the packages being released:
cd packages/ecs-...-format
npm publish
```

4 changes: 4 additions & 0 deletions packages/ecs-helpers/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@
"name": "@elastic/ecs-helpers",
"version": "2.1.1",
"description": "ecs-logging-nodejs helpers",
"publishConfig": {
"access": "public",
"provenance": true
},
"main": "lib/index.js",
"files": [
"lib"
Expand Down
4 changes: 4 additions & 0 deletions packages/ecs-morgan-format/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@
"name": "@elastic/ecs-morgan-format",
"version": "1.5.1",
"description": "A formatter for the morgan logger compatible with Elastic Common Schema.",
"publishConfig": {
"access": "public",
"provenance": true
},
"main": "index.js",
"types": "index.d.ts",
"files": [
Expand Down
4 changes: 4 additions & 0 deletions packages/ecs-pino-format/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@
"name": "@elastic/ecs-pino-format",
"version": "1.5.0",
"description": "A formatter for the pino logger compatible with Elastic Common Schema.",
"publishConfig": {
"access": "public",
"provenance": true
},
"main": "index.js",
"files": [
"index.js",
Expand Down
4 changes: 4 additions & 0 deletions packages/ecs-winston-format/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@
"name": "@elastic/ecs-winston-format",
"version": "1.5.3",
"description": "A formatter for the winston logger compatible with Elastic Common Schema.",
"publishConfig": {
"access": "public",
"provenance": true
},
"main": "index.js",
"types": "index.d.ts",
"files": [
Expand Down