Skip to content

Commit

Permalink
feat: init and rush with no test code 😉
Browse files Browse the repository at this point in the history
  • Loading branch information
sunggun-yu committed Oct 21, 2022
0 parents commit 134a416
Show file tree
Hide file tree
Showing 17 changed files with 673 additions and 0 deletions.
7 changes: 7 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
version: 2
updates:
- package-ecosystem: "gomod"
open-pull-requests-limit: 30
directory: "/"
schedule:
interval: "daily"
70 changes: 70 additions & 0 deletions .github/workflows/codeql-analysis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
# For most projects, this workflow file will not need changing; you simply need
# to commit it to your repository.
#
# You may wish to alter this file to override the set of languages analyzed,
# or to provide custom queries or build logic.
#
# ******** NOTE ********
# We have attempted to detect the languages in your repository. Please check
# the `language` matrix defined below to confirm you have the correct set of
# supported CodeQL languages.
#
name: "CodeQL"

on:
push:
branches: [ main ]
pull_request:
# The branches below must be a subset of the branches above
branches: [ main ]
schedule:
- cron: '32 8 * * 3'

jobs:
analyze:
name: Analyze
runs-on: ubuntu-latest
permissions:
actions: read
contents: read
security-events: write

strategy:
fail-fast: false
matrix:
language: [ 'go' ]
# CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python', 'ruby' ]
# Learn more about CodeQL language support at https://git.io/codeql-language-support

steps:
- name: Checkout repository
uses: actions/checkout@v2

# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
uses: github/codeql-action/init@v1
with:
languages: ${{ matrix.language }}
# If you wish to specify custom queries, you can do so here or in a config file.
# By default, queries listed here will override any specified in a config file.
# Prefix the list here with "+" to use these queries and those in the config file.
# queries: ./path/to/local/query, your-org/your-repo/queries@main

# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
# If this step fails, then you should remove it and run the build manually (see below)
- name: Autobuild
uses: github/codeql-action/autobuild@v1

# ℹ️ Command-line programs to run using the OS shell.
# 📚 https://git.io/JvXDl

# ✏️ If the Autobuild fails above, remove it and uncomment the following three lines
# and modify them (or add more) to build your code if your project
# uses a compiled language

#- run: |
# make bootstrap
# make release

- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v1
37 changes: 37 additions & 0 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
name: release

on:
push:
tags:
- '*'

permissions:
contents: write

jobs:
goreleaser:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Set up Go
uses: actions/setup-go@v2
with:
go-version: 1.19
- name: Generate token
id: generate_token
uses: tibdex/github-app-token@v1
with:
app_id: ${{ secrets.APP_ID }}
private_key: ${{ secrets.PRIVATE_KEY }}
repository: sunggun-yu/homebrew-tap
- name: Run GoReleaser
uses: goreleaser/goreleaser-action@v2
with:
distribution: goreleaser
version: latest
args: release --rm-dist
env:
GITHUB_TOKEN: ${{ steps.generate_token.outputs.token }}
25 changes: 25 additions & 0 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
name: test

on:
push:
pull_request:
branches: [ main ]

jobs:
test:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Set up Go
uses: actions/setup-go@v2
with:
go-version: 1.19
- name: Run go mod tidy
run: go mod tidy
- name: Run Test
run: go test ./... -coverprofile=coverage.out -covermode=atomic
- name: Upload coverage to Codecov
run: bash <(curl -s https://codecov.io/bash)
34 changes: 34 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# IDEs
.idea
.vscode

# Binaries for programs and plugins
*.exe
*.exe~
*.dll
*.so
*.dylib

# Test binary, built with `go test -c`
*.test

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

bin/*
!bin/.keep

dist/*
!dist/.keep

# exclude generate secret file
pkg/embeded/secrets

# Dependency directories (remove the comment below to include it)
vendor/

# custom
backup
.history
*.token
*.pem
60 changes: 60 additions & 0 deletions .goreleaser.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
# This is an example .goreleaser.yml file with some sensible defaults.
# Make sure to check the documentation at https://goreleaser.com

project_name: gh-app-access-token

before:
hooks:
- go mod tidy
builds:
- env:
- CGO_ENABLED=0
binary: "{{ .ProjectName }}"
goos:
- linux
- windows
- darwin
goarch:
- amd64
- arm64
goarm:
- "6"
- "7"
ignore:
- goos: windows
goarch: arm64
archives:
- format: tar.gz
wrap_in_directory: "true"
format_overrides:
- goos: windows
format: zip
checksum:
name_template: 'checksums.txt'
algorithm: sha256
snapshot:
name_template: "{{ incpatch .Version }}-next"
changelog:
sort: asc
filters:
exclude:
- '^docs:'
- '^test:'
- "README"
- "Merge pull request"
- "Merge branch"

brews:
- name: "gh-app-access-token"
tap:
owner: sunggun-yu
name: homebrew-tap
branch: main
description: "Cli wrapper to set profile based environment variables for your command line execution"
homepage: https://github.com/sunggun-yu/gh-app-access-token-cli
folder: Formula
download_strategy: CurlDownloadStrategy
install: |
bin.install "{{ .ProjectName }}"
test: |
system "#{bin}/{{ .ProjectName }} -v"
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2022 Sunggun Yu

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
74 changes: 74 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
# gh-app-access-token-cli

Simple Cli tool for operating Github App Installation access token

## Installation

brew:

```bash
brew install sunggun-yu/tap/gh-app-access-token
```

go install:

```bash
go install github.com/sunggun-yu/gh-app-access-token@<version>
```

## Usage

### Generate a Github App access token

```bash
# generate the Github App access token
gh-app-access-token generate \
--app-id [app-id] \
--installation-id [installation-id] \
--private-key [private-key-file-path]

# generate the Github App access token with file in HOME
gh-app-access-token generate \
--app-id [app-id] \
--installation-id [installation-id] \
--private-key $HOME/private-key.pem

# generate the Github App access token with file in HOME
gh-app-access-token generate \
--app-id [app-id] \
--installation-id [installation-id] \
--private-key ~/private-key.pem

# generate the Github App access token with text in private key file passed into stdin
cat [private-key-file-path] | gh-app-access-token generate \
--app-id [app-id] \
--installation-id [installation-id] \
--private-key -

# generate the Github App access token with private key text passed into stdin
echo "private-key-text" | gh-app-access-token generate \
--app-id [app-id] \
--installation-id [installation-id] \
--private-key -
```

>⚠️ Note/Warning
>
> it keeps waiting(hang) if there is no stdin.
### Revoke the Github App access token

```bash
# revoke token in argument
gh-app-access-token-cli revoke [access token string]

# revoke the token passed into stdin
cat [access-token-file] | gh-app-access-token-cli revoke -

# revoke the token passed into stdin
echo "access-token-value" | gh-app-access-token-cli revoke -
```

>⚠️ Note/Warning
>
> it keeps waiting(hang) if there is no stdin.
Loading

0 comments on commit 134a416

Please sign in to comment.