From 844a1bf983eb577e83cd567d9b62d76119f6c799 Mon Sep 17 00:00:00 2001 From: Leon Wright Date: Sun, 26 May 2024 15:15:35 +0800 Subject: [PATCH] feat: Build Tool Caches This creates a tool cache that can be used via a cally action for things like provider building. --- .github/workflows/build-tool-cache.yaml | 50 +++++++++++++++++++++++++ .github/workflows/release-cally.yaml | 8 ++++ 2 files changed, 58 insertions(+) create mode 100644 .github/workflows/build-tool-cache.yaml diff --git a/.github/workflows/build-tool-cache.yaml b/.github/workflows/build-tool-cache.yaml new file mode 100644 index 0000000..89041e2 --- /dev/null +++ b/.github/workflows/build-tool-cache.yaml @@ -0,0 +1,50 @@ +name: Build Tool Cache Archives + +on: + workflow_call: + inputs: + version: + type: string + required: true + +jobs: + build-archives: + runs-on: ubuntu-latest + strategy: + matrix: + python: + - "3.9" + - "3.10" + - "3.11" + - "3.12" + steps: + - uses: actions/checkout@v4 + - name: Setup Python + uses: actions/setup-python@v5 + with: + python-version: ${{ matrix.python }} + - name: Version + run: | + CALLY_VERSION=${{ inputs.version }} + echo "VERSION = '$CALLY_VERSION'" > src/cally/cli/_version.py + PYTHON_VERSION=$(python3 -c "import sys;print(sys.version_info.minor)") + TOOL_CACHE_PATH="Cally-${CALLY_VERSION}-${RUNNER_OS}-${RUNNER_ARCH}-Python-3.${PYTHON_VERSION}" + echo "VERSION=${VERSION}" >> $GITHUB_ENV + echo "TOOL_CACHE_PATH=${TOOL_CACHE_PATH}" >> $GITHUB_ENV + + - name: Install + run: | + pip install . --target ${TOOL_CACHE_PATH} --ignore-installed + find ${TOOL_CACHE_PATH}/bin/. -type f -exec sed -i '1s/.*/#!\/usr\/bin\/env python3/' {} \; + + - name: Check install + run: | + export PATH=$PATH:$(pwd)/${TOOL_CACHE_PATH}/bin + export PYTHONPATH=$(pwd)/${TOOL_CACHE_PATH} + cally --version + + - name: Build asset + run: cd ${TOOL_CACHE_PATH} && tar -czf ../${TOOL_CACHE_PATH,,}.tar.gz . + + - name: Upload asset + run: gh release upload v${{ inputs.version }} ${TOOL_CACHE_PATH,,}.tar.gz diff --git a/.github/workflows/release-cally.yaml b/.github/workflows/release-cally.yaml index c91b387..7134c7f 100644 --- a/.github/workflows/release-cally.yaml +++ b/.github/workflows/release-cally.yaml @@ -73,3 +73,11 @@ jobs: draft: false files: | dist/cally-${{ needs.build-artifact.outputs.version }}.tar.gz + + build-tool-cache: + needs: + - build-artifact + - generate-gh-release + uses: ./.github/workflows/build-tool-cache.yaml + with: + version: ${{ needs.build-artifact.outputs.version }}