Skip to content

Commit 00a7d94

Browse files
nyodassergeychikd
authored andcommitted
[ci] - Add github action (#26)
Datadog: **NOT FROM UPSTREAM K8S**. From Datadog: #26 datadog:patch [ghactions] Upgrade to checkout v3 + don't pull history (#56) datadog:patch [.github] - Update modules Update modules to newer version. This should fix issue with permissions and deprecations warnings. Without this the github action was not able to create releases datadog:patch
1 parent 1ce7ed5 commit 00a7d94

File tree

1 file changed

+135
-0
lines changed

1 file changed

+135
-0
lines changed

.github/workflows/dd-build.yml

Lines changed: 135 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,135 @@
1+
name: Build and Push k8s Release
2+
3+
on:
4+
push:
5+
# Sequence of patterns matched against refs/heads
6+
tags:
7+
# Push events on datadog tags
8+
- "*-dd*"
9+
permissions: write-all
10+
jobs:
11+
build:
12+
runs-on: ubuntu-latest
13+
strategy:
14+
matrix:
15+
platform: ["linux/arm64","linux/amd64"]
16+
steps:
17+
- uses: actions/checkout@v4
18+
with:
19+
fetch-depth: 0
20+
- name: Set up Go
21+
uses: actions/setup-go@v5
22+
with:
23+
go-version: 1.22
24+
- name: Set env
25+
run: echo SANITIZED_TARGET_PLATFORM=${KUBE_BUILD_PLATFORM/\//-} >> $GITHUB_ENV
26+
env:
27+
KUBE_BUILD_PLATFORM: ${{ matrix.platform }}
28+
- name: Cleanup disk space
29+
run: |
30+
sudo rm -rf /usr/share/dotnet
31+
sudo rm -rf /opt/ghc
32+
sudo rm -rf /usr/local/share/boost
33+
sudo rm -rf "$AGENT_TOOLSDIRECTORY"
34+
sudo rm -rf /usr/local/.ghcup
35+
- name: Build
36+
env:
37+
KUBE_BUILD_PLATFORMS: ${{ matrix.platform }}
38+
KUBE_RELEASE_RUN_TESTS: n
39+
run: make quick-release KUBE_BUILD_PLATFORMS=$KUBE_BUILD_PLATFORMS
40+
- name: Calculate checksums
41+
id: calculate_checksums
42+
shell: bash
43+
working-directory: _output/release-tars
44+
env:
45+
KUBE_BUILD_PLATFORM: ${{ matrix.platform }}
46+
run: |
47+
TARGET_PLATFORM="${KUBE_BUILD_PLATFORM/\//-}"
48+
for TARGET_FILE in *"${TARGET_PLATFORM}".tar.gz
49+
do
50+
sha256sum "$TARGET_FILE" > "${TARGET_FILE}.sha256sum"
51+
done
52+
- uses: actions/upload-artifact@v4
53+
with:
54+
name: k8s_output_${{ env.SANITIZED_TARGET_PLATFORM }}
55+
path: _output/release-tars
56+
env:
57+
SANITIZED_TARGET_PLATFORM: ${{ env.SANITIZED_TARGET_PLATFORM }}
58+
release:
59+
permissions:
60+
contents: write
61+
runs-on: ubuntu-latest
62+
needs: build
63+
outputs:
64+
upload_url: ${{ steps.create_release_branch.outputs.upload_url }}${{ steps.create_release_tags.outputs.upload_url }}
65+
steps:
66+
- name: Extract branch name
67+
shell: bash
68+
run: echo "##[set-output name=branch;]$(echo ${GITHUB_REF#refs/heads/})"
69+
id: extract_branch
70+
env:
71+
GITHUB_REF: ${{ github.ref }}
72+
if: startsWith(github.ref, 'refs/heads/')
73+
- name: Create Release for Branch
74+
id: create_release_branch
75+
uses: softprops/action-gh-release@v2
76+
if: startsWith(github.ref, 'refs/heads/')
77+
env:
78+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
79+
with:
80+
token: ${{ secrets.GITHUB_TOKEN }}
81+
name: branch@${{ steps.extract_branch.outputs.branch }}
82+
tag_name: branch@${{ steps.extract_branch.outputs.branch }}
83+
draft: false
84+
prerelease: false
85+
- name: Extract tags name
86+
shell: bash
87+
run: echo "##[set-output name=tags;]$(echo ${GITHUB_REF#refs/tags/})"
88+
id: extract_tags
89+
env:
90+
GITHUB_REF: ${{ github.ref }}
91+
if: startsWith(github.ref, 'refs/tags/')
92+
- name: Create Release for Tags
93+
id: create_release_tags
94+
uses: softprops/action-gh-release@v2
95+
if: ${{ startsWith(github.ref, 'refs/tags/') }}
96+
env:
97+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
98+
with:
99+
token: ${{ secrets.GITHUB_TOKEN }}
100+
name: ${{ steps.extract_tags.outputs.tags }}
101+
tag_name: ${{ steps.extract_tags.outputs.tags }}
102+
release_name: ${{ steps.extract_tags.outputs.tags }}
103+
draft: false
104+
prerelease: false
105+
releaseassetsarm:
106+
runs-on: ubuntu-latest
107+
needs: release
108+
strategy:
109+
matrix:
110+
assets: [
111+
"kubernetes-client",
112+
"kubernetes-node",
113+
"kubernetes-server"
114+
]
115+
platform: ["linux-arm64","linux-amd64"]
116+
extension: ["tar.gz", "tar.gz.sha256sum"]
117+
steps:
118+
- uses: actions/download-artifact@v4
119+
with:
120+
name: k8s_output_${{ matrix.platform }}
121+
path: _output/release-tars
122+
github-token: ${{ secrets.GITHUB_TOKEN }}
123+
- name: Display structure of downloaded files
124+
run: ls -R
125+
working-directory: _output
126+
- name: Upload Release Asset
127+
id: upload-release-asset
128+
uses: actions/upload-release-asset@v1
129+
env:
130+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
131+
with:
132+
upload_url: ${{ needs.release.outputs.upload_url }}
133+
asset_path: ./_output/release-tars/${{ matrix.assets }}-${{ matrix.platform }}.${{ matrix.extension}}
134+
asset_name: ${{ matrix.assets }}-${{ matrix.platform }}.${{ matrix.extension }}
135+
asset_content_type: application/tar+gzip

0 commit comments

Comments
 (0)