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

feat(cli): add release workflow #11

Merged
merged 1 commit into from
Jun 18, 2024
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
104 changes: 104 additions & 0 deletions .github/workflows/release-cli.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
# Create an incremental tag (like `cli-v1.2.0`) on Github using SemVer https://semver.org: x.y.z
# Create the Release (like `cli-v1.2.0`) based on this tag and with the same name.
# Build the CLI for all OS and upload them as assets to the release.

name: Release CLI

on:
workflow_dispatch:
inputs:
choice:
type: choice
description: "Release types (x.y.patch / x.minor.z / major.y.z)"
options:
- patch
- minor
- major

jobs:
release-cli:
if: ${{ github.ref == 'refs/heads/main' }}
name: Release CLI
strategy:
matrix:
include:
- goarch: amd64
goos: linux

- goarch: amd64
goos: windows

- goarch: arm64
goos: darwin

- goarch: amd64
goos: darwin

runs-on: ubuntu-latest
env:
OSNAME: ${{matrix.goos == 'darwin' && 'macos' || matrix.goos }}
GOARCH: ${{ matrix.goarch }}
GOOS: ${{ matrix.goos }}
ARCHNAME: ${{ matrix.goarch == 'amd64' && 'x86-64' || matrix.goarch }}
steps:
- name: Checkout code
uses: actions/checkout@v3

- name: Set env var
run: echo "ZIPFILE=sqlitecloud-go-${{ steps.tag-and-release.outputs.name }}-${{ env.OSNAME }}-${{ env.ARCHNAME }}.zip" >> $GITHUB_ENV

- name: Build CLI
run: |
cd GO/cli
go build -o ../sqlc
cd ..
zip ${{ env.ZIPFILE }} sqlc

- name: Last version
id: last-version
# last tag that starts with 'cli-v', eg: cli-v1.2.0 but outputs it as: v1.2.0
run: echo "::set-output name=number::$(git tag --list 'cli-v*' | sort -V | tail -n1 | sed 's/cli-//')"

- name: Bump version
id: bump-version
uses: olegsu/semver-action@v1
with:
version: ${{ steps.last-version.outputs.number }}
bump: ${{ inputs.choice }}

- name: Tag and Release name
id: tag-and-release
# eg: cli-v1.2.0
run: echo "::set-output name=name::cli-v$(git tag --list 'v*' | sort -V | tail -n1)"

- name: Create Release for CLI
id: release
uses: softprops/action-gh-release@v2
with:
tag_name: ${{ steps.tag-and-release.outputs.name }}
name: Release ${{ steps.tag-and-release.outputs.name }}
draft: false
generate_release_notes: true
make_latest: true
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Upload Release Asset
id: upload-release-asset
uses: actions/upload-release-asset@v1
if: matrix.goos != 'darwin'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.release.outputs.upload_url }}
asset_path: ./GO/${{ env.ZIPFILE }}
asset_name: ${{ env.ZIPFILE }}
asset_content_type: application/zip

- name: Upload binary artifact
uses: actions/upload-artifact@v3
if: matrix.goos == 'darwin'
with:
name: ${{ env.ZIPFILE }}
path: ./GO/${{ env.ZIPFILE }}
if-no-files-found: error
3 changes: 2 additions & 1 deletion .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@ jobs:
fetch-depth: 0
- name: Last version
id: last-version
run: echo "::set-output name=tag::$(git describe --tags `git rev-list --tags --max-count=1`)"
# last tag that starts with 'v', eg: v1.0.3
run: echo "::set-output name=tag::$(git tag --list 'v*' | sort -V | tail -n1)"
- name: Bump version
id: bump-version
uses: olegsu/semver-action@v1
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ test:
cd test; go test -v .

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

# GO SDK
sdk: *.go
Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,14 @@

[![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)
[![codecov](https://codecov.io/gh/sqlitecloud/sqlitecloud-go/graph/badge.svg?token=5MAG3G4X01)](https://codecov.io/gh/sqlitecloud/sqlitecloud-go)
[![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)
[![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)
[![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)
[![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)

---

[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.

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

Expand Down
Loading