-
Notifications
You must be signed in to change notification settings - Fork 0
105 lines (95 loc) · 2.87 KB
/
go-build-and-release.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
name: deepSentinel SLSA3 build and release
on:
workflow_dispatch:
push:
tags:
- "v*"
permissions: read-all
env:
IMAGE_REGISTRY: ghcr.io
IMAGE_OWNER: equals215
IMAGE_NAME: deepsentinel-server
jobs:
tests:
uses: ./.github/workflows/go-tests-coverage.yml
build:
needs: [tests]
strategy:
matrix:
component:
- server
- agent
os:
- linux
- darwin
arch:
- amd64
- arm64
permissions:
id-token: write # To sign.
contents: write # To upload release assets.
actions: read # To read workflow path.
uses: slsa-framework/slsa-github-generator/.github/workflows/[email protected]
with:
go-version: 1.22.2
config-file: .github/workflows/slsa3-configs/${{ matrix.component }}-${{ matrix.os }}-${{ matrix.arch }}.yml
prerelease: true
package:
needs: [tests, build]
permissions:
contents: read
packages: write
outputs:
image: ${{ steps.image.outputs.image }}
digest: ${{ steps.build.outputs.digest }}
runs-on: ubuntu-latest
steps:
- name: Checkout the repository
uses: actions/checkout@v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Authenticate Docker
uses: docker/login-action@v2
with:
registry: ${{ env.IMAGE_REGISTRY }}
username: ${{ env.IMAGE_OWNER }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/[email protected]
with:
images: |
${{ env.IMAGE_REGISTRY }}/${{ env.IMAGE_OWNER }}/${{ env.IMAGE_NAME }}
tags: |
type=ref,event=tag
type=sha
- name: Build and push Docker image
uses: docker/[email protected]
id: build
with:
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
platforms: linux/amd64,linux/arm64
file: Dockerfile.server
- name: Output image
id: image
run: |
image_name="${IMAGE_REGISTRY}/${IMAGE_OWNER}/${IMAGE_NAME}"
echo "image=$image_name" >> "$GITHUB_OUTPUT"
# This step calls the container workflow to generate provenance and push it to
# the container registry.
package-provenance:
needs: [package]
permissions:
actions: read
id-token: write
packages: write
if: startsWith(github.ref, 'refs/tags/')
uses: slsa-framework/slsa-github-generator/.github/workflows/[email protected]
with:
image: ${{ needs.package.outputs.image }}
digest: ${{ needs.package.outputs.digest }}
registry-username: ${{ github.actor }}
secrets:
registry-password: ${{ secrets.GITHUB_TOKEN }}