Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/actions/setup-ubuntu-host/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ runs:
- name: setup python
uses: actions/setup-python@v5
with:
python-version: ${{inputs.python-version}}
python-version: '${{ inputs.python-version }}'
cache: 'pip' # caching pip dependencies
- name: Install dependencies
shell: bash
Expand Down
18 changes: 18 additions & 0 deletions .github/actions/switch-context/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
name: 'Switch context and export all environment variables'
inputs:
context-name:
description: 'Context name to switch to'
required: true
runs:
using: "composite"
steps:
- name: Switch context
shell: bash
run: |
echo "Initializing context files"
cp scripts/dev/contexts/gha-private-context scripts/dev/contexts/private-context
scripts/dev/switch_context.sh ${{inputs.context-name}}
echo "Finished initializing to the ${{inputs.context-name}}"
while read line; do
echo "$line" >> $GITHUB_ENV
done < <(tail -n +5 .generated/context.env | sed 's/\"//g')
12 changes: 8 additions & 4 deletions .github/workflows/preview_release_notes.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,18 +21,22 @@ jobs:
uses: actions/checkout@v4
with:
fetch-depth: '0'
- name: Switch to root context
id: switch_context
uses: ./.github/actions/switch-context
with:
context-name: 'root-context'
- name: Setup host
uses: ./.github/actions/setup-ubuntu-host
with:
python-version: '${{ vars.PYTHON_VERSION }}'
python-version: ${{ env.PYTHON_VERSION }}
- name: Generate Release Notes
id: generate_release_notes
run: python -m scripts.release.release_notes -s $INITIAL_COMMIT_SHA -v $INITIAL_VERSION -o release_notes_tmp.md
env:
# We can not use environments set via GitHub UI because they will
# not be available in the pull requests running from forks.
INITIAL_COMMIT_SHA: 9ed5f98fc70c5b3442f633d2393265fb8a2aba0c
INITIAL_VERSION: 1.3.0
INITIAL_COMMIT_SHA: ${{ env.INITIAL_COMMIT_SHA }}
INITIAL_VERSION: ${{ env.INITIAL_VERSION }}
- name: Add disclaimer to release notes preview
run: |
echo -e "_:warning: (this preview might not be accurate if the PR is not rebased on current master branch)_\n" > release_notes_preview.md
Expand Down
7 changes: 6 additions & 1 deletion .github/workflows/require_changelog.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,15 @@ jobs:
uses: actions/checkout@v4
with:
fetch-depth: '0'
- name: Switch to root context
id: switch_context
uses: ./.github/actions/switch-context
with:
context-name: 'root-context'
- name: Setup host
uses: ./.github/actions/setup-ubuntu-host
with:
python-version: '${{ vars.PYTHON_VERSION }}'
python-version: ${{ env.PYTHON_VERSION }}
- name: Check if changelog entry file was added in this PR
run: |
set -o pipefail
Expand Down
8 changes: 8 additions & 0 deletions scripts/dev/contexts/gha-private-context
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!/usr/bin/env bash

set -Eeou pipefail

export NAMESPACE=""
export CLUSTER_NAME=""
export LOCAL_OPERATOR="false"
export BASE_REPO_URL=""
4 changes: 4 additions & 0 deletions scripts/dev/contexts/root-context
Original file line number Diff line number Diff line change
Expand Up @@ -129,3 +129,7 @@ fi
# but we can unify once we are done with unified operator
# installation for both multicluster and single cluster setups.
export OPERATOR_NAME="mongodb-kubernetes-operator"

# Variables used for release process
export INITIAL_COMMIT_SHA="9ed5f98fc70c5b3442f633d2393265fb8a2aba0c"
export INITIAL_VERSION="1.3.0"
5 changes: 3 additions & 2 deletions scripts/dev/switch_context.sh
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ else
fi
# Execute the command in a clean environment and capture exported variables
# Let's use our PATH as a base to have utilities available.
current_envs=$(env -i PATH="${PATH}" CURRENT_VARIANT_CONTEXT="${context}" bash -c "${base_command} && export -p")
current_envs=$(env -i PWD="${PWD}" PATH="${PATH}" CURRENT_VARIANT_CONTEXT="${context}" bash -c "${base_command} && export -p")

# `export -p` instead of `env` ensures we can safely re-source variables which we rely on further
# below like our operator.print.env script
Expand All @@ -76,7 +76,8 @@ else
fi

# convert declare -x key=value into key=value
current_envs=$(echo "${current_envs[@]}" | sed 's/^declare -x //g' | sed 's/=/=/'| sort | uniq)
# filter out variables that don't have value (missing '=')
current_envs=$(echo "${current_envs[@]}" | grep '=' | sed 's/^declare -x //g' | sed 's/=/=/'| sort | uniq)

echo -e "## This file is automatically generated by switch_context.sh\n## Do not edit it!" > "${destination_envs_file}.env"
# shellcheck disable=SC2129
Expand Down
Loading