From b2af6fbbd85a302484f02b1ca8b0bc07a7185b55 Mon Sep 17 00:00:00 2001 From: Takuya Ueda Date: Fri, 6 Jun 2025 10:27:24 +0900 Subject: [PATCH 1/2] Add workflows (test and tagpr) --- .github/release.yml | 4 +++ .github/workflows/tagpr.yml | 16 ++++++++++ .github/workflows/testandvet.yml | 50 ++++++++++++++++++++++++++++++++ .tagpr | 35 ++++++++++++++++++++++ version.go | 9 ++++-- version.txt | 1 + 6 files changed, 112 insertions(+), 3 deletions(-) create mode 100644 .github/release.yml create mode 100644 .github/workflows/tagpr.yml create mode 100644 .github/workflows/testandvet.yml create mode 100644 .tagpr create mode 100644 version.txt diff --git a/.github/release.yml b/.github/release.yml new file mode 100644 index 0000000..b0c5175 --- /dev/null +++ b/.github/release.yml @@ -0,0 +1,4 @@ +changelog: + exclude: + labels: + - tagpr diff --git a/.github/workflows/tagpr.yml b/.github/workflows/tagpr.yml new file mode 100644 index 0000000..631beae --- /dev/null +++ b/.github/workflows/tagpr.yml @@ -0,0 +1,16 @@ +# .github/workflows/tagpr.yml +name: tagpr +on: + push: + branches: ["main"] +jobs: + deploy: + runs-on: ubuntu-24.04 + permissions: + contents: write + pull-requests: write + steps: + - uses: actions/checkout@v4.2.2 + - uses: Songmu/tagpr@v1.5.0 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/testandvet.yml b/.github/workflows/testandvet.yml new file mode 100644 index 0000000..1a7eb77 --- /dev/null +++ b/.github/workflows/testandvet.yml @@ -0,0 +1,50 @@ +name: Test and Vet + +on: + push: + branches: + - main + pull_request: + branches: + - main + release: + types: + - published + - created + - edited + +defaults: + run: + shell: bash + +jobs: + test: + runs-on: ubuntu-24.04 + + steps: + - name: Checkout code + uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 + + - name: Install Go + uses: actions/setup-go@d35c59abb061a4a6fb18e82ac0862c26744d6ab5 # v5.5.0 + with: + go-version-file: 'go.mod' + + - name: Cache Go module and build cache + uses: actions/cache@5a3ec84eff668545956fd18022155c47e93e2684 # v4.2.3 + with: + key: go-${{ hashFiles('**/go.sum') }} + path: | + ~/go/pkg/mod + restore-keys: | + go- + + - name: Install tennvet + run: | + GOBIN=$(pwd) go install github.com/tenntenn/tennvet@latest + + - name: Test and vet + run: | + go vet ./... + go vet -vettool=$(pwd)/tennvet ./... + go test -v -race ./... diff --git a/.tagpr b/.tagpr new file mode 100644 index 0000000..59bf985 --- /dev/null +++ b/.tagpr @@ -0,0 +1,35 @@ +# 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 pcpr 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.tmplate (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] + vPrefix = true + releaseBranch = main + versionFile = version.txt diff --git a/version.go b/version.go index 8497008..0d36abe 100644 --- a/version.go +++ b/version.go @@ -1,14 +1,17 @@ package main import ( + _ "embed" "fmt" "os" "runtime" + "strings" ) -// version of zagane -const version = "v0.5.2" +//go:embed version.txt +var version string +// print version of zagane func printVersion() bool { if len(os.Args) != 2 { return false @@ -16,7 +19,7 @@ func printVersion() bool { switch os.Args[1] { case "-v", "--version": - fmt.Printf("zagane %s (%s)\n", version, runtime.Version()) + fmt.Printf("zagane %s (%s)\n", strings.TrimSpace(version), runtime.Version()) return true } diff --git a/version.txt b/version.txt new file mode 100644 index 0000000..b0c2058 --- /dev/null +++ b/version.txt @@ -0,0 +1 @@ +v0.5.2 From f09cab8f144636d22d7952d1df74e931dd93729c Mon Sep 17 00:00:00 2001 From: Takuya Ueda Date: Fri, 6 Jun 2025 10:40:06 +0900 Subject: [PATCH 2/2] Add dependabot --- .github/dependabot.yml | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 .github/dependabot.yml diff --git a/.github/dependabot.yml b/.github/dependabot.yml new file mode 100644 index 0000000..3938344 --- /dev/null +++ b/.github/dependabot.yml @@ -0,0 +1,6 @@ +version: 2 +updates: + - package-ecosystem: "gomod" + directory: "/" + schedule: + interval: "daily"