-
Notifications
You must be signed in to change notification settings - Fork 225
145 lines (125 loc) · 4.95 KB
/
release.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
name: release
on:
push:
tags:
- v*.*.*
branches:
- main
permissions:
attestations: write
contents: write
id-token: write
pull-requests: read
jobs:
release:
runs-on: ubuntu-latest
env:
DOCKER_IMAGE_NAME: docker.elastic.co/observability/apm-agent-nodejs
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: actions/setup-node@v4
with:
node-version: 'v16.20.2'
# Setup a Docker "buildx" builder container, used by "build-push-action"
# below for multi-platform image builds. Notes on multi-platform images:
# https://github.com/elastic/apm-agent-nodejs/issues/4038#issuecomment-2130406402
- uses: docker/setup-buildx-action@v3
- name: Log in to the Elastic Container registry
uses: docker/login-action@9780b0c442fbb1117ed29e0efdff1e18412f7567 # v3.3.0
with:
registry: ${{ secrets.ELASTIC_DOCKER_REGISTRY }}
username: ${{ secrets.ELASTIC_DOCKER_USERNAME }}
password: ${{ secrets.ELASTIC_DOCKER_PASSWORD }}
- run: make -C .ci env
- run: make -C .ci dist
- name: Attest Lambda layer zip
uses: actions/attest-build-provenance@1c608d11d69870c2092266b3f9a6f3abbf17002c # v1.4.3
with:
subject-path: "${{ github.workspace }}/build/aws/elastic-apm-node-lambda-layer-*.zip"
- name: Extract metadata (tags, labels)
id: docker-meta
uses: docker/metadata-action@8e5442c4ef9f78752691e2d8f8d19755c6f78e81 # v5.5.1
with:
images: ${{ env.DOCKER_IMAGE_NAME }}
flavor: |
latest=auto
tags: |
# "1.2.3" and "latest" Docker tags on push of git tag "v1.2.3"
type=semver,pattern={{version}}
# "edge" Docker tag on git push to default branch
type=edge
- name: Build and Push Docker Image
id: docker-push
uses: docker/build-push-action@4f58ea79222b3b9dc2c8bbdd6debcef730109a75 # v6.9.0
with:
context: .
platforms: linux/amd64,linux/arm64
file: 'Dockerfile'
push: true
tags: ${{ steps.docker-meta.outputs.tags }}
labels: ${{ steps.docker-meta.outputs.labels }}
build-args: |
AGENT_DIR=/build/dist/nodejs
- name: Attest Docker image
uses: actions/attest-build-provenance@1c608d11d69870c2092266b3f9a6f3abbf17002c # v1.4.3
with:
subject-name: "${{ env.DOCKER_IMAGE_NAME }}"
subject-digest: ${{ steps.docker-push.outputs.digest }}
push-to-registry: true
- name: Extract metadata (tags, labels) (wolfi)
id: docker-meta-wolfi
uses: docker/metadata-action@8e5442c4ef9f78752691e2d8f8d19755c6f78e81 # v5.5.1
with:
images: ${{ env.DOCKER_IMAGE_NAME }}
flavor: |
latest=auto
suffix=-wolfi
tags: |
# "1.2.3" and "latest" Docker tags on push of git tag "v1.2.3"
type=semver,pattern={{version}}
# "edge" Docker tag on git push to default branch
type=edge
- name: Build and Push Docker Image (wolfi)
id: docker-push-wolfi
uses: docker/build-push-action@4f58ea79222b3b9dc2c8bbdd6debcef730109a75 # v6.9.0
with:
context: .
platforms: linux/amd64,linux/arm64
file: 'Dockerfile.wolfi'
push: true
tags: ${{ steps.docker-meta-wolfi.outputs.tags }}
labels: ${{ steps.docker-meta-wolfi.outputs.labels }}
build-args: |
AGENT_DIR=/build/dist/nodejs
- name: Attest Docker image (wolfi)
uses: actions/attest-build-provenance@1c608d11d69870c2092266b3f9a6f3abbf17002c # v1.4.3
with:
subject-name: "${{ env.DOCKER_IMAGE_NAME }}"
subject-digest: ${{ steps.docker-push-wolfi.outputs.digest }}
push-to-registry: true
- uses: elastic/oblt-actions/aws/[email protected]
with:
aws-account-id: "267093732750"
- name: Publish AWS lambda (only for tag release)
if: startsWith(github.ref, 'refs/tags')
run: make -C .ci publish-in-all-aws-regions create-arn-file
env:
GH_TOKEN: ${{ github.token }}
- name: create github release (only for tag release)
run: make -C .ci github-release
if: startsWith(github.ref, 'refs/tags')
env:
GH_TOKEN: ${{ github.token }}
- name: npm publish (only for tag release)
if: startsWith(github.ref, 'refs/tags')
run: |-
echo "//registry.npmjs.org/:_authToken=${{ secrets.NPM_TOKEN }}" > .npmrc
npm publish --provenance
- if: ${{ always() && startsWith(github.ref, 'refs/tags') }}
uses: elastic/oblt-actions/slack/notify-result@v1
with:
bot-token: ${{ secrets.SLACK_BOT_TOKEN }}
channel-id: "#apm-agent-node"
message: '[${{ github.repository }}] Release *${{ github.ref_name }}*'