Skip to content

Commit 971f0ce

Browse files
committed
feat: become a gh extension
1 parent 589b24c commit 971f0ce

File tree

9 files changed

+288
-592
lines changed

9 files changed

+288
-592
lines changed

.github/ISSUE_TEMPLATE/config.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
blank_issues_enabled: false
22
contact_links:
33
- name: 💡 Have an idea for a new feature?
4-
url: https://github.com/jef/stargazer-vanity/discussions
4+
url: https://github.com/jef/gh-vanity/discussions
55
about: Create a new idea discussion!
6-
- name: 🙇 Need help with stargazer-vanity?
7-
url: https://github.com/jef/stargazer-vanity/discussions
6+
- name: 🙇 Need help with gh-vanity?
7+
url: https://github.com/jef/gh-vanity/discussions
88
about: Create a new help discussion if it hasn't been asked before!

.github/workflows/ci.yaml

Lines changed: 10 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -9,36 +9,24 @@ jobs:
99
runs-on: ubuntu-latest
1010
steps:
1111
- name: Checkout repository
12-
uses: actions/checkout@v2
12+
uses: actions/checkout@v3
1313
- name: Setup Go
14-
uses: actions/setup-go@v2
14+
uses: actions/setup-go@v3
1515
with:
16-
go-version: '1.16'
17-
- name: Setup build cache
18-
uses: actions/cache@v2
19-
with:
20-
path: ~/go/pkg/mod
21-
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
22-
restore-keys: ${{ runner.os }}-go-
16+
go-version: "1.19"
2317
- name: Build service
24-
run: make
18+
run: go build
2519
lint:
2620
name: Lint
2721
runs-on: ubuntu-latest
2822
steps:
2923
- name: Checkout repository
30-
uses: actions/checkout@v2
24+
uses: actions/checkout@v3
3125
- name: Setup Go
32-
uses: actions/setup-go@v2
33-
with:
34-
go-version: '1.16'
35-
- name: Setup build cache
36-
uses: actions/cache@v2
26+
uses: actions/setup-go@v3
3727
with:
38-
path: ~/go/pkg/mod
39-
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
40-
restore-keys: ${{ runner.os }}-go-
28+
go-version: "1.19"
4129
- name: Lint
42-
run: |
43-
go get -u golang.org/x/lint/golint
44-
golint -set_exit_status
30+
uses: golangci/golangci-lint-action@v3
31+
with:
32+
args: --enable dupl,gofmt,revive

.github/workflows/release.yaml

Lines changed: 17 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -4,60 +4,29 @@ on:
44
branches:
55
- main
66
jobs:
7-
build-tag-release:
8-
name: Build, tag, and release assets
7+
release:
8+
name: Create release
99
runs-on: ubuntu-latest
10+
outputs:
11+
release_created: ${{ steps.release.outputs.release_created }}
1012
steps:
1113
- name: Checkout repository
12-
uses: actions/checkout@v2
14+
uses: actions/checkout@v3
1315
- name: Setup release please
14-
uses: google-github-actions/release-please-action@v2
1516
id: release
17+
uses: google-github-actions/release-please-action@v3
1618
with:
1719
token: ${{ secrets.GITHUB_TOKEN }}
1820
release-type: simple
19-
package-name: stargazer-vanity
20-
- name: Retrieve latest tag
21-
run: echo "TAG=$(cat version.txt)" >> $GITHUB_ENV
22-
- name: Setup Go
23-
uses: actions/setup-go@v2
24-
with:
25-
go-version: '1.16'
26-
- name: Setup build cache
27-
uses: actions/cache@v2.1.4
28-
with:
29-
path: ~/go/pkg/mod
30-
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
31-
restore-keys: ${{ runner.os }}-go-
32-
- name: Build release assets
33-
run: make dist
34-
- name: Upload Windows asset
35-
if: ${{ steps.release.outputs.release_created }}
36-
uses: actions/upload-release-asset@v1
37-
env:
38-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
39-
with:
40-
upload_url: ${{ steps.release.outputs.upload_url }}
41-
asset_path: ./stargazer-vanity.exe
42-
asset_name: sgv-windows-amd64.exe
43-
asset_content_type: application/octet-stream
44-
- name: Upload Linux asset
45-
if: ${{ steps.release.outputs.release_created }}
46-
uses: actions/upload-release-asset@v1
47-
env:
48-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
49-
with:
50-
upload_url: ${{ steps.release.outputs.upload_url }}
51-
asset_path: ./stargazer-vanity.linux
52-
asset_name: sgv-linux-amd64
53-
asset_content_type: application/octet-stream
54-
- name: Upload macOS asset
55-
if: ${{ steps.release.outputs.release_created }}
56-
uses: actions/upload-release-asset@v1
57-
env:
58-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
21+
package-name: gh-vanity
22+
upload_assets:
23+
name: Upload assets
24+
runs-on: ubuntu-latest
25+
needs: release
26+
if: needs.release.outputs.release_created == 'true'
27+
steps:
28+
- name: Checkout repository
29+
uses: actions/checkout@v3
30+
- uses: cli/gh-extension-precompile@v1
5931
with:
60-
upload_url: ${{ steps.release.outputs.upload_url }}
61-
asset_path: ./stargazer-vanity.darwin
62-
asset_name: sgv-darwin-amd64
63-
asset_content_type: application/octet-stream
32+
go_version: "1.19"

.gitignore

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
11
.idea/
2+
dist/
3+
4+
coverage.out
5+
report.json
6+
gh-vanity
27

38
# Binaries for programs and plugins
4-
stargazer-vanity
59
*.exe
610
*.darwin
711
*.linux
@@ -15,6 +19,3 @@ stargazer-vanity
1519

1620
# Output of the go coverage tool, specifically when used with LiteIDE
1721
*.out
18-
19-
# Dependency directories (remove the comment below to include it)
20-
# vendor/

Makefile

Lines changed: 0 additions & 15 deletions
This file was deleted.

README.md

Lines changed: 53 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,54 +1,73 @@
1-
# 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)
2-
3-
> **star·gaz·er** `/ˈstärˌɡāzər/` Someone that has starred a repository.
4-
>
5-
> **van·i·ty** `/ˈvanədē/` Excessive pride in or admiration of one's own appearance or achievements.
1+
# 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)
62

73
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.
84

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

117
## Installation
128

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

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

19-
## Usage
13+
2. Install this extension:
2014

21-
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.
15+
```shell
16+
gh extension install jef/gh-vanity
17+
```
2218

23-
```
24-
Usage of ./stargazer-vanity:
25-
-company string
26-
Filter stargazers by company name(s). Can be comma separated.
27-
If no names are given, then all stargazers will output.
28-
-employee
29-
Filter stargazers that are GitHub employees.
30-
-repo string
31-
(Required) The name of the repository.
32-
-owner string
33-
(Required) The owner or organization of the repository.
34-
```
19+
<details>
20+
<summary><strong>Manual Installation</strong></summary>
3521

36-
### Examples
22+
Requirements: `cli/cli` and `go`.
3723

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

40-
```
41-
./stargazer-vanity -company=amazon,google -employee -owner=cli -repo=cli
42-
```
26+
```shell
27+
# git
28+
git clone git@github.com:jef/gh-vanity.git
29+
30+
# GitHub CLI
31+
gh repo clone jef/gh-vanity
32+
```
33+
34+
2. `cd` into it
35+
36+
```shell
37+
cd gh-vanity
38+
```
39+
40+
3. Build it
4341

44-
Filter Nvidia employees for [jef/streetmerchant](https://github.com/jef/streetmerchant):
42+
```shell
43+
make build
44+
```
4545

46+
4. Install it locally
47+
48+
```shell
49+
gh extension install .
50+
```
51+
</details>
52+
53+
## Usage
54+
55+
To run:
56+
57+
```shell
58+
gh vanity
4659
```
47-
./stargazer-vanity -company=nvidia -owner=jef -repo=streetmerchant
60+
61+
To upgrade:
62+
63+
```sh
64+
gh extension upgrade vanity
4865
```
4966

50-
## Development
67+
### Examples
68+
69+
Filter Amazon, Google, and GitHub employees for [jef/streetmerchant](https://github.com/jef/streetmerchant):
5170

52-
- `make build`: Builds source
53-
- `make clean`: Cleans executable
54-
- `make dist`: Cross-compilation for distribution
71+
```shell
72+
gh vanity --company=amazon,google --employee --owner=jef --name=streetmerchant
73+
```

go.mod

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
module github.com/jef/stargazer-vanity
1+
module github.com/jef/gh-vanity
22

33
go 1.16
44

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

0 commit comments

Comments
 (0)