automatic SQLIte release badge

This commit is contained in:
glebarez
2022-01-19 15:33:03 +01:00
parent 62072dbf54
commit 1934a36d14
3 changed files with 71 additions and 1 deletions

View File

@@ -0,0 +1,38 @@
name: Badge Sqlite version
on:
workflow_dispatch:
push:
branches: [master]
jobs:
create-sqlite-version-badge:
runs-on: ubuntu-latest
steps:
- name: Set up Go
uses: actions/setup-go@v2.1.5
with:
go-version: 1.17
- name: Check out code into the Go module directory
uses: actions/checkout@v2
- name: go mod package cache
uses: actions/cache@v2
with:
path: ~/go/pkg/mod
key: ${{ runner.os }}-${{ hashFiles('go.mod') }}
- name: request sqlite_version()
run: echo "sqlite_version=$(go test . -run '^TestSQLiteVersion$' -v | grep sqlite_version | tr -s ' ' | cut -d' ' -f3)" >> $GITHUB_ENV
- name: Make version badge
uses: schneegans/dynamic-badges-action@v1.1.0
with:
auth: ${{ secrets.GIST_SECRET }}
gistID: 0fd7561eb29baf31d5362ffee1ae1702
filename: badge-sqlite-version-with-date.json
label: SQLite release
message: "${{ env.sqlite_version }}"
color: 2269d3
labelColor: 25292d

View File

@@ -1,5 +1,5 @@
[![Tests](https://github.com/glebarez/go-sqlite/actions/workflows/tests.yml/badge.svg)](https://github.com/glebarez/go-sqlite/actions/workflows/tests.yml)<br>
![badge](https://img.shields.io/endpoint?url=https://gist.githubusercontent.com/glebarez/fb4d23f63d866b3e1e58b26d2f5ed01f/raw/badge-sqlite-version.json)
![badge](https://img.shields.io/endpoint?url=https://gist.githubusercontent.com/glebarez/0fd7561eb29baf31d5362ffee1ae1702/raw/badge-sqlite-version-with-date.json)
# go-sqlite
This is a pure-Go SQLite driver for Golang's native [database/sql](https://pkg.go.dev/database/sql) package.

32
sqlite_release_test.go Normal file
View File

@@ -0,0 +1,32 @@
package sqlite
import (
"database/sql"
"log"
"testing"
"time"
)
func TestSQLiteVersion(t *testing.T) {
db, err := sql.Open(driverName, ":memory:")
if err != nil {
log.Fatal(err)
}
var (
version string
sourceID string
)
row := db.QueryRow("select sqlite_version(), sqlite_source_id()")
if row.Scan(&version, &sourceID) != nil {
log.Fatal(err)
}
releaseDate, err := time.Parse(`2006-01-02`, sourceID[:10])
if err != nil {
t.Fatal(err)
}
t.Logf("%s (%s)\n", version, releaseDate.Format(`02/Jan/2006`))
}