-
Notifications
You must be signed in to change notification settings - Fork 943
ci: add adapter to kuiper-formatted artifacts #3299
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
liviutomoiaga
wants to merge
9
commits into
ci
Choose a base branch
from
ci1
base: ci
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
97f6668
ci: prepare_rpi_artefacts: Prepare RPI artefacts
liviutomoiaga 4eaaf11
ci: prepare_sdg_artefacts: Prepare and deploy SDG Linux Artefacts
liviutomoiaga 9a7df65
ci: upload_to_cloudsmith: Use input variable if provided
bf9ee64
Fix review findings
liviutomoiaga a7a5224
ci: Unify Linux and RPI artifact deployment workflows
liviutomoiaga fc2bb79
Fix regex to match strip files
liviutomoiaga ccf5b38
Converted echo statements to GitHub Actions workflow commands
liviutomoiaga 545845c
Rename: Deploy Linux to Deploy Kuiper
liviutomoiaga 9920828
Fix conflict
liviutomoiaga File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,203 @@ | ||
| name: Deploy Kuiper Artifacts to Cloudsmith | ||
|
|
||
| on: | ||
| workflow_call: | ||
| inputs: | ||
| artifacts: | ||
| description: 'Space-separated patterns of artifact names to download' | ||
| required: true | ||
| type: string | ||
| pr-target-branch: | ||
| description: 'PR target branch (for PR deployments)' | ||
| required: false | ||
| type: string | ||
| default: '' | ||
| pr-number: | ||
| description: 'PR number (for PR deployments)' | ||
| required: false | ||
| type: string | ||
| default: '' | ||
| scripts-ref: | ||
| description: 'Branch/tag to fetch CI scripts from (default: ci)' | ||
| required: false | ||
| type: string | ||
| default: 'ci' | ||
|
|
||
| permissions: | ||
| id-token: write | ||
| contents: read | ||
| actions: read | ||
|
|
||
| jobs: | ||
| deploy-artifacts: | ||
| runs-on: ubuntu-latest | ||
| timeout-minutes: 30 | ||
| permissions: | ||
| id-token: write | ||
| contents: read | ||
| actions: read | ||
|
|
||
| steps: | ||
| - name: Detect artifact type from branch | ||
| id: detect | ||
| run: | | ||
| BRANCH_NAME="${{ github.head_ref || github.ref_name }}" | ||
| echo "::notice::Branch: ${BRANCH_NAME}" | ||
|
|
||
| if [[ "${BRANCH_NAME}" == *"rpi"* ]]; then | ||
| echo "ARTIFACT_TYPE=rpi" >> $GITHUB_ENV | ||
| echo "CLOUDSMITH_REPO=sdg-linux-rpi" >> $GITHUB_ENV | ||
| else | ||
| echo "ARTIFACT_TYPE=kuiper" >> $GITHUB_ENV | ||
| echo "CLOUDSMITH_REPO=sdg-linux" >> $GITHUB_ENV | ||
| fi | ||
|
|
||
| - name: Prepare directories | ||
| run: | | ||
| sudo apt-get update && sudo apt-get install -y tree | ||
| rm -rf artifacts raw dist | ||
| mkdir -p artifacts raw dist | ||
|
|
||
| - name: Get sources | ||
| run: | | ||
| # Fetch CI scripts from the specified branch (scripts-ref input) | ||
| org_repo="analogdevicesinc/linux" | ||
| ref="${{ inputs.scripts-ref }}" | ||
|
|
||
| echo "::notice::Fetching scripts from: $org_repo @ $ref" | ||
|
|
||
| get_file() { | ||
| curl -sL -H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" \ | ||
| -o "$1" \ | ||
| "https://raw.githubusercontent.com/${org_repo}/${ref}/$1" | ||
| } | ||
|
|
||
| mkdir -p ci | ||
| get_file ci/lib.sh | ||
| get_file ci/lib_github.sh | ||
|
|
||
| if [[ "${{ env.ARTIFACT_TYPE }}" == "kuiper" ]]; then | ||
| get_file ci/expand_kernel_images.sh | ||
| get_file ci/prepare_kuiper_artifacts_structure.sh | ||
| else | ||
| get_file ci/prepare_rpi_artifacts.sh | ||
| fi | ||
|
|
||
| chmod +x ci/*.sh | ||
|
|
||
| curl -sL -o upload_to_cloudsmith.py \ | ||
| https://raw.githubusercontent.com/analogdevicesinc/wiki-scripts/main/utils/cloudsmith_utils/upload_to_cloudsmith.py | ||
|
|
||
| echo "::debug::Scripts downloaded:" | ||
| ls -la ci/ | ||
|
|
||
| - name: Download, extract, and process artifacts | ||
| run: | | ||
| WORK_DIR="$(pwd)" | ||
| source ci/lib.sh | ||
| source ci/lib_github.sh | ||
|
|
||
| # Download matching artifacts from workflow run | ||
| download_matching_artifacts \ | ||
| "${{ secrets.GITHUB_TOKEN }}" \ | ||
| "${{ github.repository }}" \ | ||
| "${{ github.run_id }}" \ | ||
| "${{ inputs.artifacts }}" \ | ||
| "artifacts" | ||
|
|
||
| # Extract to raw/ | ||
| extract_artifacts "artifacts" "raw" | ||
| echo "::debug::Contents of raw/:" | ||
| ls -la raw/ | ||
|
|
||
| # Process based on artifact type | ||
| if [[ "${{ env.ARTIFACT_TYPE }}" == "kuiper" ]]; then | ||
| # Expand linux artifacts into structured dist/ for Kuiper format | ||
| source ci/expand_kernel_images.sh | ||
| prepare_kernel_dist | ||
|
|
||
| else | ||
| export SOURCE_DIRECTORY="${WORK_DIR}/raw" | ||
| export OUTPUT_DIRECTORY="${WORK_DIR}/dist" | ||
| export BUILD_SOURCEBRANCHNAME="${{ github.head_ref || github.ref_name }}" | ||
| source ci/prepare_rpi_artifacts.sh | ||
| create_rpi_boot_archives | ||
| fi | ||
|
|
||
| - name: Setup Cloudsmith OIDC | ||
| uses: cloudsmith-io/cloudsmith-cli-action@v1.0.5 | ||
| with: | ||
| oidc-namespace: ${{ vars.CLOUDSMITH_NAMESPACE }} | ||
| oidc-service-slug: ${{ secrets.CLOUDSMITH_SERVICE_SLUG }} | ||
| oidc-auth-only: 'true' | ||
|
|
||
| - name: Prepare structure and upload to Cloudsmith | ||
| run: | | ||
| # Setup Python environment | ||
| python3 -m venv venv | ||
| source ./venv/bin/activate | ||
| python3 -m ensurepip | ||
| pip3 install cloudsmith-cli | ||
|
|
||
| source ci/lib_github.sh | ||
|
|
||
| # Set timestamp and git info | ||
| TIMESTAMP=$(date +%Y_%m_%d-%H_%M) | ||
| GIT_SHA="${{ github.event.pull_request.head.sha || github.sha }}" | ||
| GIT_SHA_DATE="${{ github.event.head_commit.timestamp }}" | ||
|
|
||
| # Get branch name | ||
| # ToDo: Test PR: github.head_ref = feature-branch, github.ref_name = refs/pull/123/merge | ||
| BRANCH_NAME="${{ github.head_ref || github.ref_name }}" | ||
|
|
||
| # Build version path | ||
| VERSION_PATH=$(get_version_path \ | ||
| "${{ env.ARTIFACT_TYPE }}" \ | ||
| "${BRANCH_NAME}" \ | ||
| "${TIMESTAMP}" \ | ||
| "${{ inputs.pr-target-branch }}" \ | ||
| "${{ inputs.pr-number }}") | ||
|
|
||
| echo "::group::Upload configuration" | ||
| echo " Artifact type: ${{ env.ARTIFACT_TYPE }}" | ||
| echo " Repository: ${{ env.CLOUDSMITH_REPO }}" | ||
| echo " Version path: ${VERSION_PATH}" | ||
| echo " Git SHA: ${GIT_SHA}" | ||
| echo " Git SHA date: ${GIT_SHA_DATE}" | ||
| echo "::endgroup::" | ||
|
|
||
| export TIMESTAMP GIT_SHA GIT_SHA_DATE | ||
| export BUILD_SOURCEBRANCHNAME="${BRANCH_NAME}" | ||
| export SOURCE_DIRECTORY="$(pwd)" | ||
|
|
||
| # Determine upload directory based on artifact type | ||
| if [[ "${{ env.ARTIFACT_TYPE }}" == "kuiper" ]]; then | ||
| # Kuiper: prepare_kuiper_artifacts_structure.sh creates timestamped directory | ||
| export TIMESTAMP GIT_SHA GIT_SHA_DATE | ||
| export BUILD_SOURCEBRANCHNAME="${BRANCH_NAME}" | ||
| export SOURCE_DIRECTORY="$(pwd)" | ||
| source ci/lib.sh | ||
| source ci/prepare_kuiper_artifacts_structure.sh | ||
| UPLOAD_PATH="${TIMESTAMP}" | ||
| else | ||
| # RPI: artifacts are already in dist/ | ||
| UPLOAD_PATH="dist" | ||
| fi | ||
|
|
||
| if [[ ! -d "${UPLOAD_PATH}" ]] || [[ -z "$(ls -A "${UPLOAD_PATH}" 2>/dev/null)" ]]; then | ||
| echo "::warning::No artifacts to upload in ${UPLOAD_PATH}" | ||
| exit 0 | ||
| fi | ||
|
|
||
| echo "::notice::Uploading from: ${UPLOAD_PATH}" | ||
| ls -la "${UPLOAD_PATH}" | ||
|
|
||
| python3 upload_to_cloudsmith.py \ | ||
| --repo="${{ env.CLOUDSMITH_REPO }}" \ | ||
| --version="${VERSION_PATH}" \ | ||
| --local_path="${UPLOAD_PATH}" \ | ||
| --token="${CLOUDSMITH_API_KEY}" \ | ||
| --max_workers=10 | ||
|
|
||
| echo "::notice::Upload complete: ${VERSION_PATH}." | ||
| echo "::notice::Check Cloudsmith repository for details on https://cloudsmith.io/~${{ vars.CLOUDSMITH_NAMESPACE }}/repos/${{ env.CLOUDSMITH_REPO }}/packages/" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this changes the default for /linux from 12 chars to the full 40 chars.
I was considering to default to 40 chars, maybe we can merge and see where it breaks