Skip to content

Commit 51dcfff

Browse files
authored
docs: Add sqlc upload to CI / CD guide (#2797)
Also improve the bump-version script to include docs and sqlc-version fields in YAML documents.
1 parent 9632e1b commit 51dcfff

File tree

2 files changed

+46
-7
lines changed

2 files changed

+46
-7
lines changed

docs/howto/ci-cd.md

Lines changed: 30 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,10 @@ to speed up the installation process.
4141

4242
## GitHub Workflows
4343

44+
We suggest running `diff`, `vet` and `upload` as part of your workflow.
45+
46+
### diff
47+
4448
The following GitHub Workflow configuration runs `sqlc diff` on every push.
4549

4650
```yaml
@@ -53,10 +57,12 @@ jobs:
5357
- uses: actions/checkout@v3
5458
- uses: sqlc-dev/setup-sqlc@v3
5559
with:
56-
sqlc-version: '1.19.0'
60+
sqlc-version: '1.22.0'
5761
- run: sqlc diff
5862
```
5963
64+
### vet
65+
6066
The following GitHub Workflow configuration runs [`sqlc vet`](vet.md) on every push.
6167
You can use `sqlc vet` without a database connection, but you'll need one if your
6268
`sqlc` configuration references the built-in `sqlc/db-prepare` lint rule.
@@ -85,11 +91,33 @@ jobs:
8591
- uses: actions/checkout@v3
8692
- uses: sqlc-dev/setup-sqlc@v3
8793
with:
88-
sqlc-version: '1.19.0'
94+
sqlc-version: '1.22.0'
8995
# Connect and migrate your database here. This is an example which runs
9096
# commands from a `schema.sql` file.
9197
- run: psql -h localhost -U postgres -p $PG_PORT -d postgres -f schema.sql
9298
env:
9399
PGPASSWORD: postgres
94100
- run: sqlc vet
101+
```
102+
103+
### upload
104+
105+
The following GitHub Workflow configuration runs [`sqlc upload`](upload.md) on
106+
every push to `main`.
107+
108+
```yaml
109+
name: sqlc
110+
on: [push]
111+
jobs:
112+
upload:
113+
runs-on: ubuntu-latest
114+
if: ${{ github.ref == 'refs/heads/main' }}
115+
steps:
116+
- uses: actions/checkout@v3
117+
- uses: sqlc-dev/setup-sqlc@v3
118+
with:
119+
sqlc-version: '1.22.0'
120+
- run: sqlc upload
121+
env:
122+
SQLC_AUTH_TOKEN: ${{ secrets.SQLC_AUTH_TOKEN }}
95123
```

scripts/bump-version/main.go

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ func run(current, next string, realmode bool) error {
100100
return nil
101101
}
102102
switch filepath.Ext(path) {
103-
case ".go", ".kt", ".py", ".json":
103+
case ".go", ".kt", ".py", ".json", ".md":
104104
c, err := os.ReadFile(path)
105105
if err != nil {
106106
return err
@@ -109,12 +109,16 @@ func run(current, next string, realmode bool) error {
109109
new := strings.ReplaceAll(old,
110110
`"sqlc_version": "v`+current,
111111
`"sqlc_version": "v`+next)
112+
new = strings.ReplaceAll(new,
113+
`sqlc-version: "`+current,
114+
`sqlc-version: "`+next)
115+
new = strings.ReplaceAll(new,
116+
`sqlc-version: '`+current,
117+
`sqlc-version: '`+next)
112118
new = strings.ReplaceAll(new, "sqlc v"+current, "sqlc v"+next)
113119
new = strings.ReplaceAll(new, "SQLC_VERSION=v"+current, "SQLC_VERSION=v"+next)
114-
if realmode {
115-
if err := os.WriteFile(path, []byte(new), 0644); err != nil {
116-
return fmt.Errorf("write error: %s: %w", path, err)
117-
}
120+
if err := write(path, old, new); err != nil {
121+
return err
118122
}
119123
default:
120124
}
@@ -135,5 +139,12 @@ func run(current, next string, realmode bool) error {
135139
}
136140
}
137141

142+
{
143+
p := filepath.Join("docs")
144+
if err := filepath.Walk(p, walker); err != nil {
145+
return err
146+
}
147+
}
148+
138149
return nil
139150
}

0 commit comments

Comments
 (0)