Skip to content

Commit 8b66e53

Browse files
authored
Merge pull request #1 from imusmanmalik/main
feat: Add GitHub Action and release
2 parents 44a9428 + 2763900 commit 8b66e53

File tree

4 files changed

+181
-0
lines changed

4 files changed

+181
-0
lines changed

.github/dependabot.yml

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
version: 2
2+
updates:
3+
- package-ecosystem: "gomod"
4+
directory: "/"
5+
schedule:
6+
interval: "daily"
7+
time: "08:00"
8+
labels:
9+
- "dependencies"
10+
commit-message:
11+
prefix: "feat"
12+
include: "scope"
13+
- package-ecosystem: "github-actions"
14+
directory: "/"
15+
schedule:
16+
interval: "daily"
17+
time: "08:00"
18+
labels:
19+
- "dependencies"
20+
commit-message:
21+
prefix: "chore"
22+
include: "scope"
23+
- package-ecosystem: "docker"
24+
directory: "/"
25+
schedule:
26+
interval: "daily"
27+
time: "08:00"
28+
labels:
29+
- "dependencies"
30+
commit-message:
31+
prefix: "feat"
32+
include: "scope"

.github/workflows/build.yml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
name: build
2+
3+
on:
4+
pull_request:
5+
push:
6+
7+
permissions:
8+
contents: read
9+
10+
jobs:
11+
build:
12+
runs-on: ubuntu-latest
13+
steps:
14+
- uses: actions/checkout@v4
15+
- uses: actions/setup-go@v5
16+
with:
17+
go-version: 1.21
18+
cache: true
19+
- run: go test -v ./...

.github/workflows/release.yml

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
#
2+
# Releaser workflow setup
3+
# https://goreleaser.com/ci/actions/
4+
#
5+
name: release
6+
7+
# run only on tags
8+
on:
9+
push:
10+
tags:
11+
- 'v*'
12+
13+
permissions:
14+
contents: write # needed to write releases
15+
id-token: write # needed for keyless signing
16+
packages: write # needed for ghcr access
17+
18+
jobs:
19+
release:
20+
runs-on: ubuntu-latest
21+
steps:
22+
- uses: actions/checkout@v4
23+
with:
24+
fetch-depth: 0 # this is important, otherwise it won't checkout the full tree (i.e. no previous tags)
25+
- uses: actions/setup-go@v5
26+
with:
27+
go-version: 1.21
28+
cache: true
29+
- uses: sigstore/cosign-installer@v3.4.0 # installs cosign
30+
- uses: anchore/sbom-action/download-syft@v0.15.8 # installs syft
31+
- uses: docker/login-action@v3 # login to ghcr
32+
with:
33+
registry: ghcr.io
34+
username: ${{ github.repository_owner }}
35+
password: ${{ secrets.GITHUB_TOKEN }}
36+
- uses: goreleaser/goreleaser-action@v5 # run goreleaser
37+
with:
38+
version: latest
39+
args: release --clean
40+
env:
41+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

.goreleaser.yaml

Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
project_name: reverse-http
2+
3+
# setups builds for linux and darwin on amd64 and arm64
4+
# https://goreleaser.com/customization/build
5+
builds:
6+
- env:
7+
- CGO_ENABLED=0
8+
goos:
9+
- linux
10+
- darwin
11+
goarch:
12+
- amd64
13+
- arm64
14+
# ensures mod timestamp to be the commit timestamp
15+
mod_timestamp: "{{ .CommitTimestamp }}"
16+
flags:
17+
# trims path
18+
- -trimpath
19+
ldflags:
20+
# use commit date instead of current date as main.date
21+
# only needed if you actually use those things in your main package, otherwise can be ignored.
22+
- -s -w -X main.version={{.Version}} -X main.commit={{.Commit}} -X main.date={{ .CommitDate }}
23+
24+
# proxies from the go mod proxy before building
25+
# https://goreleaser.com/customization/gomod
26+
gomod:
27+
proxy: true
28+
29+
# config the checksum filename
30+
# https://goreleaser.com/customization/checksum
31+
checksum:
32+
name_template: "checksums.txt"
33+
34+
# create a source tarball
35+
# https://goreleaser.com/customization/source/
36+
source:
37+
enabled: true
38+
39+
# creates SBOMs of all archives and the source tarball using syft
40+
# https://goreleaser.com/customization/sbom
41+
sboms:
42+
- artifacts: archive
43+
- id: source # Two different sbom configurations need two different IDs
44+
artifacts: source
45+
46+
# signs the checksum file
47+
# all files (including the sboms) are included in the checksum, so we don't need to sign each one if we don't want to
48+
# https://goreleaser.com/customization/sign
49+
signs:
50+
- cmd: cosign
51+
env:
52+
- COSIGN_EXPERIMENTAL=1
53+
certificate: "${artifact}.pem"
54+
args:
55+
- sign-blob
56+
- "--output-certificate=${certificate}"
57+
- "--output-signature=${signature}"
58+
- "${artifact}"
59+
- "--yes" # needed on cosign 2.0.0+
60+
artifacts: checksum
61+
output: true
62+
63+
# create a docker image
64+
# https://goreleaser.com/customization/docker
65+
dockers:
66+
- image_templates:
67+
- "ghcr.io/grepplabs/reverse-http:{{ .Tag }}"
68+
- "ghcr.io/grepplabs/reverse-http:latest"
69+
dockerfile: Dockerfile
70+
build_flag_templates:
71+
- "--pull"
72+
- "--label=org.opencontainers.image.created={{.Date}}"
73+
- "--label=org.opencontainers.image.name={{.ProjectName}}"
74+
- "--label=org.opencontainers.image.revision={{.FullCommit}}"
75+
- "--label=org.opencontainers.image.version={{.Version}}"
76+
- "--label=org.opencontainers.image.source={{.GitURL}}"
77+
78+
# signs our docker image
79+
# https://goreleaser.com/customization/docker_sign
80+
docker_signs:
81+
- cmd: cosign
82+
env:
83+
- COSIGN_EXPERIMENTAL=1
84+
artifacts: images
85+
output: true
86+
args:
87+
- "sign"
88+
- "${artifact}"
89+
- "--yes" # needed on cosign 2.0.0+

0 commit comments

Comments
 (0)