diff --git a/.github/workflows/check.yml b/.github/workflows/check.yml index 28d5f2f..130d400 100644 --- a/.github/workflows/check.yml +++ b/.github/workflows/check.yml @@ -7,38 +7,45 @@ on: branches: - main +permissions: {} + jobs: check: runs-on: ubuntu-latest + permissions: + contents: read strategy: fail-fast: false matrix: python-version: ['3.9', '3.10', '3.11', '3.12'] steps: - - uses: actions/checkout@v4 + - uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4 with: submodules: true + persist-credentials: false - name: Set up Python ${{ matrix.python-version }} - uses: actions/setup-python@v5 + uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 # v5 id: setup-python with: python-version: ${{ matrix.python-version }} - name: Setup poetry - uses: abatilo/actions-poetry@v4 + uses: abatilo/actions-poetry@0dd19c9498c3dc8728967849d0d2eae428a8a3d8 # v4 with: poetry-version: '2.1.4' - name: Setup a local virtual environment + env: + PYTHON_PATH: ${{ steps.setup-python.outputs.python-path }} run: | - poetry env use ${{ steps.setup-python.outputs.python-path }} + poetry env use "$PYTHON_PATH" poetry run python --version poetry config virtualenvs.create true --local poetry config virtualenvs.in-project true --local - - uses: actions/cache@v4 + - uses: actions/cache@0057852bfaa89a56745cba8c7296529d2fc39830 # v4 name: Define a cache for the virtual environment based on the dependencies lock file id: cache with: diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 3b88120..819c344 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -6,52 +6,47 @@ on: tags: - 'v[0-9]+.[0-9]+.[0-9]+*' +permissions: {} + jobs: build: name: Build distribution 📦 runs-on: ubuntu-latest + permissions: + contents: read steps: - - uses: actions/checkout@v4 + - uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4 with: submodules: true + persist-credentials: false - name: Set up Python 3.12 - uses: actions/setup-python@v5 + uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 # v5 id: setup-python with: python-version: 3.12 - name: Setup poetry - uses: abatilo/actions-poetry@v4 + uses: abatilo/actions-poetry@0dd19c9498c3dc8728967849d0d2eae428a8a3d8 # v4 with: poetry-version: '2.1.4' - name: Setup a local virtual environment + env: + PYTHON_PATH: ${{ steps.setup-python.outputs.python-path }} run: | - poetry env use ${{ steps.setup-python.outputs.python-path }} + poetry env use "$PYTHON_PATH" poetry run python --version poetry config virtualenvs.create true --local poetry config virtualenvs.in-project true --local - - uses: actions/cache@v4 - name: Define a cache for the virtual environment based on the dependencies lock file - id: cache - with: - path: ./.venv - key: venv-${{ runner.os }}-${{ matrix.python-version }}-${{ hashFiles('poetry.lock') }} - - - name: Ensure cache is healthy - if: steps.cache.outputs.cache-hit == 'true' - shell: bash - run: poetry run pip --version >/dev/null 2>&1 || (echo "Cache is broken, skip it" && rm -rf .venv) - - name: Install dependencies run: poetry install - name: Build a binary wheel and a source tarball run: poetry build - name: Store the distribution packages - uses: actions/upload-artifact@v4 + uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4 with: name: python-package-distributions path: dist/ @@ -70,7 +65,7 @@ jobs: steps: - name: Download all the dists - uses: actions/download-artifact@v4 + uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4 with: name: python-package-distributions path: dist/ @@ -97,7 +92,7 @@ jobs: VERSION: ${{ steps.version.outputs.version }} TAG: ${{ steps.tag.outputs.tag }} - name: Publish distribution 📦 to PyPI - uses: pypa/gh-action-pypi-publish@release/v1 + uses: pypa/gh-action-pypi-publish@cef221092ed1bacb1cc03d23a2d87d1d172e277b # v1.14.0 publish-to-testpypi: name: Publish Python distribution to TestPyPI @@ -114,11 +109,11 @@ jobs: steps: - name: Download all the dists - uses: actions/download-artifact@v4 + uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4 with: name: python-package-distributions path: dist/ - name: Publish distribution 📦 to TestPyPI - uses: pypa/gh-action-pypi-publish@release/v1 + uses: pypa/gh-action-pypi-publish@cef221092ed1bacb1cc03d23a2d87d1d172e277b # v1.14.0 with: repository-url: https://test.pypi.org/legacy/ \ No newline at end of file