diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index 2176747..76ea128 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -50,3 +50,32 @@ jobs: CRATES_TOKEN: ${{ secrets.CRATES_TOKEN }} run: | cargo publish --package upid --token $CRATES_TOKEN --allow-dirty + + docker: + needs: test + runs-on: ubuntu-latest + if: startsWith(github.ref, 'refs/tags/') + steps: + - uses: actions/checkout@v4 + - uses: docker/setup-qemu-action@v3 + - uses: docker/setup-buildx-action@v3 + - uses: docker/login-action@v3 + with: + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_TOKEN }} + - name: Extract tag name + id: extract_tag + run: echo "RELEASE_TAG=${GITHUB_REF#refs/tags/}" >> $GITHUB_ENV + - name: Docker Buildx base image + env: + RELEASE_TAG: ${{ env.RELEASE_TAG }} + run: | + docker buildx build \ + --platform linux/amd64,linux/arm64 \ + --output "type=image,push=true" \ + --tag "carderne/postgres-upid:16-${RELEASE_TAG}" \ + --tag "carderne/postgres-upid:16" \ + --tag "carderne/postgres-upid:latest" \ + --cache-from "carderne/postgres-upid:latest" \ + --cache-to type=inline \ + . diff --git a/README.md b/README.md index 52972f1..1117890 100644 --- a/README.md +++ b/README.md @@ -15,20 +15,29 @@ UPID allows a prefix of up to **4 characters** (will be right-padded if shorter This is a UPID in Python: ```python -upid("user") # user_2accvpp5guht4dts56je5a +upid("user") # user_2accvpp5guht4dts56je5a ``` And in Rust: ```rust -UPID::new("user") // user_2accvpp5guht4dts56je5a +UPID::new("user") // user_2accvpp5guht4dts56je5a ``` And in Postgres too: ```sql CREATE TABLE users (id upid NOT NULL DEFAULT gen_upid('user') PRIMARY KEY); INSERT INTO users DEFAULT VALUES; -SELECT id FROM users; --- user_2accvpp5guht4dts56je5a +SELECT id FROM users; -- user_2accvpp5guht4dts56je5a + +-- this also works +SELECT id FROM users WHERE id = 'user_2accvpp5guht4dts56je5a'; +``` + +Plays nice with your server code too, no extra work needed: +```python +with psycopg.connect("postgresql://...") as conn: + res = conn.execute("SELECT id FROM users").fetchone() + print(res) # user_2accvpp5guht4dts56je5a ``` ## Specification