Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs: Add sqlc upload to CI / CD guide #2797

Merged
merged 1 commit into from
Oct 2, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 30 additions & 2 deletions docs/howto/ci-cd.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,10 @@ to speed up the installation process.

## GitHub Workflows

We suggest running `diff`, `vet` and `upload` as part of your workflow.

### diff

The following GitHub Workflow configuration runs `sqlc diff` on every push.

```yaml
Expand All @@ -53,10 +57,12 @@ jobs:
- uses: actions/checkout@v3
- uses: sqlc-dev/setup-sqlc@v3
with:
sqlc-version: '1.19.0'
sqlc-version: '1.22.0'
- run: sqlc diff
```

### vet

The following GitHub Workflow configuration runs [`sqlc vet`](vet.md) on every push.
You can use `sqlc vet` without a database connection, but you'll need one if your
`sqlc` configuration references the built-in `sqlc/db-prepare` lint rule.
Expand Down Expand Up @@ -85,11 +91,33 @@ jobs:
- uses: actions/checkout@v3
- uses: sqlc-dev/setup-sqlc@v3
with:
sqlc-version: '1.19.0'
sqlc-version: '1.22.0'
# Connect and migrate your database here. This is an example which runs
# commands from a `schema.sql` file.
- run: psql -h localhost -U postgres -p $PG_PORT -d postgres -f schema.sql
env:
PGPASSWORD: postgres
- run: sqlc vet
```

### upload

The following GitHub Workflow configuration runs [`sqlc upload`](upload.md) on
every push to `main`.

```yaml
name: sqlc
on: [push]
jobs:
upload:
runs-on: ubuntu-latest
if: ${{ github.ref == 'refs/heads/main' }}
steps:
- uses: actions/checkout@v3
- uses: sqlc-dev/setup-sqlc@v3
with:
sqlc-version: '1.22.0'
- run: sqlc upload
env:
SQLC_AUTH_TOKEN: ${{ secrets.SQLC_AUTH_TOKEN }}
```
21 changes: 16 additions & 5 deletions scripts/bump-version/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ func run(current, next string, realmode bool) error {
return nil
}
switch filepath.Ext(path) {
case ".go", ".kt", ".py", ".json":
case ".go", ".kt", ".py", ".json", ".md":
c, err := os.ReadFile(path)
if err != nil {
return err
Expand All @@ -109,12 +109,16 @@ func run(current, next string, realmode bool) error {
new := strings.ReplaceAll(old,
`"sqlc_version": "v`+current,
`"sqlc_version": "v`+next)
new = strings.ReplaceAll(new,
`sqlc-version: "`+current,
`sqlc-version: "`+next)
new = strings.ReplaceAll(new,
`sqlc-version: '`+current,
`sqlc-version: '`+next)
new = strings.ReplaceAll(new, "sqlc v"+current, "sqlc v"+next)
new = strings.ReplaceAll(new, "SQLC_VERSION=v"+current, "SQLC_VERSION=v"+next)
if realmode {
if err := os.WriteFile(path, []byte(new), 0644); err != nil {
return fmt.Errorf("write error: %s: %w", path, err)
}
if err := write(path, old, new); err != nil {
return err
}
default:
}
Expand All @@ -135,5 +139,12 @@ func run(current, next string, realmode bool) error {
}
}

{
p := filepath.Join("docs")
if err := filepath.Walk(p, walker); err != nil {
return err
}
}

return nil
}
Loading