Skip to content

Commit

Permalink
Deployment
Browse files Browse the repository at this point in the history
  • Loading branch information
Zaczero committed May 7, 2024
1 parent 2925419 commit ee6186e
Show file tree
Hide file tree
Showing 3 changed files with 71 additions and 3 deletions.
68 changes: 68 additions & 0 deletions .github/workflows/deploy.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
name: Deployment

on:
push:
tags:
- "*"

jobs:
deploy:
name: Publish to PyPI
runs-on: ubuntu-latest
environment:
name: pypi
url: https://pypi.org/p/starlette-compress
permissions:
id-token: write

steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Install Nix
uses: cachix/install-nix-action@v26
with:
nix_path: nixpkgs=channel:nixpkgs-23.11-darwin

- name: Extract nixpkgs hash
run: |
nixpkgs_hash=$(grep -o -P '(?<=archive/)[0-9a-f]{40}(?=\.tar\.gz)' shell.nix)
echo "NIXPKGS_HASH=$nixpkgs_hash" >> $GITHUB_ENV
- name: Cache Nix store
uses: actions/cache@v4
id: nix-cache
with:
key: nix-${{ runner.os }}-${{ env.NIXPKGS_HASH }}
path: /tmp/nix-cache

- name: Import Nix store cache
if: steps.nix-cache.outputs.cache-hit == 'true'
run: |
nix-store --import < /tmp/nix-cache
- name: Cache Python packages
uses: actions/cache@v4
with:
key: python-${{ runner.os }}-${{ hashFiles('poetry.lock') }}
path: .venv

- name: Install dependencies
run: |
nix-shell --pure --run true
- name: Export Nix store cache
if: steps.nix-cache.outputs.cache-hit != 'true'
run: |
nix-store --export $(find /nix/store -maxdepth 1 -name '*-*') > /tmp/nix-cache
- name: Run tests
run: |
nix-shell --pure --run run-tests
- name: Build distribution
run: |
nix-shell --pure --run "poetry build"
- name: Publish to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
4 changes: 2 additions & 2 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ on:

jobs:
test:
name: "Run tests"
name: Run tests
runs-on: "ubuntu-latest"

steps:
Expand All @@ -29,7 +29,7 @@ jobs:
uses: actions/cache@v4
id: nix-cache
with:
key: nix-${{ runner.os }}-${{ env.NIXPKGS_HASH }}-test
key: nix-${{ runner.os }}-${{ env.NIXPKGS_HASH }}
path: /tmp/nix-cache

- name: Import Nix store cache
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ license = "Unlicense"
name = "starlette-compress"
readme = "README.md"
repository = "https://github.com/Zaczero/starlette-compress"
version = "0.1.2"
version = "0.1.3"

[tool.poetry.dependencies]
brotli = {version = ">=1", markers = "platform_python_implementation == 'CPython'"}
Expand Down

0 comments on commit ee6186e

Please sign in to comment.