Skip to content

Commit ede4c57

Browse files
authored
feat: add docker, signing, nfpm, more (#1)
* feat: add docker, signing, nfpm, more * fix: nfpm name * fix: renames, dependabot * fix: docker images * ci: brew Signed-off-by: Carlos Alexandro Becker <[email protected]> * fix: stuff * chore: cleanup --------- Signed-off-by: Carlos Alexandro Becker <[email protected]>
1 parent 93d2451 commit ede4c57

File tree

8 files changed

+189
-26
lines changed

8 files changed

+189
-26
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: cargo
4+
directory: "/"
5+
schedule:
6+
interval: "daily"
7+
time: "08:00"
8+
labels:
9+
- "dependencies"
10+
commit-message:
11+
prefix: "chore"
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: "chore"
32+
include: "scope"

.github/workflows/build.yml

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
name: build
2+
3+
on:
4+
push:
5+
branches: ["main"]
6+
pull_request:
7+
8+
env:
9+
CARGO_TERM_COLOR: always
10+
11+
jobs:
12+
build:
13+
runs-on: ubuntu-latest
14+
steps:
15+
- uses: actions/checkout@v4
16+
- run: cargo build --verbose
17+
- run: cargo test --verbose
18+
dependabot:
19+
needs: [build]
20+
runs-on: ubuntu-latest
21+
permissions:
22+
pull-requests: write
23+
contents: write
24+
if: ${{ github.actor == 'dependabot[bot]' && github.event_name == 'pull_request'}}
25+
steps:
26+
- id: metadata
27+
uses: dependabot/fetch-metadata@v2
28+
with:
29+
github-token: "${{ secrets.GITHUB_TOKEN }}"
30+
- run: |
31+
gh pr review --approve "$PR_URL"
32+
gh pr merge --squash --auto "$PR_URL"
33+
env:
34+
PR_URL: ${{github.event.pull_request.html_url}}
35+
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}

.github/workflows/release.yml

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,16 @@
1-
# .github/workflows/release.yml
21
name: goreleaser
32

43
on:
5-
pull_request:
64
push:
75
# run only against tags
86
tags:
97
- "*"
108

119
permissions:
1210
contents: write
13-
# packages: write
14-
# issues: write
15-
# id-token: write
11+
packages: write
12+
issues: write
13+
id-token: write
1614

1715
jobs:
1816
goreleaser:
@@ -24,6 +22,15 @@ jobs:
2422
# More assembly might be required: Docker logins, GPG, etc.
2523
# It all depends on your needs.
2624
- uses: mlugg/setup-zig@v1
25+
- uses: sigstore/[email protected]
26+
- uses: anchore/sbom-action/[email protected]
27+
- uses: docker/setup-qemu-action@v3
28+
- uses: docker/setup-buildx-action@v3
29+
- uses: docker/login-action@v3
30+
with:
31+
registry: ghcr.io
32+
username: ${{ github.repository_owner }}
33+
password: ${{ secrets.GITHUB_TOKEN }}
2734
- uses: goreleaser/goreleaser-action@v6
2835
with:
2936
# either 'goreleaser' (default) or 'goreleaser-pro'
@@ -35,3 +42,4 @@ jobs:
3542
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
3643
# Your GoReleaser Pro key, if you are using the 'goreleaser-pro' distribution
3744
# GORELEASER_KEY: ${{ secrets.GORELEASER_KEY }}
45+
GH_PAT: ${{ secrets.GH_PAT }}

.github/workflows/rust.yml

Lines changed: 0 additions & 17 deletions
This file was deleted.

.goreleaser.yaml

Lines changed: 104 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,18 @@
88

99
version: 2
1010

11+
# Project name should ideally match the project name in your Cargo.toml.
12+
project_name: example
13+
14+
# Hooks ran before actually building anything.
15+
# Here we use them to prepare for building.
1116
before:
1217
hooks:
13-
# if you don't do these things before calling goreleaser, it might be a
14-
# good idea to do them here:
1518
- rustup default stable
1619
- cargo install --locked cargo-zigbuild
1720
- cargo fetch --locked
1821

22+
# Actually builds the binaries.
1923
builds:
2024
- builder: rust
2125
targets:
@@ -25,6 +29,7 @@ builds:
2529
- aarch64-unknown-linux-gnu
2630
- aarch64-apple-darwin
2731

32+
# Creates archives for each target.
2833
archives:
2934
- format: tar.gz
3035
# this name template makes the OS and Arch compatible with the results of `uname`.
@@ -39,16 +44,113 @@ archives:
3944
- goos: windows
4045
format: zip
4146

47+
# Changelog configuration (will be in the github release).
4248
changelog:
4349
sort: asc
4450
filters:
4551
exclude:
4652
- "^docs:"
4753
- "^test:"
4854

55+
# A footer to add to all releases.
4956
release:
5057
footer: >-
5158
5259
---
5360
5461
Released by [GoReleaser](https://github.com/goreleaser/goreleaser).
62+
63+
# Creates Linux packages.
64+
nfpms:
65+
- file_name_template: "{{ .ConventionalFileName }}"
66+
maintainer: Carlos Alexandro Becker <[email protected]>
67+
formats:
68+
- deb
69+
- apk
70+
- rpm
71+
72+
# Creates Darwin universal binaries.
73+
universal_binaries:
74+
- replace: true
75+
76+
# Enables source archives.
77+
source:
78+
enabled: true
79+
80+
# SBOMs for the archives and source archives.
81+
sboms:
82+
- artifacts: any
83+
84+
# Sign binaries with cosign.
85+
signs:
86+
- cmd: cosign
87+
certificate: "${artifact}.pem"
88+
args:
89+
- sign-blob
90+
- "--output-certificate=${certificate}"
91+
- "--output-signature=${signature}"
92+
- "${artifact}"
93+
- "--yes"
94+
artifacts: checksum
95+
96+
# Create Docker images.
97+
# We create a manifest below, so here the images need the suffix with the
98+
# architecture.
99+
dockers:
100+
- image_templates:
101+
- "ghcr.io/goreleaser/example-rust:{{ .Tag }}-arm64"
102+
dockerfile: Dockerfile
103+
goarch: arm64
104+
use: buildx
105+
build_flag_templates:
106+
- "--pull"
107+
- "--label=org.opencontainers.image.created={{.Date}}"
108+
- "--label=org.opencontainers.image.name={{.ProjectName}}"
109+
- "--label=org.opencontainers.image.revision={{.FullCommit}}"
110+
- "--label=org.opencontainers.image.version={{.Version}}"
111+
- "--label=org.opencontainers.image.source={{.GitURL}}"
112+
- "--platform=linux/arm64"
113+
- image_templates:
114+
- "ghcr.io/goreleaser/example-rust:{{ .Tag }}-amd64"
115+
dockerfile: Dockerfile
116+
goarch: amd64
117+
use: buildx
118+
build_flag_templates:
119+
- "--pull"
120+
- "--label=org.opencontainers.image.created={{.Date}}"
121+
- "--label=org.opencontainers.image.name={{.ProjectName}}"
122+
- "--label=org.opencontainers.image.revision={{.FullCommit}}"
123+
- "--label=org.opencontainers.image.version={{.Version}}"
124+
- "--label=org.opencontainers.image.source={{.GitURL}}"
125+
- "--platform=linux/amd64"
126+
127+
# Here we join both images into a Docker manifest.
128+
docker_manifests:
129+
- name_template: "ghcr.io/goreleaser/example-rust:{{ .Tag }}"
130+
image_templates:
131+
- "ghcr.io/goreleaser/example-rust:{{ .Tag }}-arm64"
132+
- "ghcr.io/goreleaser/example-rust:{{ .Tag }}-amd64"
133+
134+
# Sign the Docker images with cosign as well.
135+
docker_signs:
136+
- cmd: cosign
137+
artifacts: manifests
138+
args:
139+
- "sign"
140+
- "${artifact}"
141+
- "--yes"
142+
143+
# Sets up homebrew-taps.
144+
# PS: this will require a personal access token, as it is cross-repository.
145+
brews:
146+
- repository:
147+
owner: goreleaser
148+
name: example-homebrew-tap
149+
token: "{{ .Env.GH_PAT }}"
150+
directory: Formula
151+
homepage: https://goreleaser.com
152+
description: Example rust release.
153+
license: MIT
154+
# usually you don't need to set this, we do to prevent conflicts with other
155+
# example-* repositories
156+
name: example-rust

Cargo.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
[package]
2-
name = "example-rust"
2+
name = "example"
33
version = "0.1.0"
44
edition = "2021"
55

Dockerfile

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

0 commit comments

Comments
 (0)