diff --git a/.goreleaser.yml b/.goreleaser.yml index f6b2721..6e22c45 100644 --- a/.goreleaser.yml +++ b/.goreleaser.yml @@ -14,6 +14,8 @@ builds: - amd64 - arm - arm64 + ldflags: + - "-X 'github.com/equinor/radix-cli/cmd.Version={{ .Version }}'" dockers: - image_templates: - "ghcr.io/equinor/radix/rx:latest" diff --git a/README.md b/README.md index d5bc51c..c69e21d 100644 --- a/README.md +++ b/README.md @@ -42,7 +42,7 @@ Authenticate with github via docker using a token with _read:packages_ access. M ```bash docker login -u -p ghcr.io -alias rx="docker run -it -v ${HOME}/.radix:/home/radix-cli/.radix ghcr.io/equinor/radix/rx:latest" +alias rx="docker run -it -v ${HOME}/.radix:/home/radix/.radix ghcr.io/equinor/radix/rx:latest" ``` (Typically your `HOME` variable will be `/Users/` on a Mac and `/home/` on Linux) @@ -73,13 +73,13 @@ See docker for linux/mac above for authentication guide. If your terminal has a profile or auto-run script, you can add the following to it: ```batch -DOSKEY rx=docker run -it -v %HOME%:/home/radix-cli ghcr.io/equinor/radix/rx:latest $* +DOSKEY rx=docker run -it -v %HOME%:/home/radix ghcr.io/equinor/radix/rx:latest $* ``` If not, you must add a new script file called `rx.bat` in a directory, present in `PATH`, with the following content ```batch -docker run -it -v %HOME%:/home/radix-cli ghcr.io/equinor/radix/rx:latest $* +docker run -it -v %HOME%:/home/radix ghcr.io/equinor/radix/rx:latest $* ``` (Typically your `HOME` variable will be `C:\Users\`) @@ -115,7 +115,7 @@ Note that using your own token obtained through `az account get-access-token` ma * Set the machine-user token to the environment variable: `export APP_SERVICE_ACCOUNT_TOKEN=` * Run the command within the container (example to watch pipeline job logs with a command `rx get logs job -a your-application-name -c playground -j your-job-name`): ```shell -docker run -it -e APP_SERVICE_ACCOUNT_TOKEN=$APP_SERVICE_ACCOUNT_TOKEN ghcr.io/equinor/radix-cli/rx:latest --token-environment get logs job -a your-application-name -c playground -j your-job-name +docker run -it -e APP_SERVICE_ACCOUNT_TOKEN=$APP_SERVICE_ACCOUNT_TOKEN ghcr.io/equinor/radix/rx:latest --token-environment get logs job -a your-application-name -c playground -j your-job-name ``` ## Problems encountered @@ -153,23 +153,12 @@ NOTE: If there is a change to the API, you make need to point to the API environ We are making releases available as GitHub releases using [go-releaser](https://goreleaser.com/). The release process is controlled by the `.goreleaser.yml` file. To make a release: -1. Set the version number in the constant `version` in the file `cmd/root.go`. The version will be shown with the command `rx --version` -2. Ensure there is no `dist` folder in the project (left from previous release) -3. Get the [personal access token](https://github.com/settings/tokens) - with access to repository and `write:packages` scope, and with enabled SSO for organisation (or create it) -4. Login to the docker repository with your user-name, using personal access token as a password (personal user=name/password authentication is or will be deprecated) - ``` - docker login ghcr.io -u USER_NAME - ``` -5. Run the command to create a version with a tag, build a docker image and push them to GitHub repository - ``` - GITHUB_TOKEN= make release VERSION=0.0.1 RELEASE_NOTE="" - ``` -6. If something goes wrong: - - open the GitHub repository and delete [created tag](https://github.com/equinor/radix-cli/releases/) (with release) - - delete it locally ` git tag -d v0.0.1` - - reset changes `git reset --hard` - - delete the `dist` folder - - perform the previous step `make release ...` again +1. Create and push the new version as a tag: `git tag v0.0.1` and `git push origin v0.0.1` +2. If something goes wrong: + - open the GitHub repository and delete [created tag](https://github.com/equinor/radix-cli/tags/) (with release) + - delete it locally ` git tag -d v0.0.1` + - reset changes `git reset --hard` + - tag the commit againg and push: `git tag v0.0.1` and `git push origin v0.0.1` To generate a local version for debugging purposes, it can be built using: diff --git a/cmd/root.go b/cmd/root.go index c12399b..55d79f2 100644 --- a/cmd/root.go +++ b/cmd/root.go @@ -1,6 +1,7 @@ package cmd import ( + _ "embed" "errors" "fmt" "os" @@ -19,9 +20,9 @@ import ( const ( radixCLIError = "Error: Radix CLI executed with error" - version = "1.9.1" ) +var Version = "dev" var rootLongHelp = strings.TrimSpace(` A command line interface which allows you to interact with the Radix platform through automation. `) @@ -31,7 +32,7 @@ var rootCmd = &cobra.Command{ Use: "rx", Short: "Command line interface for Radix platform", Long: rootLongHelp, - Version: version, + Version: Version, } // Execute the top level command