From 131f6f39bb2f7e4227ec07c56cad22994aabf25f Mon Sep 17 00:00:00 2001 From: Scott Rigby Date: Tue, 14 Feb 2023 16:21:56 -0500 Subject: [PATCH 1/4] Convert remaining CircleCI config to GitHub Actions Signed-off-by: Scott Rigby --- .circleci/bootstrap.sh | 20 ------------- .circleci/config.yml | 43 --------------------------- .circleci/deploy.sh | 53 ---------------------------------- .github/workflows/build-pr.yml | 33 ++------------------- .github/workflows/release.yml | 32 +++++++++++++++++++- 5 files changed, 33 insertions(+), 148 deletions(-) delete mode 100755 .circleci/bootstrap.sh delete mode 100644 .circleci/config.yml delete mode 100755 .circleci/deploy.sh diff --git a/.circleci/bootstrap.sh b/.circleci/bootstrap.sh deleted file mode 100755 index 79d194077..000000000 --- a/.circleci/bootstrap.sh +++ /dev/null @@ -1,20 +0,0 @@ -#!/usr/bin/env bash - -# Copyright The Helm Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -set -euo pipefail - -curl -sSL https://github.com/golangci/golangci-lint/releases/download/v$GOLANGCI_LINT_VERSION/golangci-lint-$GOLANGCI_LINT_VERSION-linux-amd64.tar.gz | tar xz -sudo mv golangci-lint-$GOLANGCI_LINT_VERSION-linux-amd64/golangci-lint /usr/local/bin/golangci-lint -rm -rf golangci-lint-$GOLANGCI_LINT_VERSION-linux-amd64 diff --git a/.circleci/config.yml b/.circleci/config.yml deleted file mode 100644 index 36e137bfd..000000000 --- a/.circleci/config.yml +++ /dev/null @@ -1,43 +0,0 @@ ---- -version: 2 - -jobs: - build: - working_directory: ~/helm.sh/helm - docker: - - image: cimg/go:1.18 - - auth: - username: $DOCKER_USER - password: $DOCKER_PASS - - environment: - GOCACHE: "/tmp/go/cache" - GOLANGCI_LINT_VERSION: "1.46.2" - - steps: - - checkout - - run: - name: install test dependencies - command: .circleci/bootstrap.sh - - run: - name: test style - command: make test-style - - run: - name: test - command: make test-coverage - - run: - name: test build - command: make - - deploy: - name: deploy - command: .circleci/deploy.sh - -workflows: - version: 2 - build: - jobs: - - build: - filters: - tags: - only: /.*/ diff --git a/.circleci/deploy.sh b/.circleci/deploy.sh deleted file mode 100755 index c886d46ce..000000000 --- a/.circleci/deploy.sh +++ /dev/null @@ -1,53 +0,0 @@ -#!/usr/bin/env bash - -# Copyright The Helm Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -set -euo pipefail - -# Skip on pull request builds -if [[ -n "${CIRCLE_PR_NUMBER:-}" ]]; then - exit -fi - -: ${AZURE_STORAGE_CONNECTION_STRING:?"AZURE_STORAGE_CONNECTION_STRING environment variable is not set"} -: ${AZURE_STORAGE_CONTAINER_NAME:?"AZURE_STORAGE_CONTAINER_NAME environment variable is not set"} - -VERSION= -if [[ -n "${CIRCLE_TAG:-}" ]]; then - VERSION="${CIRCLE_TAG}" -elif [[ "${CIRCLE_BRANCH:-}" == "main" ]]; then - VERSION="canary" -else - echo "Skipping deploy step; this is neither a releasable branch or a tag" - exit -fi - -echo "Installing Azure CLI" -echo "deb [arch=amd64] https://packages.microsoft.com/repos/azure-cli/ jammy main" | sudo tee /etc/apt/sources.list.d/azure-cli.list -curl -L https://packages.microsoft.com/keys/microsoft.asc | sudo apt-key add -sudo apt install apt-transport-https -sudo apt update -sudo apt install azure-cli - - -echo "Building helm binaries" -make build-cross -make dist checksum VERSION="${VERSION}" - -echo "Pushing binaries to Azure" -if [[ "${VERSION}" == "canary" ]]; then - az storage blob upload-batch -s _dist/ -d "$AZURE_STORAGE_CONTAINER_NAME" --pattern 'helm-*' --connection-string "$AZURE_STORAGE_CONNECTION_STRING" --overwrite -else - az storage blob upload-batch -s _dist/ -d "$AZURE_STORAGE_CONTAINER_NAME" --pattern 'helm-*' --connection-string "$AZURE_STORAGE_CONNECTION_STRING" -fi diff --git a/.github/workflows/build-pr.yml b/.github/workflows/build-pr.yml index 6a9a81042..d8120efbc 100644 --- a/.github/workflows/build-pr.yml +++ b/.github/workflows/build-pr.yml @@ -3,9 +3,7 @@ on: pull_request: branches: - main - push: - branches: - - main + jobs: build: runs-on: ubuntu-latest @@ -31,31 +29,4 @@ jobs: - name: Run unit tests run: make test-coverage - name: Test build - run: make - - canary-release: - runs-on: ubuntu-latest - needs: build - if: ${{ github.event == 'push' && github.ref == 'refs/heads/main' && github.repository_owner == 'helm' }} - steps: - - name: Checkout source code - uses: actions/checkout@755da8c3cf115ac066823e79a1e1788f8940201b # pin@v3.2.0 - - - name: Setup Go - uses: actions/setup-go@6edd4406fa81c3da01a34fa6f6343087c207a568 # pin@3.5.0 - with: - go-version-file: go.mod - - - name: Build Helm Binaries - run: | - make build-cross - make dist checksum VERSION="canary" - - - name: Upload Binaries - uses: bacongobbler/azure-blob-storage-upload@50f7d898b7697e864130ea04c303ca38b5751c50 # pin@3.0.0 - with: - source_dir: _dist - container_name: ${{ secrets.AZURE_STORAGE_CONTAINER_NAME }} - connection_string: ${{ secrets.AZURE_STORAGE_CONNECTION_STRING }} - extra_args: '--pattern helm-*' - overwrite: 'true' + run: make test build diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 3e392a21d..3b77dcf4a 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -3,10 +3,13 @@ on: create: tags: - v* + push: + branches: + - main jobs: release: - if: ${{ github.repository_owner == 'helm'}} + if: ${{ startsWith(github.ref, 'refs/tags/v') && github.repository_owner == 'helm' }} runs-on: ubuntu-latest steps: - name: Checkout source code @@ -36,3 +39,30 @@ jobs: container_name: ${{ secrets.AZURE_STORAGE_CONTAINER_NAME }} connection_string: ${{ secrets.AZURE_STORAGE_CONNECTION_STRING }} extra_args: '--pattern helm-*' + + canary-release: + runs-on: ubuntu-latest + needs: build + if: ${{ github.ref == 'refs/heads/main' && github.repository_owner == 'helm' }} + steps: + - name: Checkout source code + uses: actions/checkout@755da8c3cf115ac066823e79a1e1788f8940201b # pin@v3.2.0 + + - name: Setup Go + uses: actions/setup-go@6edd4406fa81c3da01a34fa6f6343087c207a568 # pin@3.5.0 + with: + go-version-file: go.mod + + - name: Build Helm Binaries + run: | + make build-cross + make dist checksum VERSION="canary" + + - name: Upload Binaries + uses: bacongobbler/azure-blob-storage-upload@50f7d898b7697e864130ea04c303ca38b5751c50 # pin@3.0.0 + with: + source_dir: _dist + container_name: ${{ secrets.AZURE_STORAGE_CONTAINER_NAME }} + connection_string: ${{ secrets.AZURE_STORAGE_CONNECTION_STRING }} + extra_args: '--pattern helm-*' + overwrite: 'true' From c5dda0995bcce17e422886a140cdf9e2163a7706 Mon Sep 17 00:00:00 2001 From: Scott Rigby Date: Tue, 21 Feb 2023 00:40:58 -0500 Subject: [PATCH 2/4] Add why comments Signed-off-by: Scott Rigby --- .github/workflows/release.yml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 3b77dcf4a..96a06c73c 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -7,6 +7,11 @@ on: branches: - main +# Note the only differences between release and canary-release jobs are: +# - only canary passes --overwrite flag +# - the VERSION make variable passed to 'make dist checksum' is expected to +# be "canary" if the job is triggered by a push to "main" branch. If the +# job is triggered by a tag push, VERSION should be the tag ref. jobs: release: if: ${{ startsWith(github.ref, 'refs/tags/v') && github.repository_owner == 'helm' }} @@ -65,4 +70,5 @@ jobs: container_name: ${{ secrets.AZURE_STORAGE_CONTAINER_NAME }} connection_string: ${{ secrets.AZURE_STORAGE_CONNECTION_STRING }} extra_args: '--pattern helm-*' + # WARNING: this will overwrite existing blobs in your blob storage overwrite: 'true' From c8efe2086dd4126ccaf6bd6ec9b01dbbd7f65756 Mon Sep 17 00:00:00 2001 From: Scott Rigby Date: Tue, 21 Feb 2023 00:58:45 -0500 Subject: [PATCH 3/4] Remove check to run only in helm org Signed-off-by: Scott Rigby --- .github/workflows/release.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 96a06c73c..c7e45ff73 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -14,7 +14,7 @@ on: # job is triggered by a tag push, VERSION should be the tag ref. jobs: release: - if: ${{ startsWith(github.ref, 'refs/tags/v') && github.repository_owner == 'helm' }} + if: startsWith(github.ref, 'refs/tags/v') runs-on: ubuntu-latest steps: - name: Checkout source code @@ -48,7 +48,7 @@ jobs: canary-release: runs-on: ubuntu-latest needs: build - if: ${{ github.ref == 'refs/heads/main' && github.repository_owner == 'helm' }} + if: github.ref == 'refs/heads/main' steps: - name: Checkout source code uses: actions/checkout@755da8c3cf115ac066823e79a1e1788f8940201b # pin@v3.2.0 From b69646482a7ee1e269d80f61d8f0bb781a902965 Mon Sep 17 00:00:00 2001 From: Scott Rigby Date: Tue, 21 Feb 2023 01:00:58 -0500 Subject: [PATCH 4/4] Remove job dependency. Should have done when I moved job to new file Signed-off-by: Scott Rigby --- .github/workflows/release.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index c7e45ff73..7167f97f0 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -47,7 +47,6 @@ jobs: canary-release: runs-on: ubuntu-latest - needs: build if: github.ref == 'refs/heads/main' steps: - name: Checkout source code