-
Notifications
You must be signed in to change notification settings - Fork 1
165 lines (146 loc) · 4.78 KB
/
Copy pathrelease.yml
File metadata and controls
165 lines (146 loc) · 4.78 KB
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
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
name: Release
on:
push:
tags:
- "v*"
workflow_dispatch:
inputs:
version:
description: "Version string for manual dry-run builds"
required: false
default: "manual"
permissions:
contents: read
concurrency:
group: release-${{ github.ref }}
cancel-in-progress: false
jobs:
package:
name: Package (${{ matrix.goos }}/${{ matrix.goarch }})
runs-on: ubuntu-latest
permissions:
contents: read
id-token: write
attestations: write
strategy:
fail-fast: false
matrix:
include:
- goos: linux
goarch: amd64
archive: tar.gz
- goos: linux
goarch: arm64
archive: tar.gz
- goos: darwin
goarch: amd64
archive: tar.gz
- goos: darwin
goarch: arm64
archive: tar.gz
- goos: windows
goarch: amd64
archive: zip
steps:
- name: Checkout
uses: actions/checkout@v6
- name: Setup Go
uses: actions/setup-go@v6
with:
go-version: "stable"
cache: false
- name: Build package
id: package
env:
CGO_ENABLED: "0"
GOOS: ${{ matrix.goos }}
GOARCH: ${{ matrix.goarch }}
VERSION_INPUT: ${{ github.event.inputs.version }}
run: |
set -euo pipefail
version="$GITHUB_REF_NAME"
if [ "$GITHUB_EVENT_NAME" = "workflow_dispatch" ] && [ -n "$VERSION_INPUT" ]; then
version="$VERSION_INPUT"
fi
package="prmaven-${version}-${GOOS}-${GOARCH}"
mkdir -p "dist/${package}"
binary="prmaven"
if [ "$GOOS" = "windows" ]; then
binary="prmaven.exe"
fi
go build -trimpath -ldflags="-s -w -X main.version=${version}" -o "dist/${package}/${binary}" ./cmd/prmaven
cp README.md LICENSE "dist/${package}/"
cd dist
if [ "${{ matrix.archive }}" = "zip" ]; then
zip -r "${package}.zip" "$package"
else
tar -czf "${package}.tar.gz" "$package"
fi
sha256sum "${package}.${{ matrix.archive }}" > "${package}.${{ matrix.archive }}.sha256"
echo "package_dir=dist/${package}" >> "$GITHUB_OUTPUT"
echo "archive_path=dist/${package}.${{ matrix.archive }}" >> "$GITHUB_OUTPUT"
echo "checksum_path=dist/${package}.${{ matrix.archive }}.sha256" >> "$GITHUB_OUTPUT"
echo "sbom_path=dist/${package}.sbom.spdx.json" >> "$GITHUB_OUTPUT"
echo "sbom_checksum_path=dist/${package}.sbom.spdx.json.sha256" >> "$GITHUB_OUTPUT"
- name: Generate package SBOM
uses: anchore/sbom-action@v0
with:
path: ${{ steps.package.outputs.package_dir }}
format: spdx-json
output-file: ${{ steps.package.outputs.sbom_path }}
syft-version: v1.44.0
upload-artifact: false
upload-release-assets: false
- name: Generate SBOM checksum
run: sha256sum "${{ steps.package.outputs.sbom_path }}" > "${{ steps.package.outputs.sbom_checksum_path }}"
- name: Generate package provenance attestation
uses: actions/attest@v4
with:
subject-path: ${{ steps.package.outputs.archive_path }}
- name: Generate checksum provenance attestation
uses: actions/attest@v4
with:
subject-path: ${{ steps.package.outputs.checksum_path }}
- name: Generate package SBOM attestation
uses: actions/attest@v4
with:
subject-path: ${{ steps.package.outputs.archive_path }}
sbom-path: ${{ steps.package.outputs.sbom_path }}
- name: Generate SBOM file provenance attestation
uses: actions/attest@v4
with:
subject-path: ${{ steps.package.outputs.sbom_path }}
- name: Upload package artifacts
uses: actions/upload-artifact@v7
with:
name: prmaven-${{ matrix.goos }}-${{ matrix.goarch }}
path: |
dist/*.tar.gz
dist/*.zip
dist/*.sha256
dist/*.sbom.spdx.json
dist/*.sbom.spdx.json.sha256
release:
name: Publish GitHub release
if: startsWith(github.ref, 'refs/tags/v')
runs-on: ubuntu-latest
needs:
- package
permissions:
contents: write
steps:
- name: Download artifacts
uses: actions/download-artifact@v8
with:
path: dist
merge-multiple: true
- name: Publish release
uses: softprops/action-gh-release@v3
with:
files: |
dist/*.tar.gz
dist/*.zip
dist/*.sha256
dist/*.sbom.spdx.json
dist/*.sbom.spdx.json.sha256
generate_release_notes: true