Skip to content

Commit

Permalink
feat: become a gh extension
Browse files Browse the repository at this point in the history
  • Loading branch information
jef committed Sep 29, 2022
1 parent 589b24c commit 971f0ce
Show file tree
Hide file tree
Showing 9 changed files with 288 additions and 592 deletions.
6 changes: 3 additions & 3 deletions .github/ISSUE_TEMPLATE/config.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
blank_issues_enabled: false
contact_links:
- name: 💡 Have an idea for a new feature?
url: https://github.com/jef/stargazer-vanity/discussions
url: https://github.com/jef/gh-vanity/discussions
about: Create a new idea discussion!
- name: 🙇 Need help with stargazer-vanity?
url: https://github.com/jef/stargazer-vanity/discussions
- name: 🙇 Need help with gh-vanity?
url: https://github.com/jef/gh-vanity/discussions
about: Create a new help discussion if it hasn't been asked before!
32 changes: 10 additions & 22 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,36 +9,24 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v2
uses: actions/checkout@v3
- name: Setup Go
uses: actions/setup-go@v2
uses: actions/setup-go@v3
with:
go-version: '1.16'
- name: Setup build cache
uses: actions/cache@v2
with:
path: ~/go/pkg/mod
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
restore-keys: ${{ runner.os }}-go-
go-version: "1.19"
- name: Build service
run: make
run: go build
lint:
name: Lint
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v2
uses: actions/checkout@v3
- name: Setup Go
uses: actions/setup-go@v2
with:
go-version: '1.16'
- name: Setup build cache
uses: actions/cache@v2
uses: actions/setup-go@v3
with:
path: ~/go/pkg/mod
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
restore-keys: ${{ runner.os }}-go-
go-version: "1.19"
- name: Lint
run: |
go get -u golang.org/x/lint/golint
golint -set_exit_status
uses: golangci/golangci-lint-action@v3
with:
args: --enable dupl,gofmt,revive
65 changes: 17 additions & 48 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,60 +4,29 @@ on:
branches:
- main
jobs:
build-tag-release:
name: Build, tag, and release assets
release:
name: Create release
runs-on: ubuntu-latest
outputs:
release_created: ${{ steps.release.outputs.release_created }}
steps:
- name: Checkout repository
uses: actions/checkout@v2
uses: actions/checkout@v3
- name: Setup release please
uses: google-github-actions/release-please-action@v2
id: release
uses: google-github-actions/release-please-action@v3
with:
token: ${{ secrets.GITHUB_TOKEN }}
release-type: simple
package-name: stargazer-vanity
- name: Retrieve latest tag
run: echo "TAG=$(cat version.txt)" >> $GITHUB_ENV
- name: Setup Go
uses: actions/setup-go@v2
with:
go-version: '1.16'
- name: Setup build cache
uses: actions/[email protected]
with:
path: ~/go/pkg/mod
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
restore-keys: ${{ runner.os }}-go-
- name: Build release assets
run: make dist
- name: Upload Windows asset
if: ${{ steps.release.outputs.release_created }}
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.release.outputs.upload_url }}
asset_path: ./stargazer-vanity.exe
asset_name: sgv-windows-amd64.exe
asset_content_type: application/octet-stream
- name: Upload Linux asset
if: ${{ steps.release.outputs.release_created }}
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.release.outputs.upload_url }}
asset_path: ./stargazer-vanity.linux
asset_name: sgv-linux-amd64
asset_content_type: application/octet-stream
- name: Upload macOS asset
if: ${{ steps.release.outputs.release_created }}
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
package-name: gh-vanity
upload_assets:
name: Upload assets
runs-on: ubuntu-latest
needs: release
if: needs.release.outputs.release_created == 'true'
steps:
- name: Checkout repository
uses: actions/checkout@v3
- uses: cli/gh-extension-precompile@v1
with:
upload_url: ${{ steps.release.outputs.upload_url }}
asset_path: ./stargazer-vanity.darwin
asset_name: sgv-darwin-amd64
asset_content_type: application/octet-stream
go_version: "1.19"
9 changes: 5 additions & 4 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
.idea/
dist/

coverage.out
report.json
gh-vanity

# Binaries for programs and plugins
stargazer-vanity
*.exe
*.darwin
*.linux
Expand All @@ -15,6 +19,3 @@ stargazer-vanity

# Output of the go coverage tool, specifically when used with LiteIDE
*.out

# Dependency directories (remove the comment below to include it)
# vendor/
15 changes: 0 additions & 15 deletions Makefile

This file was deleted.

87 changes: 53 additions & 34 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,54 +1,73 @@
# stargazer-vanity [![Release](https://img.shields.io/github/workflow/status/jef/stargazer-vanity/Release?color=24292e&label=Release&logo=github&logoColor=white&style=flat-square)](https://github.com/jef/stargazer-vanity/actions/workflows/release.yaml)

> **star·gaz·er** `/ˈstärˌɡāzər/` Someone that has starred a repository.
>
> **van·i·ty** `/ˈvanədē/` Excessive pride in or admiration of one's own appearance or achievements.
# gh-vanity [![Release](https://github.com/jef/gh-vanity/actions/workflows/release.yaml/badge.svg)](https://github.com/jef/gh-vanity/actions/workflows/release.yaml)

I created this out of pure vanity, hence the name. I was curious as to who has starred my repositories (and others) and what companies they worked for.

This allows programs lets a user understand that data without parsing through _many_ pages of stargazers.

## Installation

Download the specific binary from [GitHub Releases](https://github.com/jef/stargazer-vanity/releases) or use `go get`:
1. Install the `gh` cli - see the [installation](https://github.com/cli/cli#installation)

```shell
go get -u github.com/jef/stargazer-vanity
```
_Installation requires a minimum version (2.0.0) of the GitHub CLI that supports extensions._

## Usage
2. Install this extension:

It is required that you use a GitHub Personal Access Token (PAT). You can generate one [here](https://github.com/settings/tokens/new). The required scopes are `['read:org', 'user:email', 'read:user']`. Set your PAT to environment variable `GITHUB_PAT`. If `GITHUB_PAT` isn't set, you will be prompted for your PAT in the beginning of startup.
```shell
gh extension install jef/gh-vanity
```

```
Usage of ./stargazer-vanity:
-company string
Filter stargazers by company name(s). Can be comma separated.
If no names are given, then all stargazers will output.
-employee
Filter stargazers that are GitHub employees.
-repo string
(Required) The name of the repository.
-owner string
(Required) The owner or organization of the repository.
```
<details>
<summary><strong>Manual Installation</strong></summary>

### Examples
Requirements: `cli/cli` and `go`.

Filter Amazon, Google, and GitHub employees for [cli/cli](https://github.com/cli/cli):
1. Clone the repository

```
./stargazer-vanity -company=amazon,google -employee -owner=cli -repo=cli
```
```shell
# git
git clone [email protected]:jef/gh-vanity.git
# GitHub CLI
gh repo clone jef/gh-vanity
```

2. `cd` into it

```shell
cd gh-vanity
```

3. Build it

Filter Nvidia employees for [jef/streetmerchant](https://github.com/jef/streetmerchant):
```shell
make build
```

4. Install it locally

```shell
gh extension install .
```
</details>

## Usage

To run:

```shell
gh vanity
```
./stargazer-vanity -company=nvidia -owner=jef -repo=streetmerchant

To upgrade:

```sh
gh extension upgrade vanity
```

## Development
### Examples

Filter Amazon, Google, and GitHub employees for [jef/streetmerchant](https://github.com/jef/streetmerchant):

- `make build`: Builds source
- `make clean`: Cleans executable
- `make dist`: Cross-compilation for distribution
```shell
gh vanity --company=amazon,google --employee --owner=jef --name=streetmerchant
```
6 changes: 3 additions & 3 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
module github.com/jef/stargazer-vanity
module github.com/jef/gh-vanity

go 1.16

require (
github.com/cli/go-gh v0.1.1
github.com/shurcooL/graphql v0.0.0-20200928012149-18c5c3165e3a
golang.org/x/crypto v0.0.0-20201221181555-eec23a3978ad
golang.org/x/oauth2 v0.0.0-20201208152858-08078c50e5b5
github.com/spf13/cobra v1.5.0
)
Loading

0 comments on commit 971f0ce

Please sign in to comment.