Skip to content

Commit

Permalink
Merge pull request #49 from open-sauced/beta
Browse files Browse the repository at this point in the history
chore: release 1.0.0
  • Loading branch information
jpmcb authored Oct 11, 2023
2 parents 146b6b7 + 156992b commit f27369e
Show file tree
Hide file tree
Showing 39 changed files with 2,097 additions and 216 deletions.
1 change: 1 addition & 0 deletions .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
@open-sauced/engineering
15 changes: 11 additions & 4 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,13 @@ jobs:
with:
app_id: ${{ secrets.OS_GITHUB_APP_ID }}
private_key: ${{ secrets.OS_GITHUB_APP_PRIVATE_KEY }}

- name: "☁️ checkout repository"
uses: actions/checkout@v3
with:
fetch-depth: 0

token: ${{ steps.generate_token.outputs.token }}

- name: "🔧 setup node"
uses: actions/setup-node@v3
with:
Expand All @@ -43,7 +45,6 @@ jobs:
outputs:
release-tag: ${{ steps.semantic-release.outputs.release-tag }}


build:
needs:
- release
Expand All @@ -59,7 +60,7 @@ jobs:
- name: Set up Go
uses: actions/setup-go@fac708d6674e30b6ba41289acaab6d4b75aa0753 # v4.0.1
with:
go-version: 1.21
go-version: 1.21.x

- name: Check out code
uses: actions/checkout@v3
Expand All @@ -68,5 +69,11 @@ jobs:
env:
GH_TOKEN: ${{ github.token }}
run: |
GOOS=${{ matrix.goos }} GOARCH=${{ matrix.goarch }} go build -ldflags="-s -w" -o build/pizza-${{ matrix.goos }}-${{ matrix.goarch }}
GOOS=${{ matrix.goos }} GOARCH=${{ matrix.goarch }} go build \
-ldflags="-s -w" \
-ldflags="-X 'github.com/open-sauced/pizza-cli/pkg/utils.writeOnlyPublicPosthogKey=${{ secrets.POSTHOG_WRITE_PUBLIC_KEY }}'" \
-ldflags="-X 'github.com/open-sauced/pizza-cli/pkg/utils.Version={{ needs.release.outputs.release-tag }}'" \
-ldflags="-X 'github.com/open-sauced/pizza-cli/pkg/utils.Sha=$(git rev-parse HEAD)'" \
-o build/pizza-${{ matrix.goos }}-${{ matrix.goarch }}
gh release upload ${{ needs.release.outputs.release-tag }} build/pizza-${{ matrix.goos }}-${{ matrix.goarch }}
8 changes: 4 additions & 4 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,11 @@ jobs:
- name: Set up Go
uses: actions/setup-go@fac708d6674e30b6ba41289acaab6d4b75aa0753 # v4.0.1
with:
go-version: 1.20.x
go-version: 1.21.x
- name: golangci-lint
uses: golangci/golangci-lint-action@v3
with:
version: v1.53
version: v1.54.2

test:
runs-on: ubuntu-latest
Expand All @@ -36,7 +36,7 @@ jobs:
- name: Set up Go
uses: actions/setup-go@fac708d6674e30b6ba41289acaab6d4b75aa0753 # v4.0.1
with:
go-version: 1.20.x
go-version: 1.21.x
- name: Test
run: make test

Expand All @@ -47,6 +47,6 @@ jobs:
- name: Set up Go
uses: actions/setup-go@fac708d6674e30b6ba41289acaab6d4b75aa0753 # v4.0.1
with:
go-version: 1.20.x
go-version: 1.21.x
- name: Build go binary
run: make build
1 change: 1 addition & 0 deletions .golangci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ linters:
- unconvert
- unused
- vet
- gci

run:
timeout: 5m
72 changes: 72 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
# 📦 open-sauced/pizza-cli changelog

[![conventional commits](https://img.shields.io/badge/conventional%20commits-1.0.0-yellow.svg)](https://conventionalcommits.org)
[![semantic versioning](https://img.shields.io/badge/semantic%20versioning-2.0.0-green.svg)](https://semver.org)

> All notable changes to this project will be documented in this file
## [1.0.0-beta.7](https://github.com/open-sauced/pizza-cli/compare/v1.0.0-beta.6...v1.0.0-beta.7) (2023-10-02)


### 🍕 Features

* provide repository insights ([#38](https://github.com/open-sauced/pizza-cli/issues/38)) ([dc148d6](https://github.com/open-sauced/pizza-cli/commit/dc148d6fe17b9aa96ad6951aefd0a7fd7cf0e160))

## [1.0.0-beta.6](https://github.com/open-sauced/pizza-cli/compare/v1.0.0-beta.5...v1.0.0-beta.6) (2023-09-27)


### 🐛 Bug Fixes

* Uses correct generated token when checking out cli repo in release ([#44](https://github.com/open-sauced/pizza-cli/issues/44)) ([1e0c9f1](https://github.com/open-sauced/pizza-cli/commit/1e0c9f1ef3c9d0d9bd7f590f6bec021707f4c833))

## [1.0.0-beta.5](https://github.com/open-sauced/pizza-cli/compare/v1.0.0-beta.4...v1.0.0-beta.5) (2023-09-27)


### 🍕 Features

* Pizza show ([#24](https://github.com/open-sauced/pizza-cli/issues/24)) ([72f21ce](https://github.com/open-sauced/pizza-cli/commit/72f21ce260ec73c3ea0d7e97ed1411a86bb1d753))

## [1.0.0-beta.4](https://github.com/open-sauced/pizza-cli/compare/v1.0.0-beta.3...v1.0.0-beta.4) (2023-09-06)


### 🍕 Features

* provide repository contributors insights ([#30](https://github.com/open-sauced/pizza-cli/issues/30)) ([d16091f](https://github.com/open-sauced/pizza-cli/commit/d16091ff4ee2ad74e025779b27321897d2c8a49c))

## [1.0.0-beta.3](https://github.com/open-sauced/pizza-cli/compare/v1.0.0-beta.2...v1.0.0-beta.3) (2023-08-31)


### 🍕 Features

* Version command for CLI based on release builds ([#36](https://github.com/open-sauced/pizza-cli/issues/36)) ([9f3eedc](https://github.com/open-sauced/pizza-cli/commit/9f3eedcf7dac1d72f91ae40a5a09df3ee341a99c))

## [1.0.0-beta.2](https://github.com/open-sauced/pizza-cli/compare/v1.0.0-beta.1...v1.0.0-beta.2) (2023-08-29)


### 🍕 Features

* Add posthog telemetry integration ([#37](https://github.com/open-sauced/pizza-cli/issues/37)) ([9829f49](https://github.com/open-sauced/pizza-cli/commit/9829f499dad0651ec97d0969e040d2acc30714e0))

## 1.0.0-beta.1 (2023-08-22)


### 🤖 Build System

* sematic bin release, npm ([7b4607e](https://github.com/open-sauced/pizza-cli/commit/7b4607e9a4aa5eba0b5f163c586520c1022494ee))


### 🍕 Features

* Add install instructions and script for pizza CLI ([#26](https://github.com/open-sauced/pizza-cli/issues/26)) ([421a429](https://github.com/open-sauced/pizza-cli/commit/421a429ed99cca957365106485da97e085b0f173))
* cli auth ([#21](https://github.com/open-sauced/pizza-cli/issues/21)) ([34728fb](https://github.com/open-sauced/pizza-cli/commit/34728fb62d01b746ffc8ede3c97a090b32b0b9f9))
* GitHub action to build and upload Go artifacts after release created ([#22](https://github.com/open-sauced/pizza-cli/issues/22)) ([ad187a9](https://github.com/open-sauced/pizza-cli/commit/ad187a9f3229e41785a09130132a799378c04528))
* Http Client for accessing OpenSauced API client ([#23](https://github.com/open-sauced/pizza-cli/issues/23)) ([ec2b357](https://github.com/open-sauced/pizza-cli/commit/ec2b35789a2864d38bf63e0ec1a3b68393a34e9b))
* Leverage the GITHUB_APP_TOKEN for releases ([#32](https://github.com/open-sauced/pizza-cli/issues/32)) ([e0a25e0](https://github.com/open-sauced/pizza-cli/commit/e0a25e003e89a7a5173ecaae12366922365243c9))
* npm i -g pizza ([73291d1](https://github.com/open-sauced/pizza-cli/commit/73291d13d632b709f2583d834aefe6ad758de8d7))
* repo-query support ([199cfd7](https://github.com/open-sauced/pizza-cli/commit/199cfd7b04e1e1683cce5abc08c57bbef01644f6))
* update bin name release.yaml ([6b21cb8](https://github.com/open-sauced/pizza-cli/commit/6b21cb84f88f75467ce6f270e136dfca5e462d23))


### 🔁 Continuous Integration

* Update @open-sauced/release@2.2.1 and compliance.yaml ([#33](https://github.com/open-sauced/pizza-cli/issues/33)) ([146b6b7](https://github.com/open-sauced/pizza-cli/commit/146b6b7485a0f33090a4ccefd23624f9aa0df085))
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ lint:
--rm \
-v ./:/app \
-w /app \
golangci/golangci-lint:v1.53.3 \
golangci/golangci-lint:v1.54.2 \
golangci-lint run -v

test:
Expand Down
9 changes: 8 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,18 @@ Available Commands:
bake Use a pizza-oven to source git commits into OpenSauced
completion Generate the autocompletion script for the specified shell
help Help about any command
insights Gather insights about git contributors, repositories, users and pull requests
login Log into the CLI application via GitHub
repo-query Ask questions about a GitHub repository
show Get visual metrics of a repository
version Displays the build version of the CLI
Flags:
-h, --help help for pizza
--beta Shorthand for using the beta OpenSauced API endpoint ("https://beta.api.opensauced.pizza"). Supersedes the '--endpoint' flag
--disable-telemetry Disable sending telemetry data to OpenSauced
-e, --endpoint string The API endpoint to send requests to (default "https://api.opensauced.pizza")
-h, --help help for pizza
-o, --output string The formatting style for command output (default "table")
Use "pizza [command] --help" for more information about a command.
```
Expand Down
47 changes: 38 additions & 9 deletions cmd/auth/auth.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,34 +20,63 @@ import (

"github.com/cli/browser"
"github.com/open-sauced/pizza-cli/pkg/constants"
"github.com/open-sauced/pizza-cli/pkg/utils"
"github.com/spf13/cobra"
)

//go:embed success.html
var successHTML string

const loginLongDesc string = `Log into OpenSauced.
// Options are the persistent options for the login command
type Options struct {
// telemetry for capturing CLI events
telemetry *utils.PosthogCliClient
}

const (
sessionFileName = "session.json"
loginLongDesc = `Log into OpenSauced.
This command initiates the GitHub auth flow to log you into the OpenSauced application by launching your browser`
)

func NewLoginCommand() *cobra.Command {
opts := &Options{}

cmd := &cobra.Command{
Use: "login",
Short: "Log into the CLI application via GitHub",
Long: loginLongDesc,
Args: cobra.NoArgs,
RunE: func(cmd *cobra.Command, args []string) error {
return run()
username, err := run()

disableTelem, _ := cmd.Flags().GetBool(constants.FlagNameTelemetry)

if !disableTelem {
opts.telemetry = utils.NewPosthogCliClient()
defer opts.telemetry.Done()

if err != nil {
opts.telemetry.CaptureFailedLogin()
} else {
opts.telemetry.CaptureLogin(username)
}
}

return err
},
}

return cmd
}

func run() error {
func run() (string, error) {
username := ""

codeVerifier, codeChallenge, err := pkce(codeChallengeLength)
if err != nil {
return fmt.Errorf("PKCE error: %v", err.Error())
return "", fmt.Errorf("PKCE error: %v", err.Error())
}

supabaseAuthURL := fmt.Sprintf("https://%s.supabase.co/auth/v1/authorize", supabaseID)
Expand Down Expand Up @@ -95,7 +124,7 @@ func run() error {
return
}

filePath := path.Join(dirName, constants.SessionFileName)
filePath := path.Join(dirName, sessionFileName)
if err := os.WriteFile(filePath, jsonData, 0o600); err != nil {
http.Error(w, "Error writing to file", http.StatusInternalServerError)
return
Expand All @@ -107,7 +136,7 @@ func run() error {
fmt.Println("Error writing response:", err.Error())
}

username := sessionData.User.UserMetadata["user_name"]
username = sessionData.User.UserMetadata["user_name"].(string)
fmt.Println("🎉 Login successful 🎉")
fmt.Println("Welcome aboard", username, "🍕")
})
Expand All @@ -130,17 +159,17 @@ func run() error {
select {
case err := <-errCh:
if err != nil && err != http.ErrServerClosed {
return err
return "", err
}
case <-time.After(60 * time.Second):
shutdown(server)
return errors.New("authentication timeout")
return "", errors.New("authentication timeout")
case <-interruptCh:
fmt.Println("\nAuthentication interrupted❗️")
shutdown(server)
os.Exit(0)
}
return nil
return username, nil
}

func getSession(authCode, codeVerifier string) (*accessTokenResponse, error) {
Expand Down
Loading

0 comments on commit f27369e

Please sign in to comment.