Skip to content

Commit

Permalink
added ci workflows
Browse files Browse the repository at this point in the history
  • Loading branch information
izqalan committed Apr 1, 2024
1 parent 9a28d24 commit 9cb420b
Show file tree
Hide file tree
Showing 4 changed files with 99 additions and 6 deletions.
41 changes: 41 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# .github/workflows/release.yml
name: goreleaser

on:
pull_request:
push:
# run only against tags
tags:
- "*"

permissions:
contents: write
# packages: write
# issues: write

jobs:
goreleaser:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: stable
# More assembly might be required: Docker logins, GPG, etc.
# It all depends on your needs.
- name: Run GoReleaser
uses: goreleaser/goreleaser-action@v5
with:
# either 'goreleaser' (default) or 'goreleaser-pro'
distribution: goreleaser
# 'latest', 'nightly', or a semver
version: latest
args: release --clean
env:
GITHUB_TOKEN: ${{ secrets.PUBLISHER_TOKEN }}
# Your GoReleaser Pro key, if you are using the 'goreleaser-pro' distribution
# GORELEASER_KEY: ${{ secrets.GORELEASER_KEY }}
32 changes: 32 additions & 0 deletions .goreleaser.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
builds:
- binary: firehouse
goos:
- darwin
- linux
goarch:
- amd64
- arm64
env:
- CGO_ENABLED=0
flags:
- -mod=vendor

release:
prerelease: auto

universal_binaries:
- replace: true

brews:
-
name: firehouse
homepage: "https://github.com/izqalan/firehouse"
tap:
owner: izqalan
name: homebrew-izqalan
commit_author:
name: izqalan
email: [email protected]

checksum:
name_template: 'checksums.txt'
19 changes: 16 additions & 3 deletions cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,11 @@ func initService() {

rootCmd.AddCommand(serviceCmd)
serviceCmd.Flags().StringP("service-account", "s", "", "Path to the Firebase service account JSON file")
serviceCmd.MarkFlagRequired("service-account")
err := serviceCmd.MarkFlagRequired("service-account")
if err != nil {
log.Println("Error marking flag as required:", err)
return
}

getCmd := &cobra.Command{
Use: "get",
Expand Down Expand Up @@ -183,20 +187,29 @@ func initAuth() {
// prompt confirmation
fmt.Printf("Are you sure you want to delete user %s? (y/n): ", uid)
var confirm string
fmt.Scanln(&confirm)
scan, err := fmt.Scanln(&confirm)
if err != nil {
return err
}
if scan != 1 {
fmt.Println("Invalid input")
return nil
}
if confirm != "y" {
fmt.Println("Operation cancelled")
return nil
}

err := auth.DeleteUser(uid)
err = auth.DeleteUser(uid)
if err != nil {
return err
}
return nil
},
}

rootCmd.Flags().StringP("version", "v", "0.0.1", "Version of the CLI")

rootCmd.AddCommand(authCmd)

authCmd.AddCommand(authCreateCmd)
Expand Down
13 changes: 10 additions & 3 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,20 @@ func init() {
// if file not found, create a new one
if err != nil {
fmt.Println("Config file not found, creating a new one")
viper.WriteConfig()
err := viper.WriteConfig()
if err != nil {
fmt.Println("Error creating config file:", err)
return
}
}

utils.NewFirebaseClient()
}

func main() {
cmd.Execute()

err := cmd.Execute()
if err != nil {
fmt.Println("Error executing command:", err)
return
}
}

0 comments on commit 9cb420b

Please sign in to comment.