Skip to content

Commit

Permalink
Merge pull request #62 from gzuidhof/update-goreleaser
Browse files Browse the repository at this point in the history
Fix Goreleaser (bump to v2), README tweaks
  • Loading branch information
gzuidhof authored Jul 20, 2024
2 parents 5189d5b + e60ba26 commit 5d9a9b4
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 12 deletions.
18 changes: 13 additions & 5 deletions .github/workflows/goreleaser.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,24 +3,32 @@ name: goreleaser
on:
pull_request:
push:


permissions:
contents: write

jobs:
goreleaser:
runs-on: ubuntu-latest
env:
flags: ""
steps:
- if: ${{ !startsWith(github.ref, 'refs/tags/v') }}
run: echo "flags=--snapshot" >> $GITHUB_ENV # See https://github.com/goreleaser/goreleaser-action/issues/387
- name: Checkout
uses: actions/checkout@v2
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up Go
uses: actions/setup-go@v2
uses: actions/setup-go@v5
with:
go-version: "^1.18"
- name: Run GoReleaser
uses: goreleaser/goreleaser-action@v2
uses: goreleaser/goreleaser-action@v6
with:
distribution: goreleaser
version: latest
args: release --rm-dist
version: '~> v2'
args: release --clean ${{ env.flags }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,5 @@
examples/time
examples/tygo
examples/http

dist/
12 changes: 5 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,12 @@ Tygo is a tool for generating Typescript typings from Golang source files that j

It preserves comments, understands constants and also supports non-struct `type` expressions. It's perfect for generating equivalent types for a Golang REST API to be used in your front-end codebase.

**🚀 Now supports Golang 1.18 generic types, struct inheritance**
**🚀 Supports Golang 1.18 generic types and struct inheritance**

## Installation

```shell
# Go >= 1.17
go install github.com/gzuidhof/tygo@latest
# Go < 1.17:
go install github.com/gzuidhof/tygo
```

## Example
Expand Down Expand Up @@ -391,6 +388,7 @@ export interface ABCD<
## YAML support

Tygo supports generating typings for YAML-serializable objects that can be understood by Go apps.

By default, Tygo will respect `yaml` Go struct tags, in addition to `json`, but it will not apply any transformations to untagged fields.
However, the default behavior of the popular `gopkg.in/yaml.v2` package for Go structs without tags is to downcase the struct field names.
To emulate this behavior, one can use the `flavor` configuration option:
Expand Down Expand Up @@ -420,10 +418,10 @@ export interface Foo {

## Related projects

- [**typescriptify-golang-structs**](https://github.com/tkrajina/typescriptify-golang-structs): Probably the most popular choice. The downside of this package is that it relies on reflection rather than parsing, which means that certain things can't be kept such as comments without adding a bunch of tags to your structs. The CLI generates a Go file which is then executed and reflected on, and its library requires you to manually specify all types that should be converted.
- [**go2ts**](https://github.com/StirlingMarketingGroup/go2ts): A transpiler with a web interface, this project was based off this project. It's perfect for quick one-off transpilations. There is no CLI, no support for `const` and there are no ways to customize the output.
- [**typescriptify-golang-structs**](https://github.com/tkrajina/typescriptify-golang-structs): Probably the most popular choice. The downside of this package is that it relies on reflection rather than parsing, which means that certain things can't be kept such as comments without adding a bunch of tags to your structs. The CLI generates a Go file which is then executed and reflected on. The library requires you to manually specify all types that should be converted.
- [**go2ts**](https://github.com/StirlingMarketingGroup/go2ts): A transpiler with a web interface, this project can be seen as an evolution of this project. It's perfect for quick one-off transpilations. There is no CLI, no support for `const` and there are no ways to customize the output.

If this repository was useful for your project, consider leaving a star.
**If `tygo` is useful for your project, consider leaving a star.**

## License

Expand Down
2 changes: 2 additions & 0 deletions goreleaser.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
version: 2
project_name: tygo
builds:
- binary: tygo
Expand All @@ -7,6 +8,7 @@ builds:
- linux
goarch:
- amd64
- arm64
ldflags:
- -s -w -X github.com/gzuidhof/tygo/cmd.version={{.Version}} -X github.com/gzuidhof/tygo/cmd.commit={{.Commit}} -X github.com/gzuidhof/tygo/cmd.commitDate={{.CommitDate}}
archives:
Expand Down

0 comments on commit 5d9a9b4

Please sign in to comment.