diff --git a/.github/workflows/release-prod.yaml b/.github/workflows/release-prod.yaml index be62b6c3e7..b804d78692 100644 --- a/.github/workflows/release-prod.yaml +++ b/.github/workflows/release-prod.yaml @@ -212,6 +212,12 @@ jobs: mkdir -p build ./output/bin/embedded-cluster version metadata > build/metadata.json + - name: Upload binary artifact for metadata generation + uses: actions/upload-artifact@v6 + with: + name: embedded-cluster-linux-amd64 + path: output/bin/embedded-cluster + - name: Cache Staging Files env: S3_BUCKET: "tf-staging-embedded-cluster-bin" @@ -247,6 +253,72 @@ jobs: build/*.tgz build/metadata.json + generate-metadata: + runs-on: ubuntu-latest + needs: [get-tag, release] + strategy: + matrix: + arch: [amd64, arm64] + steps: + - uses: actions/checkout@v5 + + - name: Download AMD64 binary + uses: actions/download-artifact@v6 + with: + name: embedded-cluster-linux-amd64 + path: output/bin + + - name: Make binary executable + run: chmod +x output/bin/embedded-cluster + + - name: Generate ${{ matrix.arch }} metadata + run: | + mkdir -p build + CLUSTER_ARCH=${{ matrix.arch }} ./output/bin/embedded-cluster version metadata > build/metadata-${{ matrix.arch }}.json + + - name: Upload metadata artifact + uses: actions/upload-artifact@v6 + with: + name: metadata-${{ matrix.arch }} + path: build/metadata-${{ matrix.arch }}.json + + upload-metadata: + runs-on: ubuntu-latest + needs: [get-tag, generate-metadata] + strategy: + matrix: + arch: [amd64, arm64] + steps: + - uses: actions/checkout@v5 + + - name: Download metadata + uses: actions/download-artifact@v6 + with: + name: metadata-${{ matrix.arch }} + path: build + + - name: Upload to S3 + env: + EC_VERSION: ${{ needs.get-tag.outputs.tag-name }} + ARCH: ${{ matrix.arch }} + S3_BUCKET: "tf-staging-embedded-cluster-bin" + AWS_ACCESS_KEY_ID: ${{ secrets.STAGING_EMBEDDED_CLUSTER_UPLOAD_IAM_KEY_ID }} + AWS_SECRET_ACCESS_KEY: ${{ secrets.STAGING_EMBEDDED_CLUSTER_UPLOAD_IAM_SECRET }} + AWS_REGION: "us-east-1" + run: | + ./scripts/ci-upload-binaries.sh metadata + + - name: Upload to S3 (Prod) + env: + EC_VERSION: ${{ needs.get-tag.outputs.tag-name }} + ARCH: ${{ matrix.arch }} + S3_BUCKET: "tf-embedded-cluster-binaries" + AWS_ACCESS_KEY_ID: ${{ secrets.PROD_EMBEDDED_CLUSTER_UPLOAD_IAM_KEY_ID }} + AWS_SECRET_ACCESS_KEY: ${{ secrets.PROD_EMBEDDED_CLUSTER_UPLOAD_IAM_SECRET }} + AWS_REGION: "us-east-1" + run: | + ./scripts/ci-upload-binaries.sh metadata + find-previous-stable: name: Determine previous stable version runs-on: ubuntu-latest @@ -610,6 +682,7 @@ jobs: - e2e-docker - release - release-app + - upload-metadata if: ${{ !cancelled() }} steps: # https://docs.github.com/en/actions/learn-github-actions/contexts#needs-context @@ -619,6 +692,9 @@ jobs: - name: fail if e2e-docker job was not successful if: needs.e2e-docker.result != 'success' run: exit 1 + - name: fail if upload-metadata job was not successful + if: needs.upload-metadata.result != 'success' + run: exit 1 - name: succeed if everything else passed run: echo "Validation succeeded" diff --git a/kinds/types/release_metadata.go b/kinds/types/release_metadata.go index ac9b13394a..3cc5807bba 100644 --- a/kinds/types/release_metadata.go +++ b/kinds/types/release_metadata.go @@ -8,6 +8,7 @@ import ( // ReleaseMetadata holds the metadata about a specific release, including addons and // their versions. type ReleaseMetadata struct { + Architecture string `json:"architecture"` // "amd64" or "arm64" Versions map[string]string K0sSHA string K0sBinaryURL string diff --git a/pkg-new/metadata/metadata.go b/pkg-new/metadata/metadata.go index 9013e0ee5f..450be8f2bb 100644 --- a/pkg-new/metadata/metadata.go +++ b/pkg-new/metadata/metadata.go @@ -110,9 +110,10 @@ func GatherVersionMetadata(channelRelease *release.ChannelRelease) (*types.Relea } meta := types.ReleaseMetadata{ - Versions: versionsMap, - K0sSHA: sha, - Artifacts: artifacts, + Architecture: helpers.ClusterArch(), + Versions: versionsMap, + K0sSHA: sha, + Artifacts: artifacts, } chtconfig, repconfig, err := addons.GenerateChartConfigs(context.Background(), nil) diff --git a/scripts/ci-upload-binaries.sh b/scripts/ci-upload-binaries.sh index 375779f174..60951a1975 100755 --- a/scripts/ci-upload-binaries.sh +++ b/scripts/ci-upload-binaries.sh @@ -135,17 +135,23 @@ function kotsbin() { function metadata() { if [ -z "${EC_VERSION}" ]; then - echo "EC_VERSION unset, not uploading metadata.json" + echo "EC_VERSION unset, not uploading metadata" return 0 fi - # check if a file 'build/metadata.json' exists in the directory - # if it does, upload it as metadata/v${EC_VERSION}.json - if [ -f "build/metadata.json" ]; then - # append a 'v' prefix to the version if it doesn't already have one + # Upload architecture-specific metadata if provided + if [ -n "${ARCH}" ] && [ -f "build/metadata-${ARCH}.json" ]; then + retry 3 aws s3 cp --no-progress "build/metadata-${ARCH}.json" "s3://${S3_BUCKET}/metadata/v${EC_VERSION#v}-${ARCH}.json" + + # For AMD64, also upload as the default metadata.json for backward compatibility + if [ "${ARCH}" == "amd64" ]; then + retry 3 aws s3 cp --no-progress "build/metadata-${ARCH}.json" "s3://${S3_BUCKET}/metadata/v${EC_VERSION#v}.json" + fi + # Fallback to legacy single metadata.json if no ARCH specified + elif [ -f "build/metadata.json" ]; then retry 3 aws s3 cp --no-progress build/metadata.json "s3://${S3_BUCKET}/metadata/v${EC_VERSION#v}.json" else - echo "build/metadata.json not found, skipping upload" + echo "No metadata file found, skipping upload" fi } @@ -168,6 +174,11 @@ function embeddedcluster() { # there are three files to be uploaded for each release - the k0s binary, the metadata file, and the embedded-cluster release # the embedded cluster release does not exist for CI builds function main() { + # If invoked with "metadata" as the first argument, only upload metadata and exit + if [ "${1:-}" == "metadata" ]; then + metadata + return 0 + fi init_vars metadata if [ "${UPLOAD_BINARIES}" == "1" ]; then