Skip to content

Commit

Permalink
Merge pull request #34 from jgwest/add-rollouts-upgrade-script
Browse files Browse the repository at this point in the history
Add automatic rollouts upgrade script (#33)
  • Loading branch information
jgwest authored Feb 21, 2024
2 parents 2aba8a0 + 260df5e commit 027faa9
Show file tree
Hide file tree
Showing 9 changed files with 538 additions and 1 deletion.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,7 @@ lint: golangci_lint

.PHONY: gosec
gosec: go_sec
$(GO_SEC) ./...
$(GO_SEC) -exclude-dir=hack ./...

# go-get-tool will 'go install' any package $2 and install it to $1.
PROJECT_DIR := $(shell dirname $(abspath $(lastword $(MAKEFILE_LIST))))
Expand Down
2 changes: 2 additions & 0 deletions hack/upgrade-rollouts-script/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
settings.env
argo-rollouts-manager
33 changes: 33 additions & 0 deletions hack/upgrade-rollouts-script/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# Update argo-rollouts-manager to latest release of Argo Rollouts

The Go code and script this in this directory will automatically open a pull request to update the argo-rollouts-manager to the latest official argo-rollouts release:
- Update container image version in `default.go`
- Update `go.mod` to point to latest module version
- Update CRDs to latest
- Update target Rollouts version in `hack/run-upstream-argo-rollouts-e2e-tests.sh`
- Open Pull Request using 'gh' CLI

## Instructions

### Prerequisites
- GitHub CLI (_gh_) installed and on PATH
- Go installed an on PATH
- [Operator-sdk v1.28.0](https://github.com/operator-framework/operator-sdk/releases/tag/v1.28.0) installed (as of January 2024), and on PATH
- You must have your own fork of the [argo-rollouts-manager](https://github.com/argoproj-labs/argo-rollouts-manager) repository (example: `jgwest/argo-rollouts-manager`)
- Your local SSH key registered (e.g. `~/.ssh/id_rsa.pub`) with GitHub to allow git clone via SSH

### Configure and run the tool

```bash

# Set required Environment Variables
export GITHUB_FORK_USERNAME="(your username here)"
export GH_TOKEN="(a GitHub personal access token that can clone/push/open PRs against argo-rollouts-manager repo)"

# or, you can set these values in the settings.env file:
# cp settings_template.env settings.env
# Then set env vars in settings.env (which is excluded in the .gitignore)

./init-repo.sh
./go-run.sh
```
14 changes: 14 additions & 0 deletions hack/upgrade-rollouts-script/go-run.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#!/bin/bash

SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )

cd $SCRIPT_DIR

# Read Github Token and Username from settings.env, if it exists
vars_file="$SCRIPT_DIR/settings.env"
if [[ -f "$vars_file" ]]; then
source "$vars_file"
fi

# Run the upgrade code
go run .
8 changes: 8 additions & 0 deletions hack/upgrade-rollouts-script/go.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
module github.com/jgwest/argo-rollouts-release-job

go 1.20

require (
github.com/google/go-github/v58 v58.0.0
github.com/google/go-querystring v1.1.0 // indirect
)
7 changes: 7 additions & 0 deletions hack/upgrade-rollouts-script/go.sum
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
github.com/google/go-cmp v0.5.2/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI=
github.com/google/go-github/v58 v58.0.0 h1:Una7GGERlF/37XfkPwpzYJe0Vp4dt2k1kCjlxwjIvzw=
github.com/google/go-github/v58 v58.0.0/go.mod h1:k4hxDKEfoWpSqFlc8LTpGd9fu2KrV1YAa6Hi6FmDNY4=
github.com/google/go-querystring v1.1.0 h1:AnCroh3fv4ZBgVIf1Iwtovgjaw/GiKJo8M8yD/fhyJ8=
github.com/google/go-querystring v1.1.0/go.mod h1:Kcdr2DB4koayq7X8pmAG4sNG59So17icRSOU623lUBU=
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
24 changes: 24 additions & 0 deletions hack/upgrade-rollouts-script/init-repo.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#!/bin/bash

SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )

cd $SCRIPT_DIR

# Read Github Token and Username from settings.env, if it exists
vars_file="$SCRIPT_DIR/settings.env"
if [[ -f "$vars_file" ]]; then
source "$vars_file"
fi

# Clone fork of argo-rollouts-manager repo

rm -rf "$SCRIPT_DIR/argo-rollouts-manager" || true

git clone "[email protected]:$GITHUB_FORK_USERNAME/argo-rollouts-manager"
cd argo-rollouts-manager

# Add a remote back to the original repo

git remote add parent "[email protected]:argoproj-labs/argo-rollouts-manager"
git fetch parent

Loading

0 comments on commit 027faa9

Please sign in to comment.