-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit b0ac128
Showing
9 changed files
with
318 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,126 @@ | ||
name: goreleaser-nightly | ||
|
||
on: | ||
workflow_dispatch: | ||
push: | ||
tags: ['v*'] | ||
|
||
permissions: | ||
contents: write | ||
id-token: write | ||
packages: write | ||
|
||
jobs: | ||
prepare: | ||
strategy: | ||
matrix: | ||
os: [ubuntu-latest, macos-latest, windows-latest] | ||
runs-on: ${{ matrix.os }} | ||
env: | ||
DOCKER_CLI_EXPERIMENTAL: "enabled" | ||
steps: | ||
- shell: bash | ||
run: | | ||
if test '${{ github.event_name }}' = "workflow_dispatch"; then | ||
echo "flags=--nightly" >> $GITHUB_ENV | ||
else | ||
echo "flags=" >> $GITHUB_ENV | ||
fi | ||
case '${{ matrix.os }}' in | ||
ubuntu-latest) | ||
echo "goos=linux" >> $GITHUB_ENV | ||
;; | ||
macos-latest) | ||
echo "goos=darwin" >> $GITHUB_ENV | ||
;; | ||
windows-latest) | ||
echo "goos=windows" >> $GITHUB_ENV | ||
;; | ||
esac | ||
- uses: actions/checkout@v3 | ||
with: | ||
fetch-depth: 0 | ||
- uses: docker/setup-qemu-action@v1 | ||
if: matrix.os == 'ubuntu-latest' | ||
- uses: docker/setup-buildx-action@v1 | ||
if: matrix.os == 'ubuntu-latest' | ||
- name: ghcr-login | ||
uses: docker/login-action@v1 | ||
if: matrix.os != 'macos-latest' | ||
with: | ||
registry: ghcr.io | ||
username: ${{ github.repository_owner }} | ||
password: ${{ secrets.GITHUB_TOKEN }} | ||
- uses: actions/setup-go@v3 | ||
with: | ||
go-version: 1.19 | ||
cache: true | ||
- shell: bash | ||
run: | | ||
echo "sha_short=$(git rev-parse --short HEAD)" >> $GITHUB_ENV | ||
- id: cache | ||
uses: actions/cache@v3 | ||
with: | ||
path: dist/${{ env.goos }} | ||
key: ${{ env.goos }}-${{ env.sha_short }} | ||
- uses: goreleaser/goreleaser-action@v3 | ||
if: steps.cache.outputs.cache-hit != 'true' # do not run if cache hit | ||
with: | ||
distribution: goreleaser-pro | ||
version: latest | ||
args: release --rm-dist --split ${{ env.flags }} | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GH_PAT }} | ||
GORELEASER_KEY: ${{ secrets.GORELEASER_KEY }} | ||
release: | ||
runs-on: ubuntu-latest | ||
needs: prepare | ||
env: | ||
DOCKER_CLI_EXPERIMENTAL: "enabled" | ||
steps: | ||
- uses: actions/checkout@v3 | ||
with: | ||
fetch-depth: 0 | ||
- uses: docker/setup-qemu-action@v1 | ||
- uses: docker/setup-buildx-action@v1 | ||
- uses: sigstore/[email protected] | ||
- uses: anchore/sbom-action/[email protected] | ||
- name: ghcr-login | ||
uses: docker/login-action@v1 | ||
with: | ||
registry: ghcr.io | ||
username: ${{ github.repository_owner }} | ||
password: ${{ secrets.GITHUB_TOKEN }} | ||
- uses: actions/setup-go@v3 | ||
with: | ||
go-version: 1.19 | ||
cache: true | ||
|
||
# copy the cashes from prepare | ||
- shell: bash | ||
run: | | ||
echo "sha_short=$(git rev-parse --short HEAD)" >> $GITHUB_ENV | ||
- uses: actions/cache@v3 | ||
with: | ||
path: dist/linux | ||
key: linux-${{ env.sha_short }} | ||
- uses: actions/cache@v3 | ||
with: | ||
path: dist/darwin | ||
key: darwin-${{ env.sha_short }} | ||
- uses: actions/cache@v3 | ||
with: | ||
path: dist/windows | ||
key: windows-${{ env.sha_short }} | ||
|
||
|
||
# release | ||
- uses: goreleaser/goreleaser-action@v3 | ||
if: steps.cache.outputs.cache-hit != 'true' # do not run if cache hit | ||
with: | ||
distribution: goreleaser-pro | ||
version: latest | ||
args: continue --merge | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GH_PAT }} | ||
GORELEASER_KEY: ${{ secrets.GORELEASER_KEY }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
dist* | ||
|
||
dist/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,155 @@ | ||
# This is an example-real .goreleaser.yml file with some sensible defaults. | ||
# Make sure to check the documentation at https://goreleaser.com | ||
before: | ||
hooks: | ||
- go mod tidy | ||
builds: | ||
- targets: [go_first_class] | ||
mod_timestamp: '{{ .CommitTimestamp }}' | ||
flags: | ||
# trims path | ||
- -trimpath | ||
ldflags: | ||
# use commit date instead of current date as main.date | ||
# only needed if you actually use those things in your main package, otherwise can be ignored. | ||
- -s -w -X main.version={{.Version}} -X main.commit={{.Commit}} -X main.date={{ .CommitDate }} | ||
checksum: | ||
name_template: 'checksums.txt' | ||
snapshot: | ||
name_template: "{{ incpatch .Version }}-next" | ||
changelog: | ||
sort: asc | ||
filters: | ||
exclude: | ||
- '^docs:' | ||
- '^test:' | ||
|
||
nfpms: | ||
- file_name_template: '{{ .ConventionalFileName }}' | ||
homepage: https://goreleaser.com | ||
description: Just another example | ||
maintainer: Carlos Alexandro Becker <[email protected]> | ||
license: MIT | ||
vendor: GoReleaser | ||
bindir: /usr/bin | ||
section: utils | ||
formats: [apk, deb, rpm] | ||
|
||
release: | ||
name_template: 'v{{ .Version }}' | ||
footer: | | ||
* * * | ||
<a href="https://goreleser.com"><img src="https://raw.githubusercontent.com/goreleaser/artwork/master/opencollective-header.png" with="100%" alt="GoReleaser logo"></a> | ||
Find example-reals and commented usage of all options in our [website](https://goreleaser.com/intro/). | ||
Want to help? You can [sponsor](https://goreleaser.com/sponsors/),get a [Pro License](https://goreleaser.com/pro) or [contribute](https://goreleaser.com/contributing). | ||
Also, feel free to reach out on [Discord](https://discord.gg/RGEBtg8vQ6) and [Twitter](https://twitter.com/goreleaser)! | ||
nightly: | ||
publish_release: true | ||
keep_single_release: true | ||
name_template: '{{ incminor .Version }}-nightly' | ||
tag_name: nightly | ||
|
||
|
||
dockers: | ||
- image_templates: | ||
- 'ghcr.io/caarlos0/goreleaser-pro-split-merge-example-real:v{{ .Version }}-amd64' | ||
build_flag_templates: | ||
- "--pull" | ||
- "--label=org.opencontainers.image.description=Just an example-real" | ||
- "--label=org.opencontainers.image.created={{.Date}}" | ||
- "--label=org.opencontainers.image.name={{.ProjectName}}" | ||
- "--label=org.opencontainers.image.revision={{.FullCommit}}" | ||
- "--label=org.opencontainers.image.version={{.Version}}" | ||
- "--label=org.opencontainers.image.source={{.GitURL}}" | ||
- "--platform=linux/amd64" | ||
use: buildx | ||
- image_templates: | ||
- 'ghcr.io/caarlos0/goreleaser-pro-split-merge-example-real:v{{ .Version }}-arm64' | ||
build_flag_templates: | ||
- "--pull" | ||
- "--label=org.opencontainers.image.description=Just an example-real" | ||
- "--label=org.opencontainers.image.created={{.Date}}" | ||
- "--label=org.opencontainers.image.name={{.ProjectName}}" | ||
- "--label=org.opencontainers.image.revision={{.FullCommit}}" | ||
- "--label=org.opencontainers.image.version={{.Version}}" | ||
- "--label=org.opencontainers.image.source={{.GitURL}}" | ||
- "--platform=linux/arm64" | ||
use: buildx | ||
- image_templates: | ||
- 'ghcr.io/caarlos0/goreleaser-pro-split-merge-example-real:v{{ .Version }}-windows-amd64' | ||
build_flag_templates: | ||
- "--pull" | ||
- "--label=org.opencontainers.image.description=Just an example-real" | ||
- "--label=org.opencontainers.image.created={{.Date}}" | ||
- "--label=org.opencontainers.image.name={{.ProjectName}}" | ||
- "--label=org.opencontainers.image.revision={{.FullCommit}}" | ||
- "--label=org.opencontainers.image.version={{.Version}}" | ||
- "--label=org.opencontainers.image.source={{.GitURL}}" | ||
- "--platform=windows/amd64" | ||
goos: windows | ||
dockerfile: windows.dockerfile | ||
|
||
docker_manifests: | ||
- name_template: 'ghcr.io/caarlos0/goreleaser-pro-split-merge-example-real:v{{ .Version }}' | ||
image_templates: | ||
- 'ghcr.io/caarlos0/goreleaser-pro-split-merge-example-real:v{{ .Version }}-amd64' | ||
- 'ghcr.io/caarlos0/goreleaser-pro-split-merge-example-real:v{{ .Version }}-arm64' | ||
- 'ghcr.io/caarlos0/goreleaser-pro-split-merge-example-real:v{{ .Version }}-windows-amd64' | ||
- name_template: '{{ if not .IsNightly }}ghcr.io/caarlos0/goreleaser-pro-split-merge-example-real:latest{{ end }}' | ||
image_templates: | ||
- 'ghcr.io/caarlos0/goreleaser-pro-split-merge-example-real:v{{ .Version }}-amd64' | ||
- 'ghcr.io/caarlos0/goreleaser-pro-split-merge-example-real:v{{ .Version }}-arm64' | ||
- 'ghcr.io/caarlos0/goreleaser-pro-split-merge-example-real:v{{ .Version }}-windows-amd64' | ||
|
||
monorepo: | ||
tag_prefix: v # so it always filters out the nightly tag | ||
|
||
|
||
# signs the checksum file | ||
# 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 | ||
# https://goreleaser.com/customization/sign | ||
signs: | ||
- cmd: cosign | ||
env: | ||
- COSIGN_EXPERIMENTAL=1 | ||
certificate: '${artifact}.pem' | ||
args: | ||
- sign-blob | ||
- '--output-certificate=${certificate}' | ||
- '--output-signature=${signature}' | ||
- '${artifact}' | ||
artifacts: checksum | ||
output: true | ||
|
||
# create a source tarball | ||
# https://goreleaser.com/customization/source/ | ||
source: | ||
enabled: true | ||
|
||
# creates SBOMs of all archives and the source tarball using syft | ||
# https://goreleaser.com/customization/sbom | ||
sboms: | ||
- artifacts: archive | ||
- id: source # Two different sbom configurations need two different IDs | ||
artifacts: source | ||
|
||
# signs our docker image | ||
# https://goreleaser.com/customization/docker_sign | ||
docker_signs: | ||
- cmd: cosign | ||
env: | ||
- COSIGN_EXPERIMENTAL=1 | ||
artifacts: images | ||
output: true | ||
args: | ||
- 'sign' | ||
- '${artifact}' | ||
|
||
|
||
# modelines, feel free to remove those if you don't want/use them: | ||
# yaml-language-server: $schema=https://goreleaser.com/static/schema-pro.json | ||
# vim: set ts=2 sw=2 tw=0 fo=cnqoj |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
FROM alpine | ||
COPY goreleaser-pro-split-merge-example-real /usr/bin/example | ||
ENTRYPOINT ["/usr/bin/example"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
# GoReleaser Pro Split & Merge Example (real) | ||
|
||
This repo contains a quick and to-the-point example of how to use | ||
[GoReleaser Pro](https://goreleaser.com/pro) | ||
[split and merge builds](https://goreleaser.com/customization/partial/). | ||
|
||
This also serves as a [nightly](https://goreleaser.com/customization/nightlies/) example. | ||
|
||
The difference from this and | ||
[the other example](https://github.com/caarlos0/goreleaser-pro-split-merge-example/commits/main), | ||
is that this one uses the "real" OS instead of just setting `GOOS`. It also | ||
leverages that to create Windows Docker Images. | ||
|
||
--- | ||
|
||
For now, this repo is not using the goreleaser action, as it does not work with | ||
nightlies (yet), but it will, soon enough. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
module test | ||
|
||
go 1.19 |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
package main | ||
|
||
import "fmt" | ||
|
||
func main() { | ||
fmt.Println("hello world!") | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
FROM mcr.microsoft.com/windows/nanoserver:ltsc2022 | ||
WORKDIR /app | ||
COPY goreleaser-pro-split-merge-example-real.exe example.exe | ||
ENTRYPOINT ["/app/example.exe"] |