Skip to content

Commit

Permalink
feat: upgrade package to v3 (#515)
Browse files Browse the repository at this point in the history
  • Loading branch information
jackton1 committed Sep 23, 2023
1 parent a7d3956 commit d34955c
Show file tree
Hide file tree
Showing 8 changed files with 52 additions and 27 deletions.
38 changes: 38 additions & 0 deletions .github/workflows/sync-release-version.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
23 changes: 5 additions & 18 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module github.com/tj-actions/auto-doc/v2
module github.com/tj-actions/auto-doc/v3

go 1.20

Expand Down
4 changes: 2 additions & 2 deletions internal/types/action.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions internal/types/reusable.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion internal/utils/format_value.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down

0 comments on commit d34955c

Please sign in to comment.