徽章的含意 當你瀏覽一個開源項目時,看到各" />
時間:2023-06-24 16:36:02 | 來源:網(wǎng)站運營
時間:2023-06-24 16:36:02 來源:網(wǎng)站運營
GitHub 徽章制作:很早前寫過一篇關于Golang持續(xù)集成服務之Travis教程, 今天再寫寫關于 github 上常見的徽章是如何制作的. 讓你的開源項目更高大上, 讓你的代碼也更健壯.
當你瀏覽一個開源項目時,看到各種徽章, 有些徽章是直接反應這個開源庫的質(zhì)量和完整性等等.
github 于2018. 10月推薦 GitHub Actions 持續(xù)集成服務, 在此之前大家都是使用 https://travis-ci.org/ 持續(xù)集成服務, 之前我也寫過相關文章. Golang持續(xù)集成服務之Travis教程.持續(xù)集成和持續(xù)部署目前 github 官方自帶支持, 官方稱之為 GitHub Actions.
使用 GitHub Actions 后會在你的項目里自帶生成一個.github
文件夾, 即.github/workflows/go.yml
name: Go # 使用語言on: # 監(jiān)聽動作 push: # 監(jiān)聽 push 動作 branches: [ main ] # 監(jiān)聽哪個分支 branch pull_request: branches: [ main ]jobs: # 工作 job build: # 構(gòu)建動作 runs-on: ubuntu-latest # 基于 ubuntu 系統(tǒng) steps: - uses: actions/checkout@v2 - name: Set up Go uses: actions/setup-go@v2 with: go-version: 1.15 - name: Build # 構(gòu)建項目 run: go build -v ./... - name: Test # 運行用例 run: go test -v .
徽章的制作.https://github.com/yezihack/e/workflows/Go/badge.svg
https://github.com/yezihack/e
是項目的地址workflows/Go/badge.svg
中間的Go
是 https://github.com/yezihack/e/actions?query=workflow%3AGo 下的名稱. 需要注意區(qū)分大小寫.travis.yml
文件language: go # 使用語言.go: - 1.15.6 # 版本號, 支持多種版本號sudo: required # #有定制化開發(fā)環(huán)境需要,默認false,不開啟容器,編譯效率高 os: # 使用的操作系統(tǒng) - linux - osxnotifications: # 郵箱通知 email: freeit@126.comgo_import_path: # 使用Go需要導入的包. - github.com/gin-gonic/gin - github.com/pkg/errors - github.com/smartystreets/goconveybefore_install: # 主要安裝一些系統(tǒng)依賴, - go mod tidyinstall: true # 安裝, true跳過script: # 腳本執(zhí)行. - echo "run" - go test -race -coverprofile=coverage.txt -covermode=atomic - go test -v ./...after_success: # 上傳測試報告 - bash <(curl -s https://codecov.io/bash)
徽章制作https://pkg.go.dev/ 只針對Golang語言自動生成文檔打開網(wǎng)站直接輸入你項目的訪問地址, 自帶生成.
https://img.shields.io/badge/go.dev-reference-brightgreen?logo=go&logoColor=white&style=flat[](https://pkg.go.dev/github.com/yezihack/e)
https://goreportcard.com/badge/github.com/yezihack/e

關鍵詞:徽章
微信公眾號
版權所有? 億企邦 1997-2025 保留一切法律許可權利。