From b6f454a030be3e6fbe3089431304e230941b37e1 Mon Sep 17 00:00:00 2001 From: Daria Guy Date: Wed, 29 Oct 2025 19:09:19 +0200 Subject: [PATCH] Added .env file and github action to parse variables --- .github/.env | 4 +++ .github/actions/parse-env-file/action.yml | 37 ++++++++++++++++++++ .github/workflows/apt.yml | 24 ++++++++++--- .github/workflows/release_build_and_test.yml | 27 +++++++++++--- 4 files changed, 83 insertions(+), 9 deletions(-) create mode 100644 .github/.env create mode 100644 .github/actions/parse-env-file/action.yml diff --git a/.github/.env b/.github/.env new file mode 100644 index 0000000..5399167 --- /dev/null +++ b/.github/.env @@ -0,0 +1,4 @@ +BUILD_ARCHS=["i386", "amd64", "arm64", "armhf"] +BUILD_DISTS=["noble", "jammy", "bookworm", "trixie"] +BUILD_EXCLUDE=[ {"dist":"noble", "arch":"i386"}, {"dist":"jammy", "arch":"i386"} ] +SMOKE_TEST_IMAGES=["ubuntu:jammy", "ubuntu:noble", "debian:bookworm", "debian:trixie"] \ No newline at end of file diff --git a/.github/actions/parse-env-file/action.yml b/.github/actions/parse-env-file/action.yml new file mode 100644 index 0000000..28bfeab --- /dev/null +++ b/.github/actions/parse-env-file/action.yml @@ -0,0 +1,37 @@ +name: "Parse env file" +description: "Parses .env environment file and extracts all available fields as outputs" + +inputs: + env_file_path: + description: ".env file path" + default: '.github/.env' + required: false + +outputs: + BUILD_ARCHS: + description: "The extracted BUILD_DISTS from .env file" + value: ${{ steps.parse.outputs.BUILD_ARCHS }} + BUILD_DISTS: + description: "The extracted BUILD_DISTS from .env file" + value: ${{ steps.parse.outputs.BUILD_DISTS }} + BUILD_EXCLUDE: + description: "The extracted BUILD_EXCLUDE from .env file" + value: ${{ steps.parse.outputs.BUILD_EXCLUDE }} + SMOKE_TEST_IMAGES: + description: "The extracted SMOKE_TEST_IMAGES from .env file" + value: ${{ steps.parse.outputs.SMOKE_TEST_IMAGES }} + +runs: + using: "composite" + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Parse release handle + id: parse + shell: bash + run: | + cat "${{ inputs.env_file_path }}" | while IFS= read -r line || [[ -n "$line" ]]; do + [[ -z "$line" || "$line" =~ ^# ]] && continue + echo "$line" >> "$GITHUB_OUTPUT" + done \ No newline at end of file diff --git a/.github/workflows/apt.yml b/.github/workflows/apt.yml index 4f10cc5..721f676 100644 --- a/.github/workflows/apt.yml +++ b/.github/workflows/apt.yml @@ -31,13 +31,29 @@ run-name: >- }} jobs: + populate-env-vars: + runs-on: ["ubuntu-latest"] + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Parse vars + id: parse + uses: ./.github/actions/parse-env-file + outputs: + BUILD_ARCHS: ${{ steps.parse.outputs.BUILD_ARCHS }} + BUILD_DISTS: ${{ steps.parse.outputs.BUILD_DISTS }} + BUILD_EXCLUDE: ${{ steps.parse.outputs.BUILD_EXCLUDE }} + SMOKE_TEST_IMAGES: ${{ steps.parse.outputs.SMOKE_TEST_IMAGES }} + build-n-test: uses: ./.github/workflows/build-n-test-all-distros.yml + needs: populate-env-vars with: - BUILD_DISTS: ${{ vars.BUILD_DISTS }} - BUILD_ARCHS: ${{ vars.BUILD_ARCHS }} - BUILD_EXCLUDE: ${{ vars.BUILD_EXCLUDE }} - SMOKE_TEST_IMAGES: ${{ vars.SMOKE_TEST_IMAGES }} + BUILD_DISTS: ${{ needs.populate-env-vars.outputs.BUILD_DISTS }} + BUILD_ARCHS: ${{ needs.populate-env-vars.outputs.BUILD_ARCHS }} + BUILD_EXCLUDE: ${{ needs.populate-env-vars.outputs.BUILD_EXCLUDE }} + SMOKE_TEST_IMAGES: ${{ needs.populate-env-vars.outputs.SMOKE_TEST_IMAGES }} # Determine whether we should use special "unstable" release_tag. Assume # that for unstable branch and for any external call, dispatch or schedule # we are building unstable release. In other cases it's a regular PR/push diff --git a/.github/workflows/release_build_and_test.yml b/.github/workflows/release_build_and_test.yml index 75dde85..49930dd 100644 --- a/.github/workflows/release_build_and_test.yml +++ b/.github/workflows/release_build_and_test.yml @@ -45,14 +45,31 @@ jobs: release_version_branch: ${{ steps.ensure-branch.outputs.release_version_branch }} release_type: ${{ github.event.inputs.release_type }} + populate-env-vars: + runs-on: ["ubuntu-latest"] + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Parse vars + id: parse + uses: ./.github/actions/parse-env-file + outputs: + BUILD_ARCHS: ${{ steps.parse.outputs.BUILD_ARCHS }} + BUILD_DISTS: ${{ steps.parse.outputs.BUILD_DISTS }} + BUILD_EXCLUDE: ${{ steps.parse.outputs.BUILD_EXCLUDE }} + SMOKE_TEST_IMAGES: ${{ steps.parse.outputs.SMOKE_TEST_IMAGES }} + build-n-test: - needs: prepare-release + needs: + - prepare-release + - populate-env-vars uses: ./.github/workflows/build-n-test-all-distros.yml with: - BUILD_DISTS: ${{ vars.BUILD_DISTS }} - BUILD_ARCHS: ${{ vars.BUILD_ARCHS }} - BUILD_EXCLUDE: ${{ vars.BUILD_EXCLUDE }} - SMOKE_TEST_IMAGES: ${{ vars.SMOKE_TEST_IMAGES }} + BUILD_DISTS: ${{ needs.populate-env-vars.outputs.BUILD_DISTS }} + BUILD_ARCHS: ${{ needs.populate-env-vars.outputs.BUILD_ARCHS }} + BUILD_EXCLUDE: ${{ needs.populate-env-vars.outputs.BUILD_EXCLUDE }} + SMOKE_TEST_IMAGES: ${{ needs.populate-env-vars.outputs.SMOKE_TEST_IMAGES }} release_tag: ${{ inputs.release_tag }} create-release-handle: