Skip to content

Commit b0ac128

Browse files
committed
feat: first
0 parents  commit b0ac128

File tree

9 files changed

+318
-0
lines changed

9 files changed

+318
-0
lines changed

.github/workflows/nightly.yml

Lines changed: 126 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,126 @@
1+
name: goreleaser-nightly
2+
3+
on:
4+
workflow_dispatch:
5+
push:
6+
tags: ['v*']
7+
8+
permissions:
9+
contents: write
10+
id-token: write
11+
packages: write
12+
13+
jobs:
14+
prepare:
15+
strategy:
16+
matrix:
17+
os: [ubuntu-latest, macos-latest, windows-latest]
18+
runs-on: ${{ matrix.os }}
19+
env:
20+
DOCKER_CLI_EXPERIMENTAL: "enabled"
21+
steps:
22+
- shell: bash
23+
run: |
24+
if test '${{ github.event_name }}' = "workflow_dispatch"; then
25+
echo "flags=--nightly" >> $GITHUB_ENV
26+
else
27+
echo "flags=" >> $GITHUB_ENV
28+
fi
29+
case '${{ matrix.os }}' in
30+
ubuntu-latest)
31+
echo "goos=linux" >> $GITHUB_ENV
32+
;;
33+
macos-latest)
34+
echo "goos=darwin" >> $GITHUB_ENV
35+
;;
36+
windows-latest)
37+
echo "goos=windows" >> $GITHUB_ENV
38+
;;
39+
esac
40+
- uses: actions/checkout@v3
41+
with:
42+
fetch-depth: 0
43+
- uses: docker/setup-qemu-action@v1
44+
if: matrix.os == 'ubuntu-latest'
45+
- uses: docker/setup-buildx-action@v1
46+
if: matrix.os == 'ubuntu-latest'
47+
- name: ghcr-login
48+
uses: docker/login-action@v1
49+
if: matrix.os != 'macos-latest'
50+
with:
51+
registry: ghcr.io
52+
username: ${{ github.repository_owner }}
53+
password: ${{ secrets.GITHUB_TOKEN }}
54+
- uses: actions/setup-go@v3
55+
with:
56+
go-version: 1.19
57+
cache: true
58+
- shell: bash
59+
run: |
60+
echo "sha_short=$(git rev-parse --short HEAD)" >> $GITHUB_ENV
61+
- id: cache
62+
uses: actions/cache@v3
63+
with:
64+
path: dist/${{ env.goos }}
65+
key: ${{ env.goos }}-${{ env.sha_short }}
66+
- uses: goreleaser/goreleaser-action@v3
67+
if: steps.cache.outputs.cache-hit != 'true' # do not run if cache hit
68+
with:
69+
distribution: goreleaser-pro
70+
version: latest
71+
args: release --rm-dist --split ${{ env.flags }}
72+
env:
73+
GITHUB_TOKEN: ${{ secrets.GH_PAT }}
74+
GORELEASER_KEY: ${{ secrets.GORELEASER_KEY }}
75+
release:
76+
runs-on: ubuntu-latest
77+
needs: prepare
78+
env:
79+
DOCKER_CLI_EXPERIMENTAL: "enabled"
80+
steps:
81+
- uses: actions/checkout@v3
82+
with:
83+
fetch-depth: 0
84+
- uses: docker/setup-qemu-action@v1
85+
- uses: docker/setup-buildx-action@v1
86+
- uses: sigstore/[email protected]
87+
- uses: anchore/sbom-action/[email protected]
88+
- name: ghcr-login
89+
uses: docker/login-action@v1
90+
with:
91+
registry: ghcr.io
92+
username: ${{ github.repository_owner }}
93+
password: ${{ secrets.GITHUB_TOKEN }}
94+
- uses: actions/setup-go@v3
95+
with:
96+
go-version: 1.19
97+
cache: true
98+
99+
# copy the cashes from prepare
100+
- shell: bash
101+
run: |
102+
echo "sha_short=$(git rev-parse --short HEAD)" >> $GITHUB_ENV
103+
- uses: actions/cache@v3
104+
with:
105+
path: dist/linux
106+
key: linux-${{ env.sha_short }}
107+
- uses: actions/cache@v3
108+
with:
109+
path: dist/darwin
110+
key: darwin-${{ env.sha_short }}
111+
- uses: actions/cache@v3
112+
with:
113+
path: dist/windows
114+
key: windows-${{ env.sha_short }}
115+
116+
117+
# release
118+
- uses: goreleaser/goreleaser-action@v3
119+
if: steps.cache.outputs.cache-hit != 'true' # do not run if cache hit
120+
with:
121+
distribution: goreleaser-pro
122+
version: latest
123+
args: continue --merge
124+
env:
125+
GITHUB_TOKEN: ${{ secrets.GH_PAT }}
126+
GORELEASER_KEY: ${{ secrets.GORELEASER_KEY }}

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
dist*
2+
3+
dist/

.goreleaser.yaml

Lines changed: 155 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,155 @@
1+
# This is an example-real .goreleaser.yml file with some sensible defaults.
2+
# Make sure to check the documentation at https://goreleaser.com
3+
before:
4+
hooks:
5+
- go mod tidy
6+
builds:
7+
- targets: [go_first_class]
8+
mod_timestamp: '{{ .CommitTimestamp }}'
9+
flags:
10+
# trims path
11+
- -trimpath
12+
ldflags:
13+
# use commit date instead of current date as main.date
14+
# only needed if you actually use those things in your main package, otherwise can be ignored.
15+
- -s -w -X main.version={{.Version}} -X main.commit={{.Commit}} -X main.date={{ .CommitDate }}
16+
checksum:
17+
name_template: 'checksums.txt'
18+
snapshot:
19+
name_template: "{{ incpatch .Version }}-next"
20+
changelog:
21+
sort: asc
22+
filters:
23+
exclude:
24+
- '^docs:'
25+
- '^test:'
26+
27+
nfpms:
28+
- file_name_template: '{{ .ConventionalFileName }}'
29+
homepage: https://goreleaser.com
30+
description: Just another example
31+
maintainer: Carlos Alexandro Becker <[email protected]>
32+
license: MIT
33+
vendor: GoReleaser
34+
bindir: /usr/bin
35+
section: utils
36+
formats: [apk, deb, rpm]
37+
38+
release:
39+
name_template: 'v{{ .Version }}'
40+
footer: |
41+
* * *
42+
43+
<a href="https://goreleser.com"><img src="https://raw.githubusercontent.com/goreleaser/artwork/master/opencollective-header.png" with="100%" alt="GoReleaser logo"></a>
44+
45+
Find example-reals and commented usage of all options in our [website](https://goreleaser.com/intro/).
46+
Want to help? You can [sponsor](https://goreleaser.com/sponsors/),get a [Pro License](https://goreleaser.com/pro) or [contribute](https://goreleaser.com/contributing).
47+
Also, feel free to reach out on [Discord](https://discord.gg/RGEBtg8vQ6) and [Twitter](https://twitter.com/goreleaser)!
48+
49+
50+
nightly:
51+
publish_release: true
52+
keep_single_release: true
53+
name_template: '{{ incminor .Version }}-nightly'
54+
tag_name: nightly
55+
56+
57+
dockers:
58+
- image_templates:
59+
- 'ghcr.io/caarlos0/goreleaser-pro-split-merge-example-real:v{{ .Version }}-amd64'
60+
build_flag_templates:
61+
- "--pull"
62+
- "--label=org.opencontainers.image.description=Just an example-real"
63+
- "--label=org.opencontainers.image.created={{.Date}}"
64+
- "--label=org.opencontainers.image.name={{.ProjectName}}"
65+
- "--label=org.opencontainers.image.revision={{.FullCommit}}"
66+
- "--label=org.opencontainers.image.version={{.Version}}"
67+
- "--label=org.opencontainers.image.source={{.GitURL}}"
68+
- "--platform=linux/amd64"
69+
use: buildx
70+
- image_templates:
71+
- 'ghcr.io/caarlos0/goreleaser-pro-split-merge-example-real:v{{ .Version }}-arm64'
72+
build_flag_templates:
73+
- "--pull"
74+
- "--label=org.opencontainers.image.description=Just an example-real"
75+
- "--label=org.opencontainers.image.created={{.Date}}"
76+
- "--label=org.opencontainers.image.name={{.ProjectName}}"
77+
- "--label=org.opencontainers.image.revision={{.FullCommit}}"
78+
- "--label=org.opencontainers.image.version={{.Version}}"
79+
- "--label=org.opencontainers.image.source={{.GitURL}}"
80+
- "--platform=linux/arm64"
81+
use: buildx
82+
- image_templates:
83+
- 'ghcr.io/caarlos0/goreleaser-pro-split-merge-example-real:v{{ .Version }}-windows-amd64'
84+
build_flag_templates:
85+
- "--pull"
86+
- "--label=org.opencontainers.image.description=Just an example-real"
87+
- "--label=org.opencontainers.image.created={{.Date}}"
88+
- "--label=org.opencontainers.image.name={{.ProjectName}}"
89+
- "--label=org.opencontainers.image.revision={{.FullCommit}}"
90+
- "--label=org.opencontainers.image.version={{.Version}}"
91+
- "--label=org.opencontainers.image.source={{.GitURL}}"
92+
- "--platform=windows/amd64"
93+
goos: windows
94+
dockerfile: windows.dockerfile
95+
96+
docker_manifests:
97+
- name_template: 'ghcr.io/caarlos0/goreleaser-pro-split-merge-example-real:v{{ .Version }}'
98+
image_templates:
99+
- 'ghcr.io/caarlos0/goreleaser-pro-split-merge-example-real:v{{ .Version }}-amd64'
100+
- 'ghcr.io/caarlos0/goreleaser-pro-split-merge-example-real:v{{ .Version }}-arm64'
101+
- 'ghcr.io/caarlos0/goreleaser-pro-split-merge-example-real:v{{ .Version }}-windows-amd64'
102+
- name_template: '{{ if not .IsNightly }}ghcr.io/caarlos0/goreleaser-pro-split-merge-example-real:latest{{ end }}'
103+
image_templates:
104+
- 'ghcr.io/caarlos0/goreleaser-pro-split-merge-example-real:v{{ .Version }}-amd64'
105+
- 'ghcr.io/caarlos0/goreleaser-pro-split-merge-example-real:v{{ .Version }}-arm64'
106+
- 'ghcr.io/caarlos0/goreleaser-pro-split-merge-example-real:v{{ .Version }}-windows-amd64'
107+
108+
monorepo:
109+
tag_prefix: v # so it always filters out the nightly tag
110+
111+
112+
# signs the checksum file
113+
# 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
114+
# https://goreleaser.com/customization/sign
115+
signs:
116+
- cmd: cosign
117+
env:
118+
- COSIGN_EXPERIMENTAL=1
119+
certificate: '${artifact}.pem'
120+
args:
121+
- sign-blob
122+
- '--output-certificate=${certificate}'
123+
- '--output-signature=${signature}'
124+
- '${artifact}'
125+
artifacts: checksum
126+
output: true
127+
128+
# create a source tarball
129+
# https://goreleaser.com/customization/source/
130+
source:
131+
enabled: true
132+
133+
# creates SBOMs of all archives and the source tarball using syft
134+
# https://goreleaser.com/customization/sbom
135+
sboms:
136+
- artifacts: archive
137+
- id: source # Two different sbom configurations need two different IDs
138+
artifacts: source
139+
140+
# signs our docker image
141+
# https://goreleaser.com/customization/docker_sign
142+
docker_signs:
143+
- cmd: cosign
144+
env:
145+
- COSIGN_EXPERIMENTAL=1
146+
artifacts: images
147+
output: true
148+
args:
149+
- 'sign'
150+
- '${artifact}'
151+
152+
153+
# modelines, feel free to remove those if you don't want/use them:
154+
# yaml-language-server: $schema=https://goreleaser.com/static/schema-pro.json
155+
# vim: set ts=2 sw=2 tw=0 fo=cnqoj

Dockerfile

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
FROM alpine
2+
COPY goreleaser-pro-split-merge-example-real /usr/bin/example
3+
ENTRYPOINT ["/usr/bin/example"]

README.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# GoReleaser Pro Split & Merge Example (real)
2+
3+
This repo contains a quick and to-the-point example of how to use
4+
[GoReleaser Pro](https://goreleaser.com/pro)
5+
[split and merge builds](https://goreleaser.com/customization/partial/).
6+
7+
This also serves as a [nightly](https://goreleaser.com/customization/nightlies/) example.
8+
9+
The difference from this and
10+
[the other example](https://github.com/caarlos0/goreleaser-pro-split-merge-example/commits/main),
11+
is that this one uses the "real" OS instead of just setting `GOOS`. It also
12+
leverages that to create Windows Docker Images.
13+
14+
---
15+
16+
For now, this repo is not using the goreleaser action, as it does not work with
17+
nightlies (yet), but it will, soon enough.

go.mod

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
module test
2+
3+
go 1.19

go.sum

Whitespace-only changes.

main.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
package main
2+
3+
import "fmt"
4+
5+
func main() {
6+
fmt.Println("hello world!")
7+
}

windows.dockerfile

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
FROM mcr.microsoft.com/windows/nanoserver:ltsc2022
2+
WORKDIR /app
3+
COPY goreleaser-pro-split-merge-example-real.exe example.exe
4+
ENTRYPOINT ["/app/example.exe"]

0 commit comments

Comments
 (0)