diff --git a/.github/workflows/release-cli.yaml b/.github/workflows/release-cli.yaml new file mode 100644 index 0000000..c85f524 --- /dev/null +++ b/.github/workflows/release-cli.yaml @@ -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 diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index 6c08f7b..99a65ba 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -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 diff --git a/Makefile b/Makefile index bc7e59d..6c36b7a 100644 --- a/Makefile +++ b/Makefile @@ -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 diff --git a/README.md b/README.md index 1920bb3..4e7c9fd 100644 --- a/README.md +++ b/README.md @@ -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)