Skip to content

Commit

Permalink
add docker build to ci
Browse files Browse the repository at this point in the history
  • Loading branch information
carderne committed Jul 10, 2024
1 parent 78582bd commit 9256d63
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 4 deletions.
29 changes: 29 additions & 0 deletions .github/workflows/rust.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 \
.
17 changes: 13 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 9256d63

Please sign in to comment.