Skip to content

Commit

Permalink
Merge pull request #4 from coherenceplatform/aa/fix-auth-and-add-more…
Browse files Browse the repository at this point in the history
…-builds

Add builds and fix auth host
  • Loading branch information
adamaziz15 authored Nov 27, 2023
2 parents b7eb66a + 8b06fd0 commit 9797209
Show file tree
Hide file tree
Showing 5 changed files with 70 additions and 5 deletions.
22 changes: 22 additions & 0 deletions .github/workflows/build-and-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,28 @@ jobs:
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Upload Release Asset (linux/386)
id: upload-release-asset-linux-386
uses: actions/upload-release-asset@v1
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./cocli-linux-386
asset_name: cocli-linux-386
asset_content_type: application/octet-stream
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Upload Release Asset (linux/amd64)
id: upload-release-asset-linux-amd64
uses: actions/upload-release-asset@v1
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./cocli-linux-amd64
asset_name: cocli-linux-amd64
asset_content_type: application/octet-stream
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Upload Release Asset (windows/arm64)
id: upload-release-asset-windows-arm64
uses: actions/upload-release-asset@v1
Expand Down
2 changes: 1 addition & 1 deletion cocli_build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ if [[ -z "$package_name" ]]; then
exit 1
fi

platforms=("darwin/arm64" "linux/arm64" "windows/amd64")
platforms=("darwin/arm64" "linux/arm64" "linux/386" "linux/amd64" "windows/amd64")

for platform in "${platforms[@]}"
do
Expand Down
2 changes: 1 addition & 1 deletion cocli_version.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.0.1
0.0.2
45 changes: 44 additions & 1 deletion pkg/cocli/cliVersionCheck.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ import (
"fmt"
"io"
"net/http"
"strconv"
"strings"
)

type CoherenceMetadata struct {
Expand Down Expand Up @@ -37,9 +39,50 @@ func RunCliVersionCheck() {

metadata := &CoherenceMetadata{}
json.Unmarshal(bodyBytes, &metadata)
if GetCliVersion() != metadata.CliApiVersion {

parsedCliVersion, err := semverToFloat(GetCliVersion())
if err != nil {
panic(err)
}
parsedMetaCliVersion, err := semverToFloat(metadata.CliApiVersion)
if err != nil {
panic(err)
}

if parsedCliVersion < parsedMetaCliVersion {
fmt.Print("WARNING: There is a newer version of cocli available. Some commands may not work as expected until you update your cocli version\n\n")
}

return
}

func semverToFloat(version string) (float64, error) {
// Split the version string into major and minor parts using the dot as the separator
parts := strings.Split(version, ".")

if len(parts) < 2 {
return 0.0, fmt.Errorf("Invalid semver version string: %s", version)
}

// Parse the major component into an integer
major, err := strconv.Atoi(parts[0])
if err != nil {
return 0.0, err
}

// Parse the minor component into a float
minorParts := strings.Split(parts[1], "")
if len(minorParts) == 0 {
return 0.0, fmt.Errorf("Invalid semver version string: %s", version)
}

minorFloat, err := strconv.ParseFloat("0."+strings.Join(minorParts, ""), 64)
if err != nil {
return 0.0, err
}

// Combine major and minor components into a float
versionFloat := float64(major) + minorFloat

return versionFloat, nil
}
4 changes: 2 additions & 2 deletions pkg/cocli/cocli.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,12 @@ var devConfig = &CocliConfig{

var prodConfig = &CocliConfig{
ClientID: "YfsRrC0cs29oEMc6Md9QtRopYLWa3785",
AuthDomain: "coherenceplatform.us.auth0.com",
AuthDomain: "auth.withcoherence.com",
CoherenceDomain: "app.withcoherence.com",
}

const (
cliVersion = "0.0.1"
cliVersion = "0.0.2"
credsFilename = "~/.cocli/.authtoken"
)

Expand Down

0 comments on commit 9797209

Please sign in to comment.