Skip to content

Commit

Permalink
f
Browse files Browse the repository at this point in the history
  • Loading branch information
emosbaugh committed Sep 7, 2024
1 parent b7ced86 commit 2ef6d28
Show file tree
Hide file tree
Showing 2 changed files with 146 additions and 57 deletions.
198 changes: 142 additions & 56 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -96,14 +96,13 @@ jobs:
name: buildtools
path: output/bin/buildtools

build:
build-current:
name: Build
runs-on: ubuntu-latest
needs:
- git-sha
outputs:
k0s_version: ${{ steps.export.outputs.k0s_version }}
k0s_version_previous: ${{ steps.export.outputs.k0s_version_previous }}
steps:
- name: Checkout
uses: actions/checkout@v4
Expand All @@ -127,70 +126,154 @@ jobs:
go-version-file: go.mod
cache-dependency-path: "**/*.sum"

- name: Export env vars
- name: Build
env:
RELEASE_YAML_DIR: e2e/kots-release-install
S3_BUCKET: "dev-embedded-cluster-bin"
AWS_ACCESS_KEY_ID: ${{ secrets.DEV_EMBEDDED_CLUSTER_UPLOAD_IAM_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.DEV_EMBEDDED_CLUSTER_UPLOAD_IAM_SECRET }}
AWS_REGION: "us-east-1"
USE_CHAINGUARD: "1"
DO_RELEASE: "0"
run: |
echo "K0S_VERSION=$(make print-K0S_VERSION)" >> $GITHUB_ENV
echo "EC_VERSION=$(git describe --tags --match='[0-9]*.[0-9]*.[0-9]*')" >> $GITHUB_ENV
echo "SHORT_SHA=dev-${{ needs.git-sha.outputs.git_sha }}" >> $GITHUB_ENV
echo "APP_VERSION=appver-dev-${{ needs.git-sha.outputs.git_sha }}" >> $GITHUB_ENV
export K0S_VERSION=$(make print-K0S_VERSION)
export EC_VERSION=$(git describe --tags --match='[0-9]*.[0-9]*.[0-9]*')
export SHORT_SHA=dev-${{ needs.git-sha.outputs.git_sha }}
export APP_VERSION=appver-dev-${{ needs.git-sha.outputs.git_sha }}
./scripts/dev-build.sh
- name: Build LAM and Operator
- name: Upload release
uses: actions/upload-artifact@v4
with:
name: current-release
path: |
output/bin/embedded-cluster
output/bin/embedded-cluster-original
output/bin/embedded-cluster-release-builder
- name: Export K0s Version
id: export
run: |
./scripts/ci-build-deps.sh
cp "local-artifact-mirror/build/image-$EC_VERSION" "local-artifact-mirror/build/image-$EC_VERSION-previous-k0s"
cp "local-artifact-mirror/build/image-$EC_VERSION" "local-artifact-mirror/build/image-$EC_VERSION-upgrade"
cp "operator/build/image-$EC_VERSION" "operator/build/image-$EC_VERSION-previous-k0s"
cp "operator/build/image-$EC_VERSION" "operator/build/image-$EC_VERSION-upgrade"
cp "operator/build/chart-$EC_VERSION" "operator/build/chart-$EC_VERSION-previous-k0s"
cp "operator/build/chart-$EC_VERSION" "operator/build/chart-$EC_VERSION-upgrade"
- name: Build previous k0s release
K0S_VERSION="$(make print-K0S_VERSION)"
echo "K0S_VERSION=\"$K0S_VERSION\""
echo "k0s_version=$K0S_VERSION" >> "$GITHUB_OUTPUT"
build-previous-k0s:
name: Build Previous K0s
runs-on: ubuntu-latest
needs:
- git-sha
outputs:
k0s_version: ${{ steps.export.outputs.k0s_version }}
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Cache Melange
uses: actions/cache@v4
with:
path: |
local-artifact-mirror/cache/.melange-cache
operator/cache/.melange-cache
key: melange-cache

- name: Setup Melange
uses: chainguard-dev/actions/setup-melange@main

- name: Setup Go
uses: actions/setup-go@v5
with:
go-version-file: go.mod
cache-dependency-path: "**/*.sum"

- name: Build
env:
RELEASE_YAML_DIR: e2e/kots-release-install
S3_BUCKET: "dev-embedded-cluster-bin"
AWS_ACCESS_KEY_ID: ${{ secrets.DEV_EMBEDDED_CLUSTER_UPLOAD_IAM_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.DEV_EMBEDDED_CLUSTER_UPLOAD_IAM_SECRET }}
AWS_REGION: "us-east-1"
USE_CHAINGUARD: "1"
DO_RELEASE: "0"
run: |
export EC_VERSION="${EC_VERSION}-previous-k0s"
export K0S_VERSION=$(make print-PREVIOUS_K0S_VERSION)
./scripts/ci-build.sh
mv output/bin/embedded-cluster output/bin/embedded-cluster-previous-k0s
mv build/embedded-cluster-linux-amd64.tgz build/embedded-cluster-linux-amd64-previous-k0s.tgz
mv build/metadata.json build/metadata-previous-k0s.json
export EC_VERSION=$(git describe --tags --match='[0-9]*.[0-9]*.[0-9]*')-previous-k0s
export APP_VERSION=appver-dev-${{ needs.git-sha.outputs.git_sha }}-previous-k0s
- name: Build upgrade release
run: |
export EC_VERSION="${EC_VERSION}-upgrade"
./scripts/ci-build.sh
mv output/bin/embedded-cluster output/bin/embedded-cluster-upgrade
mv build/embedded-cluster-linux-amd64.tgz build/embedded-cluster-linux-amd64-upgrade.tgz
mv build/metadata.json build/metadata-upgrade.json
./scripts/dev-build.sh
- name: Build release
run: |
./scripts/ci-build.sh
cp output/bin/embedded-cluster output/bin/embedded-cluster-original
- name: Upload release
uses: actions/upload-artifact@v4
with:
name: previous-k0s-release
path: |
output/bin/embedded-cluster
output/bin/embedded-cluster-original
output/bin/embedded-cluster-release-builder
- name: Build CI binary
- name: Export K0s Version
id: export
run: |
./scripts/ci-embed-release.sh EC_BINARY=output/bin/embedded-cluster-original
# this is done after the metadata.json is generated so as to not include additional charts
./scripts/ci-embed-release.sh EC_BINARY=output/bin/embedded-cluster-previous-k0s
K0S_VERSION="$(make print-PREVIOUS_K0S_VERSION)"
echo "K0S_VERSION=\"$K0S_VERSION\""
echo "k0s_version=$K0S_VERSION" >> "$GITHUB_OUTPUT"
build-upgrade:
name: Build Upgrade
runs-on: ubuntu-latest
needs:
- git-sha
outputs:
k0s_version: ${{ steps.export.outputs.k0s_version }}
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Cache Melange
uses: actions/cache@v4
with:
path: |
local-artifact-mirror/cache/.melange-cache
operator/cache/.melange-cache
key: melange-cache

- name: Setup Melange
uses: chainguard-dev/actions/setup-melange@main

- name: Setup Go
uses: actions/setup-go@v5
with:
go-version-file: go.mod
cache-dependency-path: "**/*.sum"

- name: Cache files for integration test
- name: Build
env:
RELEASE_YAML_DIR: e2e/kots-release-upgrade
S3_BUCKET: "dev-embedded-cluster-bin"
AWS_ACCESS_KEY_ID: ${{ secrets.DEV_EMBEDDED_CLUSTER_UPLOAD_IAM_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.DEV_EMBEDDED_CLUSTER_UPLOAD_IAM_SECRET }}
AWS_REGION: "us-east-1"
USE_CHAINGUARD: "1"
DO_RELEASE: "0"
run: |
./scripts/cache-files.sh
./scripts/create-upgrade-release.sh
./scripts/create-previous-k0s-release.sh
export K0S_VERSION=$(make print-K0S_VERSION)
export EC_VERSION=$(git describe --tags --match='[0-9]*.[0-9]*.[0-9]*')-upgrade
export APP_VERSION=appver-dev-${{ needs.git-sha.outputs.git_sha }}-upgrade
./scripts/dev-build.sh
- name: Upload release
uses: actions/upload-artifact@v4
with:
name: embedded-release
name: upgrade-release
path: |
output/bin/embedded-cluster
output/bin/embedded-cluster-original
output/bin/embedded-cluster-previous-k0s
output/bin/embedded-cluster-release-builder
- name: Export K0s Version
Expand All @@ -199,14 +282,13 @@ jobs:
K0S_VERSION="$(make print-K0S_VERSION)"
echo "K0S_VERSION=\"$K0S_VERSION\""
echo "k0s_version=$K0S_VERSION" >> "$GITHUB_OUTPUT"
PREVIOUS_K0S_VERSION="$(make print-PREVIOUS_K0S_VERSION)"
echo "PREVIOUS_K0S_VERSION=\"$PREVIOUS_K0S_VERSION\""
echo "k0s_version_previous=$PREVIOUS_K0S_VERSION" >> "$GITHUB_OUTPUT"
check-images:
name: Check Images
runs-on: ubuntu-latest
needs: [buildtools, build]
needs:
- buildtools
- build-current
steps:
- name: Checkout
uses: actions/checkout@v4
Expand All @@ -218,7 +300,7 @@ jobs:
- name: Download embedded-cluster artifact
uses: actions/download-artifact@v4
with:
name: embedded-release
name: current-release
path: output/bin
- name: Check for missing images
run: |
Expand All @@ -245,7 +327,9 @@ jobs:
pull-requests: write
needs:
- git-sha
- build
- build-current
- build-previous-k0s
- build-upgrade
steps:
- name: Checkout
uses: actions/checkout@v4
Expand Down Expand Up @@ -348,7 +432,7 @@ jobs:
e2e-docker:
runs-on: ubuntu-latest
needs:
- build
- build-current
strategy:
fail-fast: false
matrix:
Expand All @@ -360,7 +444,7 @@ jobs:
- name: Download binary
uses: actions/download-artifact@v4
with:
name: embedded-release
name: current-release
path: output/bin
- name: Setup Go
uses: actions/setup-go@v5
Expand All @@ -379,7 +463,9 @@ jobs:
e2e:
runs-on: ${{ matrix.runner || 'ubuntu-latest' }}
needs:
- build
- build-current
- build-previous-k0s
- build-upgrade
- release-app
strategy:
fail-fast: false
Expand Down Expand Up @@ -437,10 +523,10 @@ jobs:
steps:
- name: Checkout
uses: actions/checkout@v4
- name: download binary
- name: Download current binary
uses: actions/download-artifact@v4
with:
name: embedded-release
name: current-release
path: output/bin

- uses: ./.github/actions/e2e
Expand All @@ -455,8 +541,8 @@ jobs:
license: ${{ secrets.STAGING_EMBEDDED_CLUSTER_LICENSE }}
dr-aws-access-key-id: ${{ secrets.TESTIM_AWS_ACCESS_KEY_ID }}
dr-aws-secret-access-key: ${{ secrets.TESTIM_AWS_SECRET_ACCESS_KEY }}
k0s-version: ${{ needs.build.outputs.k0s_version }}
k0s-version-previous: ${{ needs.build.outputs.k0s_version_previous }}
k0s-version: ${{ needs.build-current.outputs.k0s_version }}
k0s-version-previous: ${{ needs.build-previous-k0s.outputs.k0s_version }}

# this job will validate that all the tests passed
# it is used for the github branch protection rule
Expand Down
5 changes: 4 additions & 1 deletion scripts/dev-build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ REPLICATED_API_ORIGIN=${REPLICATED_API_ORIGIN:-https://api.staging.replicated.co

ARCH=${ARCH:-amd64}
USE_CHAINGUARD=${USE_CHAINGUARD:-0}
DO_RELEASE=${DO_RELEASE:-1}

require REPLICATED_APP "${REPLICATED_APP:-}"
require REPLICATED_API_TOKEN "${REPLICATED_API_TOKEN:-}"
Expand All @@ -37,7 +38,9 @@ function build() {
./scripts/ci-build.sh
./scripts/ci-embed-release.sh
./scripts/cache-files.sh
./scripts/ci-release-app.sh
if [ "$DO_RELEASE" == "1" ]; then
./scripts/ci-release-app.sh
fi
}

function clean() {
Expand Down

0 comments on commit 2ef6d28

Please sign in to comment.