# # This file is a mostly a concatenation of `kind_integration.yml` and # `cloud_integration.yml`, specifically for release. Once GitHub Actions # supports YAML anchors, we should be able to share most of the content # between these files: # https://github.community/t5/GitHub-Actions/Support-for-YAML-anchors/m-p/30336 # name: Release on: push: tags: - "*" env: GH_ANNOTATION: true jobs: # todo: Keep in sync with `cloud_integration.yml` docker_build: name: Docker build runs-on: ubuntu-18.04 steps: - name: Checkout code # actions/checkout@v2 uses: actions/checkout@722adc6 - name: Setup SSH config for Packet run: | mkdir -p ~/.ssh/ touch ~/.ssh/id && chmod 600 ~/.ssh/id echo "${{ secrets.DOCKER_SSH_CONFIG }}" > ~/.ssh/config echo "${{ secrets.DOCKER_PRIVATE_KEY }}" > ~/.ssh/id echo "${{ secrets.DOCKER_KNOWN_HOSTS }}" > ~/.ssh/known_hosts ssh linkerd-docker docker version - name: Build docker images env: DOCKER_HOST: ssh://linkerd-docker DOCKER_TRACE: 1 run: | export PATH="`pwd`/bin:$PATH" bin/docker-build # todo: Keep in sync with `cloud_integration.yml` docker_push: name: Docker push runs-on: ubuntu-18.04 needs: [docker_build] steps: - name: Checkout code # actions/checkout@v2 uses: actions/checkout@722adc6 - name: Set environment variables from scripts run: | . bin/_tag.sh echo ::set-env name=TAG::$(CI_FORCE_CLEAN=1 bin/root-tag) - name: Configure gcloud # linkerd/linkerd2-action-gcloud@v1.0.1 uses: linkerd/linkerd2-action-gcloud@308c4df with: cloud_sdk_service_account_key: ${{ secrets.CLOUD_SDK_SERVICE_ACCOUNT_KEY }} gcp_project: ${{ secrets.GCP_PROJECT }} gcp_zone: ${{ secrets.GCP_ZONE }} - name: Docker SSH setup run: | mkdir -p ~/.ssh/ touch ~/.ssh/id && chmod 600 ~/.ssh/id echo "${{ secrets.DOCKER_SSH_CONFIG }}" > ~/.ssh/config echo "${{ secrets.DOCKER_PRIVATE_KEY }}" > ~/.ssh/id echo "${{ secrets.DOCKER_KNOWN_HOSTS }}" > ~/.ssh/known_hosts ssh linkerd-docker docker version - name: Push docker images to registry env: DOCKER_HOST: ssh://linkerd-docker run: | export PATH="`pwd`/bin:$PATH" bin/docker-push-deps bin/docker-push $TAG bin/docker-retag-all $TAG master bin/docker-push master # todo: Keep in sync with `kind_integration.yml` kind_integration_tests: strategy: matrix: integration_test: [deep, upgrade, helm, helm_upgrade, uninstall, custom_domain, external_issuer] needs: [docker_build] name: Integration tests (${{ matrix.integration_test }}) runs-on: ubuntu-18.04 steps: - name: Checkout code # actions/checkout@v2 uses: actions/checkout@722adc6 - name: Try to load cached Go modules # actions/cache@v1.1.2 uses: actions/cache@70655ec with: path: ~/go/pkg/mod key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }} restore-keys: | ${{ runner.os }}-go- - name: Set environment variables from scripts run: | . bin/_tag.sh echo ::set-env name=TAG::$(CI_FORCE_CLEAN=1 bin/root-tag) . bin/_docker.sh echo ::set-env name=DOCKER_REGISTRY::$DOCKER_REGISTRY - name: Setup SSH config for Packet run: | mkdir -p ~/.ssh/ touch ~/.ssh/id && chmod 600 ~/.ssh/id echo "${{ secrets.DOCKER_SSH_CONFIG }}" > ~/.ssh/config echo "${{ secrets.DOCKER_PRIVATE_KEY }}" > ~/.ssh/id echo "${{ secrets.DOCKER_KNOWN_HOSTS }}" > ~/.ssh/known_hosts - name: Load cli-bin image into local docker images run: | # `docker load` only accepts input from STDIN, so pipe the image # archive into the command. # # In order to pipe the image archive, set `DOCKER_HOST` for a single # command and `docker save` the CLI image from the Packet host. DOCKER_HOST=ssh://linkerd-docker docker save "$DOCKER_REGISTRY/cli-bin:$TAG" | docker load - name: Install CLI run: | # Copy the CLI out of the local cli-bin container. container_id=$(docker create "$DOCKER_REGISTRY/cli-bin:$TAG") docker cp $container_id:/out/linkerd-linux $HOME/.linkerd # Validate the CLI version matches the current build tag. [[ "$TAG" == "$($HOME/.linkerd version --short --client)" ]] - name: Setup default KinD cluster if: matrix.integration_test != 'custom_domain' # engineerd/setup-kind@v0.3.0 uses: engineerd/setup-kind@d0e9be1 with: version: "v0.8.1" - name: Setup custom_domain KinD cluster if: matrix.integration_test == 'custom_domain' # engineerd/setup-kind@v0.3.0 uses: engineerd/setup-kind@d0e9be1 with: config: test/testdata/custom_cluster_domain_config.yaml version: "v0.8.1" - name: Load image archives into the local KinD cluster env: PROXY_INIT_IMAGE_NAME: gcr.io/linkerd-io/proxy-init:v1.3.1 PROMETHEUS_IMAGE_NAME: prom/prometheus:v2.15.2 run: | # Fetch images from the Packet host and load them into the local KinD cluster bin/kind-load --images --images-host ssh://linkerd-docker # Load proxy-init and prometheus images into KinD while it is # available. Allow these commands to fail since they will be cached # for the next run. kind load image-archive <(DOCKER_HOST=ssh://linkerd-docker docker save $PROXY_INIT_IMAGE_NAME) 2>&1 || true kind load image-archive <(DOCKER_HOST=ssh://linkerd-docker docker save $PROMETHEUS_IMAGE_NAME) 2>&1 || true - name: Run integration tests run: | # Export `init_test_run` and `*_integration_tests` into the # environment. . bin/_test-run.sh init_test_run $HOME/.linkerd ${{ matrix.integration_test }}_integration_tests # todo: Keep in sync with `cloud_integration.yml` cloud_integration_tests: name: Cloud integration tests runs-on: ubuntu-18.04 needs: [docker_push] steps: - name: Checkout code # actions/checkout@v2 uses: actions/checkout@722adc6 - name: Try to load cached Go modules # actions/cache@v1.1.2 uses: actions/cache@70655ec with: path: ~/go/pkg/mod key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }} restore-keys: | ${{ runner.os }}-go- - name: Install linkerd CLI id: install_cli run: | TAG="$(CI_FORCE_CLEAN=1 bin/root-tag)" image="gcr.io/linkerd-io/cli-bin:$TAG" id=$(bin/docker create $image) bin/docker cp "$id:/out/linkerd-linux" "$HOME/.linkerd" $HOME/.linkerd version --client # validate CLI version matches the repo [[ "$TAG" == "$($HOME/.linkerd version --short --client)" ]] echo "Installed Linkerd CLI version: $TAG" echo "::set-output name=tag::$TAG" - name: Create GKE cluster # linkerd/linkerd2-action-gcloud@v1.0.1 uses: linkerd/linkerd2-action-gcloud@308c4df with: cloud_sdk_service_account_key: ${{ secrets.CLOUD_SDK_SERVICE_ACCOUNT_KEY }} gcp_project: ${{ secrets.GCP_PROJECT }} gcp_zone: ${{ secrets.GCP_ZONE }} preemptible: false create: true name: testing-${{ steps.install_cli.outputs.tag }}-${{ github.run_id }} - name: Run integration tests env: GITCOOKIE_SH: ${{ secrets.GITCOOKIE_SH }} run: | export PATH="`pwd`/bin:$PATH" echo "$GITCOOKIE_SH" | bash version="$($HOME/.linkerd version --client --short | tr -cd '[:alnum:]-')" bin/test-run $HOME/.linkerd - name: CNI tests run: | export TAG="$($HOME/.linkerd version --client --short)" go test -cover -race -v -mod=readonly ./cni-plugin/test -integration-tests gh_release: name: Create GH release if: startsWith(github.ref, 'refs/tags/stable') || startsWith(github.ref, 'refs/tags/edge') runs-on: ubuntu-18.04 needs: [kind_integration_tests, cloud_integration_tests] steps: - name: Checkout code # actions/checkout@v2 uses: actions/checkout@722adc6 - name: Set environment variables from scripts run: | . bin/_tag.sh . bin/_release.sh echo ::set-env name=TAG::$(CI_FORCE_CLEAN=1 bin/root-tag) extract_release_notes NOTES.md - name: Pull CLI binaries run : bin/docker-pull-binaries $TAG - name: Create release id: create_release # softprops/action-gh-release@v1 uses: softprops/action-gh-release@91409e7 env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} with: draft: false prelease: false body_path: NOTES.md files: | ./target/release/linkerd2-cli-*-darwin ./target/release/linkerd2-cli-*-darwin.sha256 ./target/release/linkerd2-cli-*-linux ./target/release/linkerd2-cli-*-linux.sha256 ./target/release/linkerd2-cli-*-windows.exe ./target/release/linkerd2-cli-*-windows.exe.sha256 website_publish: name: Linkerd website publish if: startsWith(github.ref, 'refs/tags/stable') || startsWith(github.ref, 'refs/tags/edge') runs-on: ubuntu-18.04 needs: [gh_release] steps: - name: Create linkerd/website repository dispatch event # peter-evans/repository-dispatch@v1 uses: peter-evans/repository-dispatch@0ae1c4b with: token: ${{ secrets.RELEASE_TOKEN }} repository: linkerd/website event-type: release website_publish_check: name: Linkerd website publish check if: startsWith(github.ref, 'refs/tags/stable') || startsWith(github.ref, 'refs/tags/edge') runs-on: ubuntu-18.04 needs: [website_publish] steps: - name: Checkout code # actions/checkout@v2 uses: actions/checkout@722adc6 - name: Set environment variables from scripts run: | . bin/_tag.sh echo ::set-env name=TAG::$(CI_FORCE_CLEAN=1 bin/root-tag) - name: Set install target for stable if: startsWith(github.ref, 'refs/tags/stable') run: echo ::set-env name=INSTALL::install - name: Set install target for edge if: startsWith(github.ref, 'refs/tags/edge') run: echo ::set-env name=INSTALL::install-edge - name: Check published version run: | until RES=$(curl -sL https://run.linkerd.io/$INSTALL | grep "LINKERD2_VERSION=\${LINKERD2_VERSION:-$TAG}") \ || (( count++ >= 10 )) do sleep 30 done if [[ -z $RES ]]; then echo "::error::The version '$TAG' was NOT found published in the website" exit 1 fi chart_deploy: name: Helm chart deploy runs-on: ubuntu-18.04 needs: [gh_release] steps: - name: Checkout code # actions/checkout@v2 uses: actions/checkout@722adc6 - name: Configure gsutils # linkerd/linkerd2-action-gcloud@v1.0.1 uses: linkerd/linkerd2-action-gcloud@308c4df with: cloud_sdk_service_account_key: ${{ secrets.LINKERD_SITE_TOKEN }} gcp_project: ${{ secrets.LINKERD_SITE_PROJECT }} gcp_zone: ${{ secrets.LINKERD_SITE_ZONE }} - name: Edge Helm chart creation and upload if: startsWith(github.ref, 'refs/tags/edge') run: | mkdir -p target/helm gsutil cp gs://helm.linkerd.io/edge/index.yaml target/helm/index-pre.yaml bin/helm-build package gsutil rsync target/helm gs://helm.linkerd.io/edge - name: Stable Helm chart creation and upload if: startsWith(github.ref, 'refs/tags/stable') run: | mkdir -p target/helm gsutil cp gs://helm.linkerd.io/stable/index.yaml target/helm/index-pre.yaml bin/helm-build package gsutil rsync target/helm gs://helm.linkerd.io/stable