From 2ca151f7cf264cf40082ee79cfd02f2075a059fb Mon Sep 17 00:00:00 2001 From: Jack Xu Date: Fri, 27 Feb 2026 15:57:04 +0800 Subject: [PATCH] feat: add version_postfix input for pre-compilation VERSION patching Allow callers to append a custom postfix (e.g., -beta, -rc1) to `string public constant VERSION` in Solidity sources before forge compiles. The original files are restored after deployment so no source changes leak into committed artifacts. --- .github/workflows/deploy.yml | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 6db5787..be98894 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -56,6 +56,11 @@ on: description: 'Allowed deployment sender address' type: string required: false + version_postfix: + description: 'Postfix appended to VERSION constants in Solidity source before compilation (e.g., -beta, -rc1)' + type: string + required: false + default: '' secrets: rpc_url: description: 'RPC endpoint URL' @@ -115,6 +120,18 @@ jobs: echo "EVM suffix will be auto-detected from foundry.toml during deployment" grep -A 1 "solc_version" "$FOUNDRY_CONFIG" + - name: Apply version postfix + if: inputs.version_postfix != '' + env: + VERSION_POSTFIX: ${{ inputs.version_postfix }} + run: | + grep -rl 'string public constant VERSION' src/ --include="*.sol" | while read file; do + cp "$file" "${file}.version-bak" + sed -i "s/\(string public constant VERSION = \"[^\"]*\)\";/\1${VERSION_POSTFIX}\";/" "$file" + echo "Applied postfix to $file:" + grep 'string public constant VERSION' "$file" + done + - name: Run deployment script env: DEPLOY_SCRIPT: ${{ inputs.deploy_script }} @@ -138,6 +155,13 @@ jobs: echo "Restored original foundry.toml" fi + # Restore VERSION-modified Solidity files + for bakfile in $(find src/ -name "*.version-bak" 2>/dev/null); do + original="${bakfile%.version-bak}" + mv "$bakfile" "$original" + echo "Restored $original" + done + - name: Check for changes id: git-check run: |