Skip to content

Commit d3841ae

Browse files
Merge pull request #11 from sqlitecloud/release-cli
feat(cli): add release workflow
2 parents 74db2b0 + a509172 commit d3841ae

File tree

4 files changed

+110
-5
lines changed

4 files changed

+110
-5
lines changed

.github/workflows/release-cli.yaml

Lines changed: 104 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,104 @@
1+
# Create an incremental tag (like `cli-v1.2.0`) on Github using SemVer https://semver.org: x.y.z
2+
# Create the Release (like `cli-v1.2.0`) based on this tag and with the same name.
3+
# Build the CLI for all OS and upload them as assets to the release.
4+
5+
name: Release CLI
6+
7+
on:
8+
workflow_dispatch:
9+
inputs:
10+
choice:
11+
type: choice
12+
description: "Release types (x.y.patch / x.minor.z / major.y.z)"
13+
options:
14+
- patch
15+
- minor
16+
- major
17+
18+
jobs:
19+
release-cli:
20+
if: ${{ github.ref == 'refs/heads/main' }}
21+
name: Release CLI
22+
strategy:
23+
matrix:
24+
include:
25+
- goarch: amd64
26+
goos: linux
27+
28+
- goarch: amd64
29+
goos: windows
30+
31+
- goarch: arm64
32+
goos: darwin
33+
34+
- goarch: amd64
35+
goos: darwin
36+
37+
runs-on: ubuntu-latest
38+
env:
39+
OSNAME: ${{matrix.goos == 'darwin' && 'macos' || matrix.goos }}
40+
GOARCH: ${{ matrix.goarch }}
41+
GOOS: ${{ matrix.goos }}
42+
ARCHNAME: ${{ matrix.goarch == 'amd64' && 'x86-64' || matrix.goarch }}
43+
steps:
44+
- name: Checkout code
45+
uses: actions/checkout@v3
46+
47+
- name: Set env var
48+
run: echo "ZIPFILE=sqlitecloud-go-${{ steps.tag-and-release.outputs.name }}-${{ env.OSNAME }}-${{ env.ARCHNAME }}.zip" >> $GITHUB_ENV
49+
50+
- name: Build CLI
51+
run: |
52+
cd GO/cli
53+
go build -o ../sqlc
54+
cd ..
55+
zip ${{ env.ZIPFILE }} sqlc
56+
57+
- name: Last version
58+
id: last-version
59+
# last tag that starts with 'cli-v', eg: cli-v1.2.0 but outputs it as: v1.2.0
60+
run: echo "::set-output name=number::$(git tag --list 'cli-v*' | sort -V | tail -n1 | sed 's/cli-//')"
61+
62+
- name: Bump version
63+
id: bump-version
64+
uses: olegsu/semver-action@v1
65+
with:
66+
version: ${{ steps.last-version.outputs.number }}
67+
bump: ${{ inputs.choice }}
68+
69+
- name: Tag and Release name
70+
id: tag-and-release
71+
# eg: cli-v1.2.0
72+
run: echo "::set-output name=name::cli-v$(git tag --list 'v*' | sort -V | tail -n1)"
73+
74+
- name: Create Release for CLI
75+
id: release
76+
uses: softprops/action-gh-release@v2
77+
with:
78+
tag_name: ${{ steps.tag-and-release.outputs.name }}
79+
name: Release ${{ steps.tag-and-release.outputs.name }}
80+
draft: false
81+
generate_release_notes: true
82+
make_latest: true
83+
env:
84+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
85+
86+
- name: Upload Release Asset
87+
id: upload-release-asset
88+
uses: actions/upload-release-asset@v1
89+
if: matrix.goos != 'darwin'
90+
env:
91+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
92+
with:
93+
upload_url: ${{ steps.release.outputs.upload_url }}
94+
asset_path: ./GO/${{ env.ZIPFILE }}
95+
asset_name: ${{ env.ZIPFILE }}
96+
asset_content_type: application/zip
97+
98+
- name: Upload binary artifact
99+
uses: actions/upload-artifact@v3
100+
if: matrix.goos == 'darwin'
101+
with:
102+
name: ${{ env.ZIPFILE }}
103+
path: ./GO/${{ env.ZIPFILE }}
104+
if-no-files-found: error

.github/workflows/release.yaml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,8 @@ jobs:
2727
fetch-depth: 0
2828
- name: Last version
2929
id: last-version
30-
run: echo "::set-output name=tag::$(git describe --tags `git rev-list --tags --max-count=1`)"
30+
# last tag that starts with 'v', eg: v1.0.3
31+
run: echo "::set-output name=tag::$(git tag --list 'v*' | sort -V | tail -n1)"
3132
- name: Bump version
3233
id: bump-version
3334
uses: olegsu/semver-action@v1

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ test:
1212
cd test; go test -v .
1313

1414
test-codecov:
15-
cd test; go test -v -race -coverprofile=coverage.txt -covermode=atomic .
15+
cd test; go test -v -race -coverprofile=coverage.out -covermode=atomic .
1616

1717
# GO SDK
1818
sdk: *.go

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,14 @@
1212

1313
[![Test and QA](https://github.com/sqlitecloud/sqlitecloud-go/actions/workflows/testing.yaml/badge.svg?branch=main)](https://github.com/sqlitecloud/sqlitecloud-go/actions/workflows/testing.yaml)
1414
[![codecov](https://codecov.io/gh/sqlitecloud/sqlitecloud-go/graph/badge.svg?token=5MAG3G4X01)](https://codecov.io/gh/sqlitecloud/sqlitecloud-go)
15-
[![GitHub Tag](https://img.shields.io/github/v/tag/sqlitecloud/sqlitecloud-go?label=version&link=https%3A%2F%2Fpkg.go.dev%2Fgithub.com%2Fsqlitecloud%2Fsqlitecloud-go)](https://github.com/sqlitecloud/sqlitecloud-go)
16-
[![GitHub go.mod Go version](https://img.shields.io/github/go-mod/go-version/sqlitecloud/sqlitecloud-go?link=https%3A%2F%2Fgithub.com%2Fsqlitecloud%2Fsqlitecloud-go)](https://github.com/sqlitecloud/sqlitecloud-go)
15+
[![GitHub Tag](https://img.shields.io/github/v/tag/sqlitecloud/sqlitecloud-go?label=version&link=https%3A%2F%2Fpkg.go.dev%2Fgithub.com%2Fsqlitecloud%2Fsqlitecloud-go)](https://pkg.go.dev/github.com/sqlitecloud/sqlitecloud-go)
16+
[![GitHub go.mod Go version](https://img.shields.io/github/go-mod/go-version/sqlitecloud/sqlitecloud-go?link=https%3A%2F%2Fpkg.go.dev%2Fgithub.com%2Fsqlitecloud%2Fsqlitecloud-go)](https://pkg.go.dev/github.com/sqlitecloud/sqlitecloud-go)
1717

1818
---
1919

2020
[SQLite Cloud](https://sqlitecloud.io) for Go is a powerful package that allows you to interact with the SQLite Cloud database seamlessly. It provides methods for various database operations. This package is designed to simplify database operations in Go applications, making it easier than ever to work with SQLite Cloud. In addition to the standard SQLite statements, several other [commands](https://docs.sqlitecloud.io/docs/commands) are supported.
2121

22-
- Documentation: https://pkg.go.dev/github.com/sqlitecloud/sqlitecloud-go
22+
- Documentation: [https://pkg.go.dev/github.com/sqlitecloud/sqlitecloud-go#section-documentation](https://pkg.go.dev/github.com/sqlitecloud/sqlitecloud-go#section-documentation)
2323
- Source: [https://github.com/sqlitecloud/sqlitecloud-go](https://github.com/sqlitecloud/sqlitecloud-go)
2424
- Site: [https://sqlitecloud.io](https://sqlitecloud.io/developers)
2525

0 commit comments

Comments
 (0)