From 286b3b7c9648b39d2fb4294b348c2eff23a9582d Mon Sep 17 00:00:00 2001 From: daku10 Date: Sat, 15 Apr 2023 22:26:22 +0900 Subject: [PATCH 1/2] add version command --- cli/root.go | 1 + cli/version.go | 30 ++++++++++++++++++++++++++++++ version/version.go | 3 +++ 3 files changed, 34 insertions(+) create mode 100644 cli/version.go create mode 100644 version/version.go diff --git a/cli/root.go b/cli/root.go index ce372f1..470cb4e 100644 --- a/cli/root.go +++ b/cli/root.go @@ -22,6 +22,7 @@ This application implements algorithm is compatible with lz-string@1.4.4`, rootCmd.AddCommand( newCompressCmd(config), newDecompressCmd(config), + newVersionCmd(config), ) return rootCmd } diff --git a/cli/version.go b/cli/version.go new file mode 100644 index 0000000..b2d3cb8 --- /dev/null +++ b/cli/version.go @@ -0,0 +1,30 @@ +package cli + +import ( + "bufio" + "errors" + "fmt" + + "github.com/daku10/go-lz-string/version" + "github.com/spf13/cobra" +) + +func newVersionCmd(config *Config) *cobra.Command { + var versionCmd = &cobra.Command{ + Use: "version", + Short: "print version", + Long: "print the version of go-lz-string", + RunE: func(cmd *cobra.Command, args []string) error { + bufWriter := bufio.NewWriter(cmd.OutOrStdout()) + fmt.Fprintln(bufWriter, version.Version) + if err := bufWriter.Flush(); err != nil { + return errors.New("version command failed") + } + return nil + }, + } + versionCmd.SetIn(config.In) + versionCmd.SetOut(config.Out) + versionCmd.SetErr(config.Err) + return versionCmd +} diff --git a/version/version.go b/version/version.go new file mode 100644 index 0000000..876c4b6 --- /dev/null +++ b/version/version.go @@ -0,0 +1,3 @@ +package version + +var Version = "0.0.3" From 29e65ef0a574a602a53350bccc0a98b55c2d55bd Mon Sep 17 00:00:00 2001 From: daku10 Date: Sat, 15 Apr 2023 22:11:58 +0900 Subject: [PATCH 2/2] introduce tagpr --- .github/workflows/tagpr.yml | 24 +++++++++++++++++++++ .tagpr | 42 +++++++++++++++++++++++++++++++++++++ 2 files changed, 66 insertions(+) create mode 100644 .github/workflows/tagpr.yml create mode 100644 .tagpr diff --git a/.github/workflows/tagpr.yml b/.github/workflows/tagpr.yml new file mode 100644 index 0000000..8046dd1 --- /dev/null +++ b/.github/workflows/tagpr.yml @@ -0,0 +1,24 @@ +name: tagpr +on: + push: + branches: + - main +permissions: write-all +jobs: + tagpr: + runs-on: ubuntu-latest + steps: + - name: Generate Token + id: generate-token + uses: getsentry/action-github-app-token@v2 + with: + app_id: ${{ secrets.APP_ID }} + private_key: ${{ secrets.APP_PRIVATE_KEY }} + - name: Check out source code + uses: actions/checkout@v3 + with: + token: ${{ steps.generate-token.outputs.token }} + - name: Run tagpr + uses: Songmu/tagpr@v1 + env: + GITHUB_TOKEN: ${{ steps.generate-token.outputs.token }} diff --git a/.tagpr b/.tagpr new file mode 100644 index 0000000..815efa8 --- /dev/null +++ b/.tagpr @@ -0,0 +1,42 @@ +# config file for the tagpr in git config format +# The tagpr generates the initial configuration, which you can rewrite to suit your environment. +# CONFIGURATIONS: +# tagpr.releaseBranch +# Generally, it is "main." It is the branch for releases. The tagpr tracks this branch, +# creates or updates a pull request as a release candidate, or tags when they are merged. +# +# tagpr.versionFile +# Versioning file containing the semantic version needed to be updated at release. +# It will be synchronized with the "git tag". +# Often this is a meta-information file such as gemspec, setup.cfg, package.json, etc. +# Sometimes the source code file, such as version.go or Bar.pm, is used. +# If you do not want to use versioning files but only git tags, specify the "-" string here. +# You can specify multiple version files by comma separated strings. +# +# tagpr.vPrefix +# Flag whether or not v-prefix is added to semver when git tagging. (e.g. v1.2.3 if true) +# This is only a tagging convention, not how it is described in the version file. +# +# tagpr.changelog (Optional) +# Flag whether or not changelog is added or changed during the release. +# +# tagpr.command (Optional) +# Command to change files just before release. +# +# tagpr.template (Optional) +# Pull request template in go template format +# +# tagpr.release (Optional) +# GitHub Release creation behavior after tagging [true, draft, false] +# If this value is not set, the release is to be created. +# +# tagpr.majorLabels (Optional) +# Label of major update targets. Default is [major] +# +# tagpr.minorLabels (Optional) +# Label of minor update targets. Default is [minor] +# +[tagpr] + vPrefix = true + releaseBranch = main + versionFile = version/version.go