From 5ad243a7dab650de00241b16b057b9b8c09a7594 Mon Sep 17 00:00:00 2001 From: Ashley Cui Date: Thu, 8 May 2025 13:34:25 -0400 Subject: [PATCH] [skip-ci] Tighten version match Tighten the regex needed to match a valid version. Signed-off-by: Ashley Cui --- .github/workflows/machine-os-pr.yml | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/.github/workflows/machine-os-pr.yml b/.github/workflows/machine-os-pr.yml index db222ce83d..b2900763de 100644 --- a/.github/workflows/machine-os-pr.yml +++ b/.github/workflows/machine-os-pr.yml @@ -27,9 +27,12 @@ jobs: - name: Get version id: getversion run: | - VERSION=$(curl "https://raw.githubusercontent.com/$PODMAN_REPO/$SHA/version/rawversion/version.go" | sed -n 's/^const RawVersion = \"\(.*\)\"$/\1/p') + VERSION=$(curl "https://raw.githubusercontent.com/$PODMAN_REPO/$SHA/version/rawversion/version.go" | sed -n 's/^const RawVersion = \"\([0-9]\+\.[0-9]\+\.[0-9]\+\(-rc[0-9]\+\|-dev\)\?\)"$/\1/p') # ignore -dev version bumps unless on main - if [[ $VERSION == *-dev ]] ; then + if [[ -z "$VERSION" ]] ; then + echo "::error:: Invalid version string" + exit 1 + elif [[ $VERSION == *-dev ]] ; then echo "::warning:: SKIPPING: dev bump" elif [[ ${{github.base_ref}} == "main" ]] ; then echo "::warning:: SKIPPING: main branch" @@ -72,9 +75,11 @@ jobs: - name: Bump version if: steps.getversion.outputs.update == 'true' + env: + VERS: ${{steps.getversion.outputs.version}} run: | - echo ${{steps.getversion.outputs.version}} - sed -i 's/export PODMAN_VERSION=".*"/export PODMAN_VERSION="${{steps.getversion.outputs.version}}"/g' podman-rpm-info-vars.sh + update=$(printf 's/export PODMAN_VERSION=".*"/export PODMAN_VERSION="%s"/g\n' "$VERS") + sed -i "$update" podman-rpm-info-vars.sh sed -i 's/export PODMAN_PR_NUM=".*"/export PODMAN_PR_NUM="${{github.event.number}}"/g' podman-rpm-info-vars.sh echo "Updated file:" cat podman-rpm-info-vars.sh