diff --git a/.github/workflows/sync-release-version.yml b/.github/workflows/sync-release-version.yml index 765508a1..29713221 100644 --- a/.github/workflows/sync-release-version.yml +++ b/.github/workflows/sync-release-version.yml @@ -5,9 +5,47 @@ on: jobs: + check-version: + runs-on: ubuntu-latest + name: semver-diff + steps: + - uses: actions/checkout@v3 + with: + fetch-depth: 0 + ref: main + + - name: Get branch name + id: branch-name + uses: tj-actions/branch-names@v7 + + - name: Run semver-diff + id: semver-diff + uses: tj-actions/semver-diff@v2 + + - name: Show release type + if: steps.semver-diff.outputs.release_type == "major" + run: | + OLD_VERSION=$(echo "${{ steps.semver-diff.outputs.old_version }}" | cut -d'.' -f1 | cut -d'v' -f2) + MAJOR_VERSION=$(echo "${{ steps.semver-diff.outputs.new_version }}" | cut -d'.' -f1 | cut -d'v' -f2) + + make upgrade-from-one-version-to-a-major-version OLD_VERSION=$OLD_VERSION MAJOR_VERSION=$MAJOR_VERSION + + - name: Commit the change to the main branch and update the latest version + if: steps.semver-diff.outputs.release_type == "major" + run: | + git config --local user.email "github-actions[bot]@users.noreply.github.com" + git config --local user.name "github-actions[bot]" + git tag -d ${{ steps.branch-name.outputs.tag }} + git add . + git commit -m "chore: upgraded from ${{ steps.semver-diff.outputs.old_version }} -> ${{ steps.semver-diff.outputs.new_version }}" + git push -f origin main + git tag ${{ steps.branch-name.outputs.tag }} + git push -f origin ${{ steps.branch-name.outputs.tag }} + release: name: release runs-on: ubuntu-latest + needs: check-version steps: - uses: actions/checkout@v4 with: diff --git a/Makefile b/Makefile index 44b4a6a5..e95ce86b 100644 --- a/Makefile +++ b/Makefile @@ -36,27 +36,14 @@ run-help: build guard-OUTPUT guard-FILENAME ## Execute binary @./bin/auto_doc --help @$(MAKE) clean -upgrade-to-v2: ## Upgrade to v2 +upgrade-from-one-version-to-a-major-version: guard-OLD_VERSION guard-MAJOR_VERSION ## Upgrade from and old version to a major version + @echo "Upgrading from v$(OLD_VERSION) to v$(MAJOR_VERSION)" @find . -type f \ -name '*.go' \ - -exec grep -q 'github.com/tj-actions/auto-doc/v2' {} \; \ - && echo "Already upgraded to v2" \ - && exit 1 \ - || echo "Upgrading to v2" + -exec sed -i '' -e 's,github.com/tj-actions/auto-doc/v$(OLD_VERSION),github.com/tj-actions/auto-doc/v$(MAJOR_VERSION),g' {} \; @find . -type f \ - -name '*.go' \ - -exec sed -i '' -e 's,github.com/tj-actions/auto-doc,github.com/tj-actions/auto-doc/v2,g' {} \; - -upgrade-from-v2-to-a-major-version: guard-MAJOR_VERSION ## Upgrade from v2 to a major version - @find . -type f \ - -name '*.go' \ - -exec grep -q 'github.com/tj-actions/auto-doc/v$(MAJOR_VERSION)' {} \; \ - && echo "Already upgraded to v$(MAJOR_VERSION)" \ - && exit 1 \ - || echo "Upgrading to v$(MAJOR_VERSION)" - @find . -type f \ - -name '*.go' \ - -exec sed -i '' -e 's,github.com/tj-actions/auto-doc/v2,github.com/tj-actions/auto-doc/v$(MAJOR_VERSION),g' {} \; + -name 'go.mod' \ + -exec sed -i '' -e 's,github.com/tj-actions/auto-doc/v$(OLD_VERSION),github.com/tj-actions/auto-doc/v$(MAJOR_VERSION),g' {} \; .PHONY: test test: clean diff --git a/cmd/root.go b/cmd/root.go index 59e5ab36..57e228c5 100644 --- a/cmd/root.go +++ b/cmd/root.go @@ -21,8 +21,8 @@ import ( "github.com/spf13/cobra" - "github.com/tj-actions/auto-doc/v2/internal" - "github.com/tj-actions/auto-doc/v2/internal/types" + "github.com/tj-actions/auto-doc/v3/internal" + "github.com/tj-actions/auto-doc/v3/internal/types" ) var fileName string diff --git a/go.mod b/go.mod index c4f83353..2b87bdb8 100644 --- a/go.mod +++ b/go.mod @@ -1,4 +1,4 @@ -module github.com/tj-actions/auto-doc/v2 +module github.com/tj-actions/auto-doc/v3 go 1.20 diff --git a/internal/types/action.go b/internal/types/action.go index ab5a6e13..57a66e41 100644 --- a/internal/types/action.go +++ b/internal/types/action.go @@ -29,8 +29,8 @@ import ( "github.com/spf13/cobra" "gopkg.in/yaml.v3" - "github.com/tj-actions/auto-doc/v2/internal" - "github.com/tj-actions/auto-doc/v2/internal/utils" + "github.com/tj-actions/auto-doc/v3/internal" + "github.com/tj-actions/auto-doc/v3/internal/utils" ) // ActionInput represents the input of the action.yml diff --git a/internal/types/reusable.go b/internal/types/reusable.go index 17b3588f..7ba4c44b 100644 --- a/internal/types/reusable.go +++ b/internal/types/reusable.go @@ -29,8 +29,8 @@ import ( "github.com/spf13/cobra" "gopkg.in/yaml.v3" - "github.com/tj-actions/auto-doc/v2/internal" - "github.com/tj-actions/auto-doc/v2/internal/utils" + "github.com/tj-actions/auto-doc/v3/internal" + "github.com/tj-actions/auto-doc/v3/internal/utils" ) // ReusableInput represents the input of the reusable workflow diff --git a/internal/utils/format_value.go b/internal/utils/format_value.go index e8527f0d..27a4b619 100644 --- a/internal/utils/format_value.go +++ b/internal/utils/format_value.go @@ -20,7 +20,7 @@ import ( "fmt" "strings" - "github.com/tj-actions/auto-doc/v2/internal" + "github.com/tj-actions/auto-doc/v3/internal" ) // FormatValue formats a string that would be outputed as markdown diff --git a/main.go b/main.go index 1d34331d..e1fcb4b3 100644 --- a/main.go +++ b/main.go @@ -15,7 +15,7 @@ limitations under the License. */ package main -import "github.com/tj-actions/auto-doc/v2/cmd" +import "github.com/tj-actions/auto-doc/v3/cmd" func main() { cmd.Execute()