-
Notifications
You must be signed in to change notification settings - Fork 209
207 lines (182 loc) · 7.94 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
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
name: release
on:
release:
types: [published]
permissions:
contents: write
issues: write
pull-requests: write
env:
NUGET_PACKAGES: ${{ github.workspace }}/.nuget/packages
JOB_URL: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}
SLACK_CHANNEL: "#apm-agent-dotnet"
jobs:
release:
runs-on: ubuntu-latest
env:
PREFIX_APM_AGENT: "build/output/ElasticApmAgent_"
PREFIX_APM_PROFILER: "build/output/elastic_apm_profiler_"
SUFFIX_APM_AGENT: ".zip"
SUFFIX_APM_PROFILER: "-linux-x64.zip"
DOCKER_IMAGE_NAME: "docker.elastic.co/observability/apm-agent-dotnet"
permissions:
attestations: write
contents: write
id-token: write
steps:
- uses: actions/checkout@v4
- name: Bootstrap Action Workspace
id: bootstrap
uses: ./.github/workflows/bootstrap
with:
rust: 'true'
- name: Package
run: ./build.sh pack
- name: Release to Nuget
run: .ci/linux/deploy.sh ${{ secrets.NUGET_API_KEY }} ${{ secrets.NUGET_API_URL }}
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@aa33708b10e362ff993539393ff100fa93ed6a27 # v3.5.0
- 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 }}
- 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}},value=${{ steps.bootstrap.outputs.agent-version }}
# "edge" Docker tag on git push to default branch
type=edge
- name: Build and Push Profiler Docker Image
id: docker-push
continue-on-error: true # continue for now until we see it working in action
uses: docker/build-push-action@5176d81f87c23d6fc96624dfdbcd9f3830bbe445 # v6.5.0
with:
cache-from: type=gha
cache-to: type=gha,mode=max
context: .
platforms: linux/amd64,linux/arm64
push: true
tags: ${{ steps.docker-meta.outputs.tags }}
labels: ${{ steps.docker-meta.outputs.labels }}
build-args: |
AGENT_ZIP_FILE=${{ env.PREFIX_APM_PROFILER }}${{ steps.bootstrap.outputs.agent-version }}${{ env.SUFFIX_APM_PROFILER }}
- name: Attest image
uses: actions/attest-build-provenance@5e9cb68e95676991667494a6a4e59b8a2f13e1d0 # v1.3.3
continue-on-error: true # continue for now until we see it working in action
with:
subject-name: ${{ env.DOCKER_IMAGE_NAME }}
subject-digest: ${{ steps.docker-push.outputs.digest }}
push-to-registry: true
- name: generate build provenance (APM Agent)
uses: actions/attest-build-provenance@5e9cb68e95676991667494a6a4e59b8a2f13e1d0 # v1.3.3
with:
subject-path: "${{ github.workspace }}/${{ env.PREFIX_APM_AGENT }}${{ steps.bootstrap.outputs.agent-version }}${{ env.SUFFIX_APM_AGENT }}"
- name: generate build provenance (APM Profiler)
uses: actions/attest-build-provenance@5e9cb68e95676991667494a6a4e59b8a2f13e1d0 # v1.3.3
with:
subject-path: "${{ github.workspace }}/${{ env.PREFIX_APM_PROFILER }}${{ steps.bootstrap.outputs.agent-version }}${{ env.SUFFIX_APM_PROFILER }}"
- name: Attach Profiler And Startup Hooks
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
gh release upload ${{ github.ref_name }} "${{ env.PREFIX_APM_AGENT }}${{ steps.bootstrap.outputs.agent-version }}${{ env.SUFFIX_APM_AGENT }}" "${{ env.PREFIX_APM_PROFILER }}${{ steps.bootstrap.outputs.agent-version }}${{ env.SUFFIX_APM_PROFILER }}"
- if: ${{ success() }}
uses: elastic/oblt-actions/slack/send@v1
continue-on-error: true #continue for now until we see it working in action
with:
bot-token: ${{ secrets.SLACK_BOT_TOKEN }}
channel-id: ${{ env.SLACK_CHANNEL }}
message: |
:large_green_circle: [${{ github.repository }}] Release *${{ github.ref_name }}* published.
Build: (<${{ env.JOB_URL }}|here>)
Release URL: (<https://github.com/elastic/apm-agent-dotnet/releases/tag/${{ github.ref_name }}|${{ github.ref_name }}>)
- if: ${{ failure() }}
uses: elastic/oblt-actions/slack/send@v1
continue-on-error: true #continue for now until we see it working in action
with:
bot-token: ${{ secrets.SLACK_BOT_TOKEN }}
channel-id: ${{ env.SLACK_CHANNEL }}
message: |
:large_yellow_circle: [${{ github.repository }}] Release *${{ github.ref_name }}* could not be published.
Build: (<${{ env.JOB_URL }}|here>)
release-windows:
runs-on: windows-2022
needs: [ 'release']
outputs:
agent-version: ${{ steps.bootstrap.outputs.agent-version }}
major-version: ${{ steps.bootstrap.outputs.major-version }}
env:
PREFIX_ZIP_FILE: "build/output/elastic_apm_profiler_"
SUFFIX_ZIP_FILE: "-win-x64.zip"
permissions:
attestations: write
contents: write
id-token: write
steps:
- uses: actions/checkout@v4
- name: Bootstrap Action Workspace
id: bootstrap
uses: ./.github/workflows/bootstrap
with:
rust: 'true'
- name: Build profiler
run: ./build.bat profiler-zip
- name: generate build provenance (APM Profiler)
uses: actions/attest-build-provenance@5e9cb68e95676991667494a6a4e59b8a2f13e1d0 # v1.3.3
with:
subject-path: "${{ github.workspace }}/${{ env.PREFIX_ZIP_FILE }}${{ steps.bootstrap.outputs.agent-version }}${{ env.SUFFIX_ZIP_FILE }}"
- name: Attach Profiler
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
gh release upload ${{ github.ref_name }} "${{ env.PREFIX_ZIP_FILE }}${{ steps.bootstrap.outputs.agent-version }}${{ env.SUFFIX_ZIP_FILE }}"
post-release:
needs: [ 'release-windows']
runs-on: ubuntu-latest
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GIT_TAG: v${{ needs.release-windows.outputs.agent-version }}
NEW_BRANCH: update/${{ needs.release-windows.outputs.agent-version }}
TARGET_BRANCH: ${{ needs.release-windows.outputs.major-version }}.x
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Setup git config
uses: elastic/apm-pipeline-library/.github/actions/setup-git@current
- name: Create GitHub Pull Request if minor release.
run: |
echo "as long as there is a major.x branch"
existed_in_local=$(git ls-remote --heads origin ${TARGET_BRANCH})
if [ -z "${existed_in_local}" ]; then
echo -e "::warning::Target branch '${TARGET_BRANCH}' does not exist."
exit 0
fi
git checkout $TARGET_BRANCH
git checkout -b ${NEW_BRANCH}
git format-patch -k --stdout ${TARGET_BRANCH}...origin/main -- docs CHANGELOG.asciidoc | git am -3 -k
git push origin ${NEW_BRANCH}
gh pr create \
--title "post-release: ${GIT_TAG}" \
--body "Generated automatically with ${JOB_URL}" \
--head "elastic:${NEW_BRANCH}" \
--base "$TARGET_BRANCH" \
--repo "${{ github.repository }}"
- name: Create branch if major release
run: |
echo "as long as there is no a major.x branch"
existed_in_local=$(git ls-remote --heads origin ${TARGET_BRANCH})
if [ -n "${existed_in_local}" ]; then
echo -e "::warning::Target branch '${TARGET_BRANCH}' does exist."
exit 0
fi
git branch -D $TARGET_BRANCH
git push origin $TARGET_BRANCH