Skip to content

Commit e0f7d3d

Browse files
authored
feat: add GitHub Actions workflows for coverage generation and release process (#22)
1 parent e774f5f commit e0f7d3d

3 files changed

Lines changed: 107 additions & 0 deletions

File tree

.github/workflows/coverage.yml

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
name: Generate coverage badges
2+
on:
3+
push:
4+
branches: [main]
5+
6+
permissions:
7+
contents: write
8+
9+
jobs:
10+
generate-badges:
11+
runs-on: ubuntu-latest
12+
steps:
13+
- uses: actions/checkout@v4
14+
15+
# setup go environment
16+
- name: Set up Go
17+
uses: actions/setup-go@v5
18+
with:
19+
go-version: 1.24.x
20+
21+
- name: coverage
22+
id: coverage
23+
run: |
24+
go mod download
25+
go generate ./...
26+
go test -coverpkg=./... -coverprofile=profile.cov ./...
27+
sed -i '/cmd/d' profile.cov # remove cmd package from coverage
28+
total=$(go tool cover -func profile.cov | grep '^total:' | awk '{print $3}' | sed "s/%//")
29+
rm profile.cov
30+
echo "COVERAGE_VALUE=${total}" >> $GITHUB_ENV
31+
32+
- uses: actions/checkout@v4
33+
with:
34+
repository: sgaunet/gh-action-badge
35+
path: gh-action-badge
36+
ref: main
37+
fetch-depth: 1
38+
39+
- name: Generate coverage badge
40+
id: coverage-badge
41+
uses: ./gh-action-badge/.github/actions/gh-action-coverage
42+
with:
43+
limit-coverage: "70"
44+
badge-label: "coverage"
45+
badge-filename: "coverage-badge.svg"
46+
badge-value: "${COVERAGE_VALUE}"
47+
48+
- name: Print url of badge
49+
run: |
50+
echo "Badge URL: ${{ steps.coverage-badge.outputs.badge-url }}"

.github/workflows/release.yml

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
name: release
2+
3+
on:
4+
push:
5+
# Pattern matched against refs/tags
6+
tags:
7+
- '**' # Push events to every tag including hierarchical tags like v1.0/beta
8+
9+
permissions:
10+
contents: write
11+
packages: write
12+
13+
jobs:
14+
goreleaser-release:
15+
runs-on: ubuntu-latest
16+
steps:
17+
-
18+
name: Checkout
19+
uses: actions/checkout@v4
20+
with:
21+
fetch-depth: 0
22+
- name: Install Go
23+
uses: actions/setup-go@v5
24+
with:
25+
go-version: '>=1.24'
26+
- name: Install devbox
27+
uses: jetify-com/devbox-install-action@v0.13.0
28+
with:
29+
enable-cache: true
30+
devbox-version: 0.14.0
31+
32+
-
33+
# Add support for more platforms with QEMU (optional)
34+
# https://github.com/docker/setup-qemu-action
35+
name: Set up QEMU
36+
uses: docker/setup-qemu-action@v3
37+
-
38+
name: Set up Docker Buildx
39+
uses: docker/setup-buildx-action@v3
40+
41+
- name: Login to GitHub Container Registry
42+
uses: docker/login-action@v3
43+
with:
44+
registry: ghcr.io
45+
username: ${{ github.actor }}
46+
password: ${{ secrets.GITHUB_TOKEN }}
47+
48+
- name: Install prerequisites
49+
shell: /usr/bin/bash {0}
50+
run: |
51+
devbox install
52+
devbox run release
53+
env:
54+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
55+
# Your GoReleaser Pro key, if you are using the 'goreleaser-pro' distribution
56+
# GORELEASER_KEY: ${{ secrets.GORELEASER_KEY }}

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
[![Go Report Card](https://goreportcard.com/badge/github.com/sgaunet/jwt-cli)](https://goreportcard.com/report/github.com/sgaunet/jwt-cli)
22
[![GitHub release](https://img.shields.io/github/release/sgaunet/jwt-cli.svg)](https://github.com/sgaunet/jwt-cli/releases/latest)
33
![GitHub Downloads](https://img.shields.io/github/downloads/sgaunet/jwt-cli/total)
4+
![Coverage](https://raw.githubusercontent.com/wiki/sgaunet/jwt-cli/coverage-badge.svg)
45
[![GoDoc](https://godoc.org/github.com/sgaunet/jwt-cli?status.svg)](https://godoc.org/github.com/sgaunet/jwt-cli)
56
[![License](https://img.shields.io/github/license/sgaunet/jwt-cli.svg)](LICENSE)
67

0 commit comments

Comments
 (0)