Skip to content

Commit

Permalink
ci: improve import path action (#2104)
Browse files Browse the repository at this point in the history
  • Loading branch information
p0mvn authored Jul 18, 2022
1 parent 7fb5f82 commit dcc82d7
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 18 deletions.
28 changes: 12 additions & 16 deletions .github/workflows/import_paths.yml
Original file line number Diff line number Diff line change
Expand Up @@ -57,21 +57,17 @@ jobs:
-
name: Run find & replace script
run: ./scripts/replace_import_paths.sh ${{ inputs.version }}
- name: Commit and push changes
uses: devops-infra/action-commit-push@master
- name: Create Pull Request
uses: peter-evans/create-pull-request@v4
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
commit_message: "auto: update Go import paths to v${{ inputs.version }}"
target_branch: update-paths
- name: Open PR
uses: devops-infra/[email protected]
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
title: ${{ github.event.commits[0].message }}
source_branch: ${{ inputs.source-branch }}
target_branch: ${{ inputs.target-branch }}
assignee: ${{ github.actor }}
draft: true
label: T:auto,T:code-hygiene
token: ${{ secrets.ADD_TO_PROJECT_PAT }}
title: "auto: update Go import paths to v${{ inputs.version }}"
commit-message: "auto: update Go import paths to v${{ inputs.version }}"
body: "**Automated pull request**\n\nUpdating Go import paths to v${{ inputs.version }}"
get_diff: true
base: ${{ inputs.target-branch }}
branch-suffix: random
branch: ${{ inputs.source-branch }}
delete-branch: true
assignees: ${{ github.actor }}
draft: true
labels: T:auto,T:code-hygiene
20 changes: 18 additions & 2 deletions scripts/replace_import_paths.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#!/bin/bash

set -euo pipefail

NEXT_MAJOR_VERSION=$1
import_path_to_replace=$(go list -m)

Expand All @@ -15,7 +17,7 @@ replace_paths() {
sed -i "s/github.com\/osmosis-labs\/osmosis\/v${version_to_replace}/github.com\/osmosis-labs\/osmosis\/v${NEXT_MAJOR_VERSION}/g" ${file}
}

# Replace all files within Go packages.
echo "Replacing import paths in Go files"
for mod in $modules;
do
for file in $mod/*; do
Expand All @@ -25,6 +27,20 @@ do
done
done

replace_paths "go.mod"
echo "Replacing import paths in proto files"
for file in $(find proto/osmosis -type f -name "*.proto"); do
replace_paths $file
done

# protocgen.sh
replace_paths "scripts/protocgen.sh"

echo "Updating go.mod and vendoring"
# go.mod
replace_paths "go.mod"
go mod vendor >/dev/null

echo "running make proto-gen"
# ensure protos match generated Go files
# N.B.: This must be run after go mod vendor.
make proto-gen >/dev/null

0 comments on commit dcc82d7

Please sign in to comment.