Skip to content
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

ci: provide means to override build-meta output #95

Merged
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
52 changes: 34 additions & 18 deletions .github/build-meta.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,22 @@ set -euxo pipefail

SCRIPT_DIR="$(dirname "$0")"

OVERRIDES_DIR="$SCRIPT_DIR/overrides/build-meta"

function set_output_value() {
local output_file="$1"
local name="$2"
local value="$3"

# Check if override is defined
if [ -f "$OVERRIDES_DIR/$name" ]; then
value="$(cat "$OVERRIDES_DIR/$name")"
echo "::notice::Overriding $name with value \"$value\""
fi

echo "$name=$value" >> "$output_file"
}

# Get Git short hash for repo at $SCRIPT_DIR
GIT_SHORT_HASH="$(git -C "$SCRIPT_DIR" rev-parse --short HEAD)"

Expand Down Expand Up @@ -173,24 +189,24 @@ BUILD_META_OUTPUT="$BUILD_META_TMP_DIR/build-meta.txt"

# shellcheck disable=SC2129
# Not the nicest way to do this, but it works.
echo "build-meta-output=$BUILD_META_TMP_DIR" >> "$BUILD_META_OUTPUT"
echo "container-version=$CONTAINER_VERSION" >> "$BUILD_META_OUTPUT"
echo "gluon-repository=$GLUON_REPOSITORY" >> "$BUILD_META_OUTPUT"
echo "gluon-commit=$GLUON_COMMIT" >> "$BUILD_META_OUTPUT"
echo "site-version=$SITE_VERSION" >> "$BUILD_META_OUTPUT"
echo "release-version=$RELEASE_VERSION" >> "$BUILD_META_OUTPUT"
echo "autoupdater-enabled=$AUTOUPDATER_ENABLED" >> "$BUILD_META_OUTPUT"
echo "autoupdater-branch=$AUTOUPDATER_BRANCH" >> "$BUILD_META_OUTPUT"
echo "broken=$BROKEN" >> "$BUILD_META_OUTPUT"
echo "manifest-stable=$MANIFEST_STABLE" >> "$BUILD_META_OUTPUT"
echo "manifest-beta=$MANIFEST_BETA" >> "$BUILD_META_OUTPUT"
echo "manifest-testing=$MANIFEST_TESTING" >> "$BUILD_META_OUTPUT"
echo "sign-manifest=$SIGN_MANIFEST" >> "$BUILD_META_OUTPUT"
echo "deploy=$DEPLOY" >> "$BUILD_META_OUTPUT"
echo "link-release=$LINK_RELEASE" >> "$BUILD_META_OUTPUT"
echo "create-release=$CREATE_RELEASE" >> "$BUILD_META_OUTPUT"
echo "latest-release=$LATEST_RELEASE" >> "$BUILD_META_OUTPUT"
echo "target-whitelist=$TARGET_WHITELIST" >> "$BUILD_META_OUTPUT"
set_output_value "$BUILD_META_OUTPUT" "build-meta-output" "$BUILD_META_TMP_DIR"
set_output_value "$BUILD_META_OUTPUT" "container-version" "$CONTAINER_VERSION"
set_output_value "$BUILD_META_OUTPUT" "gluon-repository" "$GLUON_REPOSITORY"
set_output_value "$BUILD_META_OUTPUT" "gluon-commit" "$GLUON_COMMIT"
set_output_value "$BUILD_META_OUTPUT" "site-version" "$SITE_VERSION"
set_output_value "$BUILD_META_OUTPUT" "release-version" "$RELEASE_VERSION"
set_output_value "$BUILD_META_OUTPUT" "autoupdater-enabled" "$AUTOUPDATER_ENABLED"
set_output_value "$BUILD_META_OUTPUT" "autoupdater-branch" "$AUTOUPDATER_BRANCH"
set_output_value "$BUILD_META_OUTPUT" "broken" "$BROKEN"
set_output_value "$BUILD_META_OUTPUT" "manifest-stable" "$MANIFEST_STABLE"
set_output_value "$BUILD_META_OUTPUT" "manifest-beta" "$MANIFEST_BETA"
set_output_value "$BUILD_META_OUTPUT" "manifest-testing" "$MANIFEST_TESTING"
set_output_value "$BUILD_META_OUTPUT" "sign-manifest" "$SIGN_MANIFEST"
set_output_value "$BUILD_META_OUTPUT" "deploy" "$DEPLOY"
set_output_value "$BUILD_META_OUTPUT" "link-release" "$LINK_RELEASE"
set_output_value "$BUILD_META_OUTPUT" "create-release" "$CREATE_RELEASE"
set_output_value "$BUILD_META_OUTPUT" "latest-release" "$LATEST_RELEASE"
set_output_value "$BUILD_META_OUTPUT" "target-whitelist" "$TARGET_WHITELIST"

# Copy over to GITHUB_OUTPUT
cat "$BUILD_META_OUTPUT" >> "$GITHUB_OUTPUT"
Expand Down
Empty file.
28 changes: 28 additions & 0 deletions .github/validate-overrides.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#!/bin/bash

# Validate no files in .github/overrides/build-meta contain newlines

set -euo pipefail

SCRIPT_DIR="$(dirname "$0")"

OVERRIDES_DIR="$SCRIPT_DIR/overrides/build-meta"

FILES_WITH_TWO_LINES=""

# Find all files which contain at lest two lines
while IFS= read -r -d '' file
do
if [ "$(wc -l < "$file")" -gt 1 ]; then
FILES_WITH_TWO_LINES="$FILES_WITH_TWO_LINES $file"
fi
done < <(find "$OVERRIDES_DIR" -type f -print0)

# Check for newlines in overrides
if [ -n "$FILES_WITH_TWO_LINES" ]; then
echo "The following files contain newlines:"
echo "$FILES_WITH_TWO_LINES"
exit 1
fi

exit 0
11 changes: 11 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,18 @@ on:
required: false

jobs:
validate-overrides:
runs-on: ubuntu-22.04
name: Validate CI overrides
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Validate overrides
run: |
bash .github/validate-overrides.sh

build-meta:
needs: validate-overrides
outputs:
container-version: >-
${{ steps.build-metadata.outputs.container-version }}
Expand Down