Skip to content

Commit 071e0ad

Browse files
authored
release: automate the release for this project (#194)
1 parent a0d5ec7 commit 071e0ad

File tree

8 files changed

+157
-5
lines changed

8 files changed

+157
-5
lines changed
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
---
2+
3+
name: npm/publish
4+
description: common build tasks for npm publish
5+
6+
inputs:
7+
node-version:
8+
description: 'Nodejs version'
9+
required: false
10+
default: 'v18.20.2'
11+
package:
12+
description: 'The npm package'
13+
required: true
14+
npm-token:
15+
description: 'The NPMJS token'
16+
required: true
17+
18+
runs:
19+
using: "composite"
20+
steps:
21+
- uses: actions/setup-node@v4
22+
with:
23+
node-version: 'v18.20.2'
24+
registry-url: 'https://registry.npmjs.org'
25+
26+
- run: npm ci --ignore-scripts
27+
shell: 'bash'
28+
29+
- name: npm publish
30+
working-directory: ./packages/${{ inputs.package}}
31+
run: npm publish
32+
shell: 'bash'
33+
env:
34+
# https://docs.github.com/en/actions/publishing-packages/publishing-nodejs-packages#publishing-packages-to-the-npm-registry
35+
NODE_AUTH_TOKEN: ${{ inputs.npm-token }}
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
# Release a tagged version of the '@elastic/ecs-helpers' package.
2+
name: release-ecs-helpers
3+
4+
on:
5+
push:
6+
tags:
7+
- ecs-helpers-v*.*.*
8+
9+
# 'id-token' perm needed for npm publishing with provenance (see
10+
# https://docs.npmjs.com/generating-provenance-statements#example-github-actions-workflow)
11+
permissions:
12+
contents: write
13+
pull-requests: read
14+
id-token: write
15+
16+
jobs:
17+
release:
18+
runs-on: ubuntu-latest
19+
steps:
20+
- uses: actions/checkout@v4
21+
with:
22+
fetch-depth: 0
23+
24+
- uses: ./.github/actions/npm-publish
25+
with:
26+
node-version: 'v18.20.2'
27+
npm-token: 'ecs-helpers'
28+
package: ${{ matrix.package }}
29+
30+
- name: Notify in Slack
31+
if: ${{ failure() }}
32+
uses: elastic/oblt-actions/slack/notify-result@v1
33+
with:
34+
bot-token: ${{ secrets.SLACK_BOT_TOKEN }}
35+
channel-id: "#apm-agent-node"
36+
message: '[${{ github.repository }}] Release `@elastic/ecs-helpers` *${{ github.ref_name }}*'

.github/workflows/release.yml

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
# Release a tagged version of the '@elastic/ecs-[...]-format' packages.
2+
name: release
3+
4+
on:
5+
push:
6+
tags:
7+
- v*.*.*
8+
9+
# 'id-token' perm needed for npm publishing with provenance (see
10+
# https://docs.npmjs.com/generating-provenance-statements#example-github-actions-workflow)
11+
permissions:
12+
contents: write
13+
pull-requests: read
14+
id-token: write
15+
16+
jobs:
17+
release:
18+
runs-on: ubuntu-latest
19+
strategy:
20+
matrix:
21+
package: ["ecs-morgan-format", "ecs-pino-format", "ecs-winston-format"]
22+
steps:
23+
- uses: actions/checkout@v4
24+
with:
25+
fetch-depth: 0
26+
27+
- uses: ./.github/actions/npm-publish
28+
with:
29+
node-version: 'v18.20.2'
30+
npm-token: ${{ secrets.NPM_TOKEN }}
31+
package: ${{ matrix.package }}
32+
33+
notify:
34+
runs-on: ubuntu-latest
35+
needs: [release]
36+
steps:
37+
- id: check
38+
uses: elastic/oblt-actions/check-dependent-jobs@v1
39+
with:
40+
jobs: ${{ toJSON(needs) }}
41+
- name: Notify in Slack
42+
# Only notify on failure, because on success the published GitHub
43+
# Release will result in a notification from the GitHub Slack app
44+
# (assuming '/github subscribe elastic/elastic-otel-node').
45+
if: ${{ steps.check.outputs.status == 'failure' }}
46+
uses: elastic/oblt-actions/slack/[email protected]
47+
with:
48+
bot-token: ${{ secrets.SLACK_BOT_TOKEN }}
49+
channel-id: "#apm-agent-node"
50+
message: '[${{ github.repository }}] Release `@elastic/ecs-[...]-format` packages *${{ github.ref_name }}*'

RELEASING.md

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,18 +22,28 @@ Assuming "x.y.z" is the release version:
2222
changes, then the commit/PR title should include mention of those
2323
things as well.)
2424
3. Get the PR approved and merged.
25-
4. Tag the commit as follows, in a git clone with the merged commit:
25+
26+
4. Working on the elastic repo (not a fork), tag the commit as follows:
2627
```
2728
git tag ecs-helpers-vx.y.z
2829
git push origin ecs-helpers-vx.y.z
2930
```
30-
5. Publish to npm, in a clean git clone:
31+
The GitHub Actions "release-ecs-helpers" workflow will handle the release
32+
steps -- including the `npm publish`. See the appropriate run at:
33+
https://github.com/elastic/ecs-logging-nodehs/actions/workflows/release-ecs-helpers.yml
34+
35+
5. The automation will do the rest.
36+
37+
If for any reason you need to run the publish the package manually then run the
38+
below command in a clean git clone:
3139
```
3240
git status # this should show "working tree clean"
41+
3342
cd packages/ecs-helpers
3443
npm publish
3544
```
3645
46+
3747
## Releasing `@elastic/ecs-[...]-format`
3848
3949
1. Choose the appropriate version number. All `ecs-*-format` packages currently
@@ -62,18 +72,23 @@ Assuming "x.y.z" is the release version:
6272
6373
3. Get the PR approved and merged.
6474
65-
4. Tag the commit as follows, in a git clone with the merged commit:
75+
4. Working on the elastic repo (not a fork), tag the commit as follows:
6676
```
6777
git tag vx.y.z
6878
git push origin vx.y.z
6979
```
80+
The GitHub Actions "release" workflow will handle the release
81+
steps -- including the `npm publish`. See the appropriate run at:
82+
https://github.com/elastic/ecs-logging-nodehs/actions/workflows/release.yml
83+
84+
5. The automation will do the rest.
7085
71-
5. Publish to npm, in a clean git clone:
86+
If for any reason you need to run the publish the package manually then run the
87+
below command in a clean git clone:
7288
```
7389
git status # this should show "working tree clean"
7490
7591
# for each of the packages being released:
7692
cd packages/ecs-...-format
7793
npm publish
7894
```
79-

packages/ecs-helpers/package.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@
22
"name": "@elastic/ecs-helpers",
33
"version": "2.1.1",
44
"description": "ecs-logging-nodejs helpers",
5+
"publishConfig": {
6+
"access": "public",
7+
"provenance": true
8+
},
59
"main": "lib/index.js",
610
"files": [
711
"lib"

packages/ecs-morgan-format/package.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@
22
"name": "@elastic/ecs-morgan-format",
33
"version": "1.5.1",
44
"description": "A formatter for the morgan logger compatible with Elastic Common Schema.",
5+
"publishConfig": {
6+
"access": "public",
7+
"provenance": true
8+
},
59
"main": "index.js",
610
"types": "index.d.ts",
711
"files": [

packages/ecs-pino-format/package.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@
22
"name": "@elastic/ecs-pino-format",
33
"version": "1.5.0",
44
"description": "A formatter for the pino logger compatible with Elastic Common Schema.",
5+
"publishConfig": {
6+
"access": "public",
7+
"provenance": true
8+
},
59
"main": "index.js",
610
"files": [
711
"index.js",

packages/ecs-winston-format/package.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@
22
"name": "@elastic/ecs-winston-format",
33
"version": "1.5.3",
44
"description": "A formatter for the winston logger compatible with Elastic Common Schema.",
5+
"publishConfig": {
6+
"access": "public",
7+
"provenance": true
8+
},
59
"main": "index.js",
610
"types": "index.d.ts",
711
"files": [

0 commit comments

Comments
 (0)