Skip to content

Commit 97d8772

Browse files
authored
Add Release workflow with goreleaser (#202)
* Fix Signed-off-by: Ondrej Fabry <[email protected]> * Add blank lines to workflows for readability Signed-off-by: Ondrej Fabry <[email protected]> * Upload artifacts in release workflow Signed-off-by: Ondrej Fabry <[email protected]> * Update step in release workflow Signed-off-by: Ondrej Fabry <[email protected]> * Add newline at the end of file Signed-off-by: Ondrej Fabry <[email protected]> --------- Signed-off-by: Ondrej Fabry <[email protected]>
1 parent c703bfe commit 97d8772

File tree

6 files changed

+161
-0
lines changed

6 files changed

+161
-0
lines changed

.github/workflows/ci.yaml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ jobs:
2121
steps:
2222
- name: "Checkout"
2323
uses: actions/checkout@v4
24+
2425
- name: "Run YAML linter"
2526
uses: ibiqlik/action-yamllint@v3
2627
with:
@@ -35,15 +36,19 @@ jobs:
3536
steps:
3637
- name: "Checkout"
3738
uses: actions/checkout@v4
39+
3840
- name: "Setup Go"
3941
uses: actions/setup-go@v5
4042
with:
4143
go-version: ${{ matrix.go }}
44+
4245
- name: "Run go mod tidy"
4346
run: go mod tidy -v
47+
4448
- name: "Check go.mod"
4549
run: |
4650
git diff --exit-code go.mod
51+
4752
- name: "Check go.sum"
4853
run: |
4954
git diff --exit-code go.sum
@@ -59,12 +64,15 @@ jobs:
5964
steps:
6065
- name: "Checkout"
6166
uses: actions/checkout@v4
67+
6268
- name: "Setup Go"
6369
uses: actions/setup-go@v5
6470
with:
6571
go-version: ${{ matrix.go }}
72+
6673
- name: "Generate binapi"
6774
run: make gen-binapi-docker
75+
6876
- name: "Check binapi"
6977
run: |
7078
git diff --exit-code binapi
@@ -79,18 +87,23 @@ jobs:
7987
steps:
8088
- name: "Checkout"
8189
uses: actions/checkout@v4
90+
8291
- name: "Setup Go"
8392
uses: actions/setup-go@v5
8493
with:
8594
go-version: ${{ matrix.go }}
95+
8696
- name: "Setup gotestsum"
8797
uses: autero1/[email protected]
8898
with:
8999
gotestsum_version: 1.11.0
100+
90101
- name: "Go Build"
91102
run: go build -v ./...
103+
92104
- name: "Go Test"
93105
run: gotestsum --format testname --jsonfile test.json -- -race ./...
106+
94107
- name: "Test results"
95108
if: always()
96109
uses: guyarb/[email protected]
@@ -109,10 +122,12 @@ jobs:
109122
steps:
110123
- name: "Checkout"
111124
uses: actions/checkout@v4
125+
112126
- name: "Setup Go"
113127
uses: actions/setup-go@v5
114128
with:
115129
go-version: ${{ matrix.go }}
130+
116131
- name: "Run golangci"
117132
uses: golangci/golangci-lint-action@v4 # docs: https://github.com/golangci/golangci-lint-action
118133
with:

.github/workflows/release.yaml

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
name: Release
2+
3+
on:
4+
push:
5+
branches:
6+
- master
7+
tags:
8+
- 'v*'
9+
pull_request:
10+
workflow_dispatch: # Allows you to run this workflow manually from the Actions tab
11+
12+
permissions:
13+
contents: write
14+
packages: write
15+
issues: write
16+
17+
jobs:
18+
goreleaser:
19+
runs-on: ubuntu-latest
20+
steps:
21+
- name: "Checkout"
22+
uses: actions/checkout@v4
23+
with:
24+
fetch-depth: 0
25+
26+
- name: "Setup Go"
27+
uses: actions/setup-go@v5
28+
29+
- name: "Download Syft"
30+
uses: anchore/sbom-action/download-syft@v0 #v0.15.10
31+
32+
- name: "Release Version"
33+
if: success() && startsWith(github.ref, 'refs/tags/v')
34+
uses: goreleaser/goreleaser-action@v5
35+
with:
36+
version: latest
37+
args: release --clean
38+
env:
39+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
40+
HOSTNAME: github
41+
42+
- name: "Release Snapshot"
43+
if: success() && !startsWith(github.ref, 'refs/tags/v')
44+
uses: goreleaser/goreleaser-action@v5
45+
with:
46+
version: latest
47+
args: release --clean --snapshot
48+
env:
49+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
50+
HOSTNAME: github
51+
52+
- name: "Upload Artifacts"
53+
uses: actions/upload-artifact@v4
54+
with:
55+
name: govpp-artifacts
56+
path: |
57+
dist/*
58+
!dist/govpp-build*

.github/workflows/test.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,12 @@ jobs:
3333
steps:
3434
- name: "Checkout"
3535
uses: actions/checkout@v4
36+
3637
- name: "Setup Go"
3738
uses: actions/setup-go@v5
3839
with:
3940
go-version: '1.21'
41+
4042
- name: "Run Tests"
4143
run: |
4244
make test-integration

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88
.cache/
99

1010
/bin/
11+
/dist/
12+
/govpp
1113

1214
# cmd
1315
cmd/binapi-generator/binapi-generator

.goreleaser.yml

Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
# GoReleser config
2+
#
3+
# documentation at http://goreleaser.com
4+
---
5+
project_name: govpp
6+
7+
builds:
8+
- id: govpp-build
9+
main: ./cmd/govpp
10+
binary: govpp
11+
env:
12+
- CGO_ENABLED=0
13+
goos:
14+
- linux
15+
- darwin
16+
goarch:
17+
- amd64
18+
ignore:
19+
- goos: darwin
20+
goarch: "386"
21+
mod_timestamp: '{{ .CommitTimestamp }}'
22+
flags:
23+
- -trimpath
24+
ldflags:
25+
- -s -w
26+
- -X go.fd.io/govpp/version.version=v{{.Version}}
27+
- -X go.fd.io/govpp/version.commit={{.FullCommit}}
28+
- -X go.fd.io/govpp/version.branch={{.Branch}}
29+
- -X go.fd.io/govpp/version.buildStamp={{.Timestamp}}
30+
31+
archives:
32+
- id: govpp-archive
33+
builds:
34+
- govpp-build
35+
format: tar.gz
36+
wrap_in_directory: true
37+
files:
38+
- README.md
39+
- docs/*
40+
allow_different_binary_count: true
41+
name_template: "govpp_{{ .Version }}_{{ .Os }}_{{ .Arch }}"
42+
43+
checksum:
44+
name_template: 'checksums.txt'
45+
46+
changelog:
47+
skip: false
48+
sort: asc
49+
filters:
50+
exclude:
51+
- '!^docs:'
52+
- typo
53+
54+
dockers:
55+
- dockerfile: Dockerfile.govpp
56+
image_templates:
57+
- "ghcr.io/fdio/govpp:{{ .Tag }}"
58+
- "ghcr.io/fdio/govpp:v{{ .Major }}.{{ .Minor }}"
59+
- "ghcr.io/fdio/govpp:latest"
60+
build_flag_templates:
61+
- "--pull"
62+
- "--label=org.opencontainers.image.created={{.Date}}"
63+
- "--label=org.opencontainers.image.name={{.ProjectName}}"
64+
- "--label=org.opencontainers.image.revision={{.FullCommit}}"
65+
- "--label=org.opencontainers.image.version={{.Version}}"
66+
- "--label=org.opencontainers.image.source={{.GitURL}}"
67+
ids:
68+
- govpp-build
69+
70+
sboms:
71+
- artifacts: archive
72+
73+
release:
74+
github:
75+
owner: FDio
76+
name: govpp
77+
ids:
78+
- govpp-archive
79+
draft: true
80+
prerelease: auto
81+
name_template: "{{.Tag}}"

Dockerfile.govpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
FROM scratch
2+
COPY govpp /
3+
ENTRYPOINT ["/govpp"]

0 commit comments

Comments
 (0)