Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
75 changes: 60 additions & 15 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
@@ -1,30 +1,75 @@
name: release

permissions:
contents: write # Allow actions to update dependabot PRs

on:
push:
tags:
- kyaml/v*
- cmd/config/v*
- api/v*
- kustomize/v*
workflow_dispatch:
inputs:
kustomize_tag:
description: 'Tag to release'
required: true
libs_tag:
description: 'Tag to release'
required: true

permissions:
contents: write # Allow actions to push changes

jobs:
release:
runs-on: ubuntu-latest
steps:
- name: Check out code into the Go module directory
uses: actions/checkout@v5
with:
fetch-depth: 0
- name: Create a branch for the release
run: |
git config --global user.name 'github-actions'
git config --global user.email '[email protected]'
git config --global push.default current

go tool gorepomod prerelease "${{ github.events.inputs.kustomize_tag }}"

- name: Set up Go 1.x
uses: actions/setup-go@v6
with:
go-version-file: go.work
id: go
- run: ./releasing/create-release.sh "${tag}"
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
tag: ${{ github.ref_name }}

- name: Release kyaml
run: |
make IS_LOCAL=true verify-kustomize-repo
go tool gorepomod release kyaml ${{ github.event.inputs.libs_tag }} --doIt
./releasing/create-release.sh kyaml/${{ github.event.inputs.libs_tag }}
go tool gorepomod pin kyaml --doIt
git commit -m "Update kyaml to ${{ github.events.inputs.libs_tag }}"
git push --force

- name: Release cmd/config
run: |
make IS_LOCAL=true verify-kustomize-repo
go tool gorepomod release cmd/config ${{ github.event.inputs.libs_tag }} --doIt
./releasing/create-release.sh cmd/config/${{ github.event.inputs.libs_tag }}
go tool gorepomod pin cmd/config --doIt
git commit -m "Update cmd/config to ${{ github.events.inputs.libs_tag }}"
git push --force

- name: Release api
run: |
make IS_LOCAL=true verify-kustomize-repo
go tool gorepomod release api ${{ github.event.inputs.libs_tag }} --doIt
./releasing/create-release.sh api/${{ github.event.inputs.libs_tag }}
go tool gorepomod pin api --doIt
git commit -m "Update api to ${{ github.events.inputs.libs_tag }}"
git push --force

- name: Release kustomize
run: |
make IS_LOCAL=true verify-kustomize-repo
go tool gorepomod release kustomize ${{ github.event.inputs.kustomize_tag }} --doIt
./releasing/create-release.sh kustomize/${{ github.event.inputs.kustomize_tag }}

- name: Push changes
run: |
git switch master
git pull origin master
sed -i "" "s/LATEST_RELEASE=.*/LATEST_RELEASE=${{ github.event.inputs.kustomize_tag }}/" Makefile
source ./releasing/helpers.sh
createBranch bumpMakefile "Update LATEST_RELEASE to ${{ github.event.inputs.kustomize_tag }}"
86 changes: 59 additions & 27 deletions cmd/gorepomod/internal/arguments/args.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,17 @@ import (
)

const (
doItFlag = "--doIt"
localFlag = "--local"
cmdPin = "pin"
cmdUnPin = "unpin"
cmdTidy = "tidy"
cmdList = "list"
cmdRelease = "release"
cmdUnRelease = "unrelease"
cmdDebug = "debug"
doItFlag = "--doIt"
localFlag = "--local"
cmdPin = "pin"
cmdUnPin = "unpin"
cmdTidy = "tidy"
cmdList = "list"
cmdPreRelease = "pre-release"
cmdRelease = "release"
cmdUnRelease = "unrelease"
cmdDebug = "debug"
cmdNext = "next"
)

var (
Expand Down Expand Up @@ -53,19 +55,21 @@ const (
UnPin
Pin
List
PreRelease
Release
UnRelease
Debug
Next
)

type Args struct {
cmd Command
moduleName misc.ModuleShortName
conditionalModule misc.ModuleShortName
version semver.SemVer
bump semver.SvBump
doIt bool
localFlag bool
cmd Command
moduleName misc.ModuleShortName
conditionalModules []misc.ModuleShortName
version semver.SemVer
bump semver.SvBump
doIt bool
localFlag bool
}

func (a *Args) GetCommand() Command {
Expand All @@ -92,8 +96,8 @@ func (a *Args) ModuleName() misc.ModuleShortName {
return a.moduleName
}

func (a *Args) ConditionalModule() misc.ModuleShortName {
return a.conditionalModule
func (a *Args) ConditionalModules() []misc.ModuleShortName {
return a.conditionalModules
}

func (a *Args) Exclusions() (result []string) {
Expand Down Expand Up @@ -152,7 +156,6 @@ func Parse() (result *Args, err error) {
result.localFlag = clArgs.localFlag

result.moduleName = misc.ModuleUnknown
result.conditionalModule = misc.ModuleUnknown
if !clArgs.more() {
return nil, fmt.Errorf("command needs at least one arg")
}
Expand All @@ -178,22 +181,47 @@ func Parse() (result *Args, err error) {
}
result.moduleName = misc.ModuleShortName(clArgs.next())
if clArgs.more() {
result.conditionalModule = misc.ModuleShortName(clArgs.next())
result.conditionalModules = []misc.ModuleShortName{misc.ModuleShortName(clArgs.next())}
}
result.cmd = UnPin
case cmdTidy:
result.cmd = Tidy
case cmdList:
result.cmd = List
case cmdPreRelease:
if !clArgs.more() {
return nil, fmt.Errorf("specify version")
}
result.version, err = semver.Parse(clArgs.next())
if err != nil {
return nil, err
}
result.cmd = PreRelease
case cmdRelease:
if !clArgs.more() {
return nil, fmt.Errorf("specify {module} to release")
}
result.moduleName = misc.ModuleShortName(clArgs.next())
bump := "patch"
if clArgs.more() {
bump = clArgs.next()
if !clArgs.more() {
return nil, fmt.Errorf("specify version")
}
result.version, err = semver.Parse(clArgs.next())
if err != nil {
return nil, err
}
result.cmd = Release
case cmdUnRelease:
if !clArgs.more() {
return nil, fmt.Errorf("specify {module} to unrelease")
}
result.moduleName = misc.ModuleShortName(clArgs.next())
result.cmd = UnRelease
case cmdNext:
if !clArgs.more() {
return nil, fmt.Errorf("specify one of 'major', 'minor' or 'patch'")
}

bump := clArgs.next()
switch bump {
case "major":
result.bump = semver.Major
Expand All @@ -205,13 +233,17 @@ func Parse() (result *Args, err error) {
return nil, fmt.Errorf(
"unknown bump %s; specify one of 'major', 'minor' or 'patch'", bump)
}
result.cmd = Release
case cmdUnRelease:

if !clArgs.more() {
return nil, fmt.Errorf("specify {module} to unrelease")
return nil, fmt.Errorf("specify at least one {module} to release")
}
result.moduleName = misc.ModuleShortName(clArgs.next())
result.cmd = UnRelease

for clArgs.more() {
result.conditionalModules = append(result.conditionalModules, misc.ModuleShortName(clArgs.next()))
}

result.cmd = Next
case cmdDebug:
if !clArgs.more() {
return nil, fmt.Errorf("specify {module} to debug")
Expand Down
15 changes: 14 additions & 1 deletion cmd/gorepomod/internal/git/runner.go
Original file line number Diff line number Diff line change
Expand Up @@ -277,8 +277,13 @@ func (gr *Runner) FetchRemote(remote misc.TrackedRepo) error {

// MergeFromRemoteMain does a fast forward only merge with main branch.
func (gr *Runner) MergeFromRemoteMain(remote misc.TrackedRepo) error {
return gr.MergeFromRemoteBranch(remote, mainBranch)
}

// MergeFromRemoteMain does a fast forward only merge with the branch.
func (gr *Runner) MergeFromRemoteBranch(remote misc.TrackedRepo, branch string) error {
remo := strings.Join(
[]string{string(remote), mainBranch}, pathSep)
[]string{string(remote), branch}, pathSep)
gr.comment("merging from remote")
return gr.runNoOut(undoPainful, "merge", "--ff-only", remo)
}
Expand Down Expand Up @@ -388,3 +393,11 @@ func (gr *Runner) GetLatestTag(releaseBranch string) (string, error) {
func (gr *Runner) GetMainBranch() string {
return string(mainBranch)
}

func (gr *Runner) GetCurrentBranch() (string, error) {
out, err := gr.run(noHarmDone, "branch", "--show-current")
if err != nil {
return "", err
}
return strings.TrimSpace(out), nil
}
4 changes: 4 additions & 0 deletions cmd/gorepomod/internal/misc/interfaces.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,10 @@ type LaModule interface {
// ShortName is the module's name without the repo.
ShortName() ModuleShortName

// ModulePath is the absolute module path
// which is written at the module directive in go.mod file.
ModulePath() string

// ImportPath is the relative path below the Go src root,
// which is the same path as would be used to
// import the module.
Expand Down
4 changes: 4 additions & 0 deletions cmd/gorepomod/internal/mod/module.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,10 @@ func (m *Module) ShortName() misc.ModuleShortName {
return m.shortName
}

func (m *Module) ModulePath() string {
return m.mf.Module.Mod.Path
}

func (m *Module) ImportPath() string {
return filepath.Join(m.repo.RepoPath(), string(m.ShortName()))
}
Expand Down
Loading