Skip to content

Commit fd8393a

Browse files
authored
chore: add releaser actions (#79)
Signed-off-by: Gaius <[email protected]>
1 parent 78e13ab commit fd8393a

File tree

5 files changed

+210
-0
lines changed

5 files changed

+210
-0
lines changed

.github/workflows/release.yml

+74
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
name: Release
2+
3+
on:
4+
push:
5+
tags:
6+
- v*
7+
8+
permissions:
9+
contents: read
10+
11+
jobs:
12+
goreleaser:
13+
permissions:
14+
contents: write
15+
runs-on: ubuntu-latest
16+
timeout-minutes: 60
17+
outputs:
18+
hashes: ${{ steps.hash.outputs.hashes }}
19+
steps:
20+
- name: Checkout
21+
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
22+
with:
23+
fetch-depth: 0
24+
submodules: recursive
25+
26+
- name: Setup Go
27+
uses: actions/setup-go@f111f3307d8850f501ac008e886eec1fd1932a34
28+
with:
29+
go-version-file: go.mod
30+
31+
- name: Check GoReleaser config
32+
uses: goreleaser/goreleaser-action@90a3faa9d0182683851fbfa97ca1a2cb983bfca3
33+
with:
34+
version: latest
35+
args: check
36+
37+
- name: Run GoReleaser
38+
uses: goreleaser/goreleaser-action@90a3faa9d0182683851fbfa97ca1a2cb983bfca3
39+
id: run-goreleaser
40+
with:
41+
version: latest
42+
args: release --clean
43+
env:
44+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
45+
46+
- name: Generate subject
47+
id: hash
48+
env:
49+
ARTIFACTS: "${{ steps.run-goreleaser.outputs.artifacts }}"
50+
run: |
51+
set -euo pipefail
52+
hashes=$(echo $ARTIFACTS | jq --raw-output '.[] | {name, "digest": (.extra.Digest // .extra.Checksum)} | select(.digest) | {digest} + {name} | join(" ") | sub("^sha256:";"")' | base64 -w0)
53+
if test "$hashes" = ""; then # goreleaser < v1.13.0
54+
checksum_file=$(echo "$ARTIFACTS" | jq -r '.[] | select (.type=="Checksum") | .path')
55+
hashes=$(cat $checksum_file | base64 -w0)
56+
fi
57+
echo "hashes=$hashes" >> $GITHUB_OUTPUT
58+
59+
- name: Set tag output
60+
id: tag
61+
run: echo "tag_name=${GITHUB_REF#refs/*/}" >> "$GITHUB_OUTPUT"
62+
63+
provenance:
64+
needs: [goreleaser]
65+
permissions:
66+
actions: read # To read the workflow path.
67+
id-token: write # To sign the provenance.
68+
contents: write # To add assets to a release.
69+
uses: slsa-framework/slsa-github-generator/.github/workflows/[email protected]
70+
with:
71+
base64-subjects: "${{ needs.goreleaser.outputs.hashes }}"
72+
upload-assets: true # upload to a new release
73+
upload-tag-name: "${{ needs.release.outputs.tag_name }}"
74+
draft-release: true

.goreleaser.yml

+57
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
release:
2+
draft: true
3+
replace_existing_draft: true
4+
5+
before:
6+
hooks:
7+
- go mod download
8+
9+
builds:
10+
- main: ./cmd/main.go
11+
id: modctl
12+
binary: modctl
13+
goos:
14+
- linux
15+
- darwin
16+
goarch:
17+
- amd64
18+
- arm64
19+
20+
archives:
21+
- name_template: "modctl-{{ .Version }}-{{ .Os }}-{{ .Arch }}"
22+
formats: ["tar.gz"]
23+
files:
24+
- LICENSE
25+
- README.md
26+
27+
checksum:
28+
name_template: "checksums.txt"
29+
30+
snapshot:
31+
version_template: "{{ .Tag }}-next"
32+
33+
changelog:
34+
sort: asc
35+
filters:
36+
exclude:
37+
- "^docs:"
38+
- "^test:"
39+
40+
nfpms:
41+
- id: modctl
42+
file_name_template: "modctl-{{ .Version }}-{{ .Os }}-{{ .Arch }}"
43+
package_name: modctl
44+
description: A command line tool for managing artifact bundled based on the Model Format Specification
45+
license: "Apache 2.0"
46+
bindir: /usr/bin
47+
builds:
48+
- modctl
49+
formats:
50+
- rpm
51+
- deb
52+
contents:
53+
- src: build/package/docs/modctl.1
54+
dst: /usr/share/man/man1/modctl.1
55+
56+
- src: LICENSE
57+
dst: /usr/share/doc/modctl/License

Makefile

+5
Original file line numberDiff line numberDiff line change
@@ -118,3 +118,8 @@ install-mockery:
118118
echo "Error: Homebrew is not installed. Please install Homebrew first and ensure it's in your PATH."; \
119119
exit 1; \
120120
fi
121+
122+
# Generate modctl man page.
123+
build-modctl-man-page:
124+
@pandoc -s -t man ./build/package/docs/modctl.1.md -o ./build/package/docs/modctl.1
125+
.PHONY: build-modctl-man-page

build/package/docs/modctl.1

+37
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
.\" Automatically generated by Pandoc 3.6.1
2+
.\"
3+
.TH "MODCTL" "1" "" "Version v2.2.0" "Frivolous \[lq]Modctl\[rq] Documentation"
4+
.SH NAME
5+
\f[B]modctl\f[R] \[em] A command line tool for managing artifact bundled
6+
based on the Model Format Specification
7+
.SS OPTIONS
8+
.IP
9+
.EX
10+
A command line tool for managing artifact bundled based on the Model Format Specification
11+
12+
Usage:
13+
modctl [flags]
14+
modctl [command]
15+
16+
Available Commands:
17+
build A command line tool for modctl build
18+
completion Generate the autocompletion script for the specified shell
19+
extract A command line tool for modctl extract
20+
help Help about any command
21+
inspect A command line tool for modctl inspect
22+
login A command line tool for modctl login
23+
logout A command line tool for modctl logout
24+
ls A command line tool for modctl list
25+
prune A command line tool for modctl prune
26+
pull A command line tool for modctl pull
27+
push A command line tool for modctl push
28+
rm A command line tool for modctl rm
29+
30+
Flags:
31+
\-h, \-\-help help for modctl
32+
\-\-storage\-dir string specify the storage directory for modctl (default \[dq]/Users/qiwenbo/.modctl\[dq])
33+
.EE
34+
.SH BUGS
35+
See GitHub Issues: \c
36+
.UR https://github.com/CloudNativeAI/modctl/issues
37+
.UE \c

build/package/docs/modctl.1.md

+37
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
% MODCTL(1) Version v2.2.0 | Frivolous "Modctl" Documentation
2+
3+
# NAME
4+
5+
**modctl** — A command line tool for managing artifact bundled based on the Model Format Specification
6+
7+
## OPTIONS
8+
9+
```shell
10+
A command line tool for managing artifact bundled based on the Model Format Specification
11+
12+
Usage:
13+
modctl [flags]
14+
modctl [command]
15+
16+
Available Commands:
17+
build A command line tool for modctl build
18+
completion Generate the autocompletion script for the specified shell
19+
extract A command line tool for modctl extract
20+
help Help about any command
21+
inspect A command line tool for modctl inspect
22+
login A command line tool for modctl login
23+
logout A command line tool for modctl logout
24+
ls A command line tool for modctl list
25+
prune A command line tool for modctl prune
26+
pull A command line tool for modctl pull
27+
push A command line tool for modctl push
28+
rm A command line tool for modctl rm
29+
30+
Flags:
31+
-h, --help help for modctl
32+
--storage-dir string specify the storage directory for modctl (default "/Users/qiwenbo/.modctl")
33+
```
34+
35+
# BUGS
36+
37+
See GitHub Issues: <https://github.com/CloudNativeAI/modctl/issues>

0 commit comments

Comments
 (0)