-
Notifications
You must be signed in to change notification settings - Fork 4
203 lines (188 loc) · 6.96 KB
/
build_packages.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
# We use a single workflow to build all packages because github.run_number is
# specific to each workflow. This ensures that each package has an
# OTC_BUILD_NUMBER that is greater than previous runs which allows package
# upgrades from one build to the next.
name: 'Build packages'
# Sets the name of the CI run based on whether the run was triggered by a push
# or remotely with or without workflow_run_id set. The name used for push events
# is the full commit message as I have not been able to find a way to only show
# the commit title (first 72 characters of commit message) - Justin K.
run-name: >
${{
github.event.inputs.workflow_id != '' &&
format('Build for Remote Workflow: {0}', github.event.inputs.workflow_id)
||
github.event.inputs.otc_version != '' &&
github.event.inputs.otc_sumo_version != '' &&
format('Build for GitHub Release: {0}-sumo-{1}',
github.event.inputs.otc_version, github.event.inputs.otc_sumo_version)
||
github.event.head_commit.message
}}
on:
push:
branches:
- '**'
tags-ignore:
- '**'
pull_request:
workflow_dispatch:
inputs:
workflow_id:
description: |
Workflow Run ID from the SumoLogic/sumologic-otel-collector repository
to download artifacts from. The artifacts for the specified workflow
must contain an otelcol-sumo binary for each platform that packages
are being built for.
required: false
type: string
otc_version:
description: |
Version of otelcol-sumo to package in A.B.C format.
required: false
type: string
otc_sumo_version:
description: |
Sumo version of otelcol-sumo to package. E.g. the X in A.B.C-sumo-X.
required: false
type: string
release:
description: Publish release
type: boolean
require: false
default: false
jobs:
# Determines the latest version which will be used to fetch artifacts from a
# GitHub Release and as the version of the packages being built. This is
# skipped if the otc_version and otc_sumo_version inputs have been set.
determine_version:
runs-on: ubuntu-latest
name: Determine version
outputs:
otc_version: >-
${{
github.event.inputs.otc_version ||
steps.version-core.outputs.version
}}
otc_sumo_version: >-
${{
github.event.inputs.otc_sumo_version ||
steps.sumo-version.outputs.version
}}
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Output Remote Workflow URL
if: github.event.inputs.workflow_id != ''
run: echo ::notice title=Remote Workflow URL::https://github.com/SumoLogic/sumologic-otel-collector/actions/runs/${{ github.event.inputs.workflow_id }}
- name: Determine latest release
id: release
uses: ./ci/github-actions/get-latest-release
if: >
github.event.inputs.otc_version == '' &&
github.event.inputs.otc_sumo_version == ''
with:
token: ${{ github.token }}
owner: SumoLogic
repository: sumologic-otel-collector
- name: Determine version core from release
id: version-core
if: >
github.event.inputs.otc_version == '' &&
github.event.inputs.otc_sumo_version == ''
env:
VERSION_TAG: ${{ steps.release.outputs.tag_name }}
run: >
./ci/get_version.sh otc_version > /tmp/otc_version &&
cat /tmp/otc_version &&
echo "version=$(cat /tmp/otc_version)" >> $GITHUB_OUTPUT
- name: Determine sumo version from release
id: sumo-version
if: >
github.event.inputs.otc_version == '' &&
github.event.inputs.otc_sumo_version == ''
env:
VERSION_TAG: ${{ steps.release.outputs.tag_name }}
run: >
./ci/get_version.sh otc_sumo_version > /tmp/otc_sumo_version &&
cat /tmp/otc_sumo_version &&
echo "version=$(cat /tmp/otc_sumo_version)" >> $GITHUB_OUTPUT
# Builds a package for each target in the matrix. The target must be an
# existing file name (without extension) in the targets directory when
# build_tool is cmake.
build_packages:
name: ${{ matrix.target }}
uses: ./.github/workflows/_reusable_build_package.yml
needs:
- determine_version
with:
otc_version: ${{ needs.determine_version.outputs.otc_version }}
otc_sumo_version: ${{ needs.determine_version.outputs.otc_sumo_version }}
otc_build_number: ${{ github.run_number }}
cmake_target: ${{ matrix.target }}
workflow_id: ${{ github.event.inputs.workflow_id }}
runs_on: ${{ matrix.runs_on }}
goarch: ${{ matrix.goarch }}
package_arch: ${{ matrix.package_arch }}
build_tool: ${{ matrix.build_tool }}
secrets:
apple_developer_certificate_p12_base64: ${{ secrets.APPLE_DEVELOPER_CERTIFICATE_P12_BASE64 }}
apple_developer_certificate_password: ${{ secrets.APPLE_DEVELOPER_CERTIFICATE_PASSWORD }}
productbuild_identity_name: ${{ secrets.APPLE_DEVELOPER_CERTIFICATE_IDENTITY }}
gh_artifacts_token: ${{ secrets.GH_ARTIFACTS_TOKEN }}
strategy:
matrix:
include:
- target: otc_linux_amd64_deb
runs_on: ubuntu-latest
build_tool: cmake
- target: otc_linux_amd64_rpm
runs_on: ubuntu-latest
build_tool: cmake
- target: otc_linux_arm64_deb
runs_on: ubuntu-latest
build_tool: cmake
- target: otc_linux_arm64_rpm
runs_on: ubuntu-latest
build_tool: cmake
- target: otc_darwin_amd64_productbuild
runs_on: macos-latest
build_tool: cmake
- target: otc_darwin_arm64_productbuild
runs_on: macos-latest
build_tool: cmake
- target: otc_windows_amd64_wix
runs_on: windows-2019
goarch: amd64
package_arch: x64
build_tool: wix
publish_release:
name: Publish Release
runs-on: ubuntu-latest
needs:
- build_packages
- determine_version
permissions:
contents: write
if: github.event.inputs.release
steps:
- name: Download all packages stored as artifacts
uses: actions/download-artifact@v3
with:
path: artifacts/
- uses: ncipollo/release-action@v1
with:
name: v${{ needs.determine_version.outputs.otc_version }}-${{ github.run_number }}
commit: ${{ github.sha }}
tag: v${{ needs.determine_version.outputs.otc_version }}-${{ github.run_number }}
draft: true
prerelease: false
allowUpdates: true
omitBodyDuringUpdate: true
omitNameDuringUpdate: true
artifacts: "artifacts/*/*"
artifactErrorsFailBuild: true
replacesArtifacts: true
body: |
## v${{ needs.determine_version.outputs.otc_version }}-${{ github.run_number }}
**TODO**