name: Setup Build Environment runs: using: "composite" steps: - name: Init Cache uses: actions/cache@v5 with: path: | ~/.cache/pip ~/.platformio/.cache key: ${{ runner.os }}-pio - name: Install Python uses: actions/setup-python@v6 with: python-version: '3.13' - name: Install PlatformIO shell: bash run: | pip install --upgrade platformio -r requirements-build.txt # Keep the complete version suffix. For example: # - room-server-v1.2.3 -> v1.2.3 # - repeater-room-v1.2.3-channel-dev-abc12345 -> v1.2.3-channel-dev-abc12345 - name: Extract Version from Git Tag shell: bash run: | if [[ "${GITHUB_REF}" == refs/tags/* ]]; then # triggered by a tag push (e.g: refs/tags/companion-v1.2.3) GIT_TAG_NAME="${GITHUB_REF#refs/tags/}" if [[ "${GIT_TAG_NAME}" =~ (^|-)(v[0-9][-0-9A-Za-z._+]*)$ ]]; then VERSION_STRING="${BASH_REMATCH[2]}" else echo "::error::Cannot extract a v-prefixed version from tag '${GIT_TAG_NAME}'" >&2 exit 1 fi else # triggered by a workflow dispatch (e.g: refs/heads/main) # strip "refs/heads/" prefix and replace any remaining "/" with "-" to protect file paths BRANCH_NAME="${GITHUB_REF#refs/heads/}" VERSION_STRING=$(echo "$BRANCH_NAME" | tr '/' '-') fi echo "GIT_TAG_VERSION=${VERSION_STRING}" >> $GITHUB_ENV