From 26c6943ee4ff904fc03fa1fc7761e2268e605d13 Mon Sep 17 00:00:00 2001 From: Bob Date: Mon, 1 Feb 2021 19:07:00 +0100 Subject: [PATCH] [ci] - Add github action (#26) --- .github/workflows/dd-build.yml | 116 +++++++++++++++++++++++++++++++++ 1 file changed, 116 insertions(+) create mode 100644 .github/workflows/dd-build.yml diff --git a/.github/workflows/dd-build.yml b/.github/workflows/dd-build.yml new file mode 100644 index 0000000000000..bafef7f785fc7 --- /dev/null +++ b/.github/workflows/dd-build.yml @@ -0,0 +1,116 @@ +name: Build and Push k8s Release + +on: + push: + # Sequence of patterns matched against refs/heads + tags: + # Push events on datadog tags + - "*-dd*" +jobs: + build: + runs-on: ubuntu-latest + strategy: + matrix: + platform: ["linux/arm64","linux/amd64"] + steps: + - uses: actions/checkout@v2 + with: + fetch-depth: 0 + - name: Set up Go + uses: actions/setup-go@v2 + with: + go-version: 1.15 + - name: Build + env: + KUBE_BUILD_PLATFORMS: ${{ matrix.platform }} + KUBE_RELEASE_RUN_TESTS: n + run: make quick-release KUBE_BUILD_PLATFORMS=$KUBE_BUILD_PLATFORMS + - name: Calculate checksums + id: calculate_checksums + shell: bash + working-directory: _output/release-tars + env: + KUBE_BUILD_PLATFORM: ${{ matrix.platform }} + run: | + TARGET_PLATFORM="${KUBE_BUILD_PLATFORM/\//-}" + for TARGET_FILE in *"${TARGET_PLATFORM}".tar.gz + do + sha256sum "$TARGET_FILE" > "${TARGET_FILE}.sha256sum" + done + - uses: actions/upload-artifact@v2 + with: + name: k8s_output + path: _output/release-tars + release: + runs-on: ubuntu-latest + needs: build + outputs: + upload_url: ${{ steps.create_release_branch.outputs.upload_url }}${{ steps.create_release_tags.outputs.upload_url }} + steps: + - name: Extract branch name + shell: bash + run: echo "##[set-output name=branch;]$(echo ${GITHUB_REF#refs/heads/})" + id: extract_branch + env: + GITHUB_REF: ${{ github.ref }} + if: startsWith(github.ref, 'refs/heads/') + - name: Create Release for Branch + id: create_release_branch + uses: actions/create-release@v1 + if: startsWith(github.ref, 'refs/heads/') + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + tag_name: branch@${{ steps.extract_branch.outputs.branch }} + release_name: branch@${{ steps.extract_branch.outputs.branch }} + draft: false + prerelease: false + + - name: Extract tags name + shell: bash + run: echo "##[set-output name=tags;]$(echo ${GITHUB_REF#refs/tags/})" + id: extract_tags + env: + GITHUB_REF: ${{ github.ref }} + if: startsWith(github.ref, 'refs/tags/') + - name: Create Release for Tags + id: create_release_tags + uses: actions/create-release@v1 + if: ${{ startsWith(github.ref, 'refs/tags/') }} + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + tag_name: ${{ steps.extract_tags.outputs.tags }} + release_name: ${{ steps.extract_tags.outputs.tags }} + draft: false + prerelease: false + releaseassetsarm: + runs-on: ubuntu-latest + needs: release + strategy: + matrix: + assets: [ + "kubernetes-client", + "kubernetes-node", + "kubernetes-server" + ] + platform: ["linux-arm64","linux-amd64"] + extension: ["tar.gz", "tar.gz.sha256sum"] + steps: + - uses: actions/download-artifact@v2 + with: + name: k8s_output + path: _output/release-tars + - name: Display structure of downloaded files + run: ls -R + working-directory: _output + - name: Upload Release Asset + id: upload-release-asset + uses: actions/upload-release-asset@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + upload_url: ${{ needs.release.outputs.upload_url }} + asset_path: ./_output/release-tars/${{ matrix.assets }}-${{ matrix.platform }}.${{ matrix.extension}} + asset_name: ${{ matrix.assets }}-${{ matrix.platform }}.${{ matrix.extension }} + asset_content_type: application/tar+gzip