Skip to content

Commit ccd5037

Browse files
committed
Add standard CI jobs
Signed-off-by: Adolfo García Veytia (Puerco) <puerco@carabiner.dev>
1 parent dfc134e commit ccd5037

5 files changed

Lines changed: 217 additions & 1 deletion

File tree

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
# SPDX-FileCopyrightText: Copyright 2026 Carabiner Systems, Inc
2+
# SPDX-License-Identifier: Apache-2.0
3+
4+
name: go-tests
5+
6+
on:
7+
pull_request:
8+
branches: [ "main" ]
9+
workflow_dispatch: {}
10+
11+
jobs:
12+
resolve-versions:
13+
runs-on: ubuntu-latest
14+
outputs:
15+
go-versions: ${{ steps.matrix.outputs.go-versions }}
16+
steps:
17+
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
18+
with:
19+
persist-credentials: false
20+
21+
- name: Resolve Go versions
22+
id: go-versions
23+
uses: carabiner-dev/actions/go/versions@360ffa1eb909b0105d4eccb6d6ef337911c34952 # v1.1.6
24+
25+
- name: Build version matrix
26+
id: matrix
27+
run: |
28+
echo "go-versions=[\"${{ steps.go-versions.outputs.GO_VERSION_STABLE }}\",\"${{ steps.go-versions.outputs.GO_VERSION_PREVIOUS }}\"]" >> "$GITHUB_OUTPUT"
29+
30+
test:
31+
needs: resolve-versions
32+
runs-on: ${{ matrix.os }}
33+
strategy:
34+
matrix:
35+
go-version: ${{ fromJSON(needs.resolve-versions.outputs.go-versions) }}
36+
os: [ubuntu-latest, macos-latest, windows-latest]
37+
fail-fast: false
38+
39+
steps:
40+
- name: Preserve line endings
41+
run: git config --global core.autocrlf false
42+
43+
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
44+
with:
45+
persist-credentials: false
46+
47+
- name: Set up Go ${{ matrix.go-version }}
48+
uses: actions/setup-go@4a3601121dd01d1626a1e23e37211e3254c1c06c # v6.4.0
49+
with:
50+
go-version: ${{ matrix.go-version }}
51+
cache: false
52+
53+
- name: Test
54+
run: |
55+
go get -d ./...
56+
go test -v ./...
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
# SPDX-FileCopyrightText: Copyright 2026 Carabiner Systems, Inc
2+
# SPDX-License-Identifier: Apache-2.0
3+
4+
name: golangci-lint
5+
6+
on:
7+
workflow_dispatch: {}
8+
pull_request:
9+
branches:
10+
- main
11+
12+
permissions:
13+
contents: read
14+
15+
jobs:
16+
golangci:
17+
name: lint
18+
runs-on: ubuntu-latest
19+
steps:
20+
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
21+
with:
22+
persist-credentials: false
23+
24+
- name: Resolve Go versions
25+
id: go-versions
26+
uses: carabiner-dev/actions/go/versions@360ffa1eb909b0105d4eccb6d6ef337911c34952 # v1.1.6
27+
28+
- uses: actions/setup-go@4a3601121dd01d1626a1e23e37211e3254c1c06c # v6.4.0
29+
with:
30+
go-version: ${{ steps.go-versions.outputs.GO_VERSION_STABLE }}
31+
cache: true
32+
33+
- name: Run golangci-lint
34+
uses: golangci/golangci-lint-action@1e7e51e771db61008b38414a730f564565cf7c20 # v9.2.0
35+
with:
36+
version: v2.11

.github/workflows/release.yaml

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
# SPDX-FileCopyrightText: Copyright 2026 Carabiner Systems, Inc
2+
# SPDX-License-Identifier: Apache-2.0
3+
4+
name: Release
5+
6+
on:
7+
push:
8+
tags:
9+
- 'v*'
10+
11+
permissions:
12+
contents: read
13+
14+
jobs:
15+
release:
16+
runs-on: ubuntu-latest
17+
18+
permissions:
19+
contents: write
20+
id-token: write
21+
attestations: write
22+
23+
steps:
24+
- name: Setup bnd
25+
uses: carabiner-dev/actions/install/bnd@360ffa1eb909b0105d4eccb6d6ef337911c34952 # v1.1.6
26+
27+
- name: Check out code
28+
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
29+
with:
30+
fetch-depth: 1
31+
persist-credentials: false
32+
33+
- uses: actions/setup-go@4a3601121dd01d1626a1e23e37211e3254c1c06c # v6.4.0
34+
with:
35+
go-version-file: go.mod
36+
cache: false
37+
38+
- name: Install tejolote
39+
uses: kubernetes-sigs/release-actions/setup-tejolote@8753ea6bdadb814d779c6ec34eaca689dbfb492b # v0.4.3
40+
41+
- name: Set tag output
42+
id: tag
43+
run: echo "tag_name=${GITHUB_REF#refs/*/}" >> "$GITHUB_OUTPUT"
44+
45+
- name: Run GoReleaser
46+
uses: goreleaser/goreleaser-action@ec59f474b9834571250b370d4735c50f8e2d1e29 # v7.0.0
47+
id: goreleaser
48+
with:
49+
args: release --clean
50+
env:
51+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
52+
53+
- name: Generate Provenance
54+
id: tejolote
55+
env:
56+
GH_TOKEN: ${{ github.token }}
57+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
58+
run: |
59+
tejolote attest --artifacts github://${{github.repository}}/${{ steps.tag.outputs.tag_name }} github://${{github.repository}}/"${GITHUB_RUN_ID}" --output provenance.json
60+
bnd statement provenance.json -o policyctl-${{ steps.tag.outputs.tag_name }}.provenance.json
61+
gh release upload ${{ steps.tag.outputs.tag_name }} policyctl-${{ steps.tag.outputs.tag_name }}.provenance.json
62+
bnd push ${{github.repository}} policyctl-${{ steps.tag.outputs.tag_name }}.provenance.json
63+
64+
- name: Generate SBOM
65+
uses: carabiner-dev/actions/unpack/sbom@360ffa1eb909b0105d4eccb6d6ef337911c34952 # v1.1.6
66+
env:
67+
GH_TOKEN: ${{ github.token }}
68+
with:
69+
ignore: testdata
70+
format: spdx
71+
push-to-release: ${{ steps.tag.outputs.tag_name }}

.goreleaser.yaml

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
# SPDX-FileCopyrightText: Copyright 2026 Carabiner Systems, Inc
2+
# SPDX-License-Identifier: Apache-2.0
3+
4+
project_name: policyctl
5+
version: 2
6+
7+
env:
8+
- GO111MODULE=on
9+
- CGO_ENABLED=0
10+
11+
before:
12+
hooks:
13+
- go mod tidy
14+
- /bin/bash -c 'if [ -n "$(git --no-pager diff --exit-code go.mod go.sum)" ]; then exit 1; fi'
15+
16+
gomod:
17+
proxy: true
18+
19+
builds:
20+
- id: release
21+
no_unique_dist_dir: true
22+
binary: policyctl-{{ .Tag }}-{{ .Os }}-{{ .Arch }}
23+
main: .
24+
goos:
25+
- darwin
26+
- linux
27+
- windows
28+
goarch:
29+
- amd64
30+
- arm64
31+
ignore:
32+
- goos: windows
33+
goarch: arm64
34+
- goos: darwin
35+
goarch: amd64
36+
flags:
37+
- -trimpath
38+
39+
archives:
40+
- formats: binary
41+
name_template: policyctl-{{ .Tag }}-{{ .Os }}-{{ .Arch }}
42+
allow_different_binary_count: true
43+
checksum:
44+
disable: true
45+
46+
release:
47+
github:
48+
owner: carabiner-dev
49+
name: policyctl
50+
prerelease: auto
51+
52+
changelog:
53+
disable: true

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
module github.com/carabiner-dev/policyctl
22

3-
go 1.26.1
3+
go 1.26.2
44

55
require (
66
github.com/TylerBrock/colorjson v0.0.0-20200706003622-8a50f05110d2

0 commit comments

Comments
 (0)