-
Notifications
You must be signed in to change notification settings - Fork 49
190 lines (164 loc) · 6.53 KB
/
create-release-v2.yaml
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
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
name: 'Create and Publish Tags with Testing and Artifact Handling'
on:
workflow_dispatch:
inputs:
TAG:
description: 'Tag name'
required: true
type: string
push:
tags:
- 'v*.*.*-rc.*'
env:
REGO_ARTIFACT_KEY_NAME: rego_artifact
REGO_ARTIFACT_PATH: release
jobs:
test_pr_checks:
permissions:
pull-requests: write
uses: kubescape/workflows/.github/workflows/go-basic-tests.yaml@main
with:
GO_VERSION: '1.21'
BUILD_PATH: github.com/kubescape/regolibrary/gitregostore/...
secrets: inherit
build-and-rego-test:
needs: [test_pr_checks]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
name: Checkout repo content
- name: Set up Go 1.21
uses: actions/setup-go@v2
with:
go-version: 1.21
- name: Test Regos (Golang OPA hot rule compilation)
working-directory: testrunner
run: |
sudo apt update && sudo apt install -y cmake
GOPATH=$(go env GOPATH) make
- name: Setup Python 3.10.6
uses: actions/setup-python@v2
with:
python-version: 3.10.6
- name: Install Python dependencies
run: |
python -m pip install --upgrade pip
pip install requests
- name: Update frameworks subsections (generating subsections ids)
run: python ./scripts/generate_subsections_ids.py
- name: Validate control-ID duplications
run: python ./scripts/validations.py
- name: Generate RegoLibrary artifacts (run export script)
run: python ./scripts/export.py
- name: Strip Metadata Files Extensions
run: |
cd release
find . -type f \( -name '*.json' -o -name '*.csv' \) | while read f; do mv "$f" "${f%.*}"; done
- run: ls -laR
- name: Set outputs
id: set_outputs
run: |
echo "REGO_ARTIFACT_KEY_NAME=${{ env.REGO_ARTIFACT_KEY_NAME }}" >> $GITHUB_OUTPUT
echo "REGO_ARTIFACT_PATH=${{ env.REGO_ARTIFACT_PATH }}" >> $GITHUB_OUTPUT
- name: Upload artifact
uses: actions/upload-artifact@v2
with:
name: ${{ env.REGO_ARTIFACT_KEY_NAME }}
path: ${{ env.REGO_ARTIFACT_PATH }}/
if-no-files-found: error
# test kubescape e2e flow with tested artifacts
ks-and-rego-test:
uses: kubescape/workflows/.github/workflows/kubescape-cli-e2e-tests.yaml@main
needs: [build-and-rego-test]
if: ${{ (always() && (contains(needs.*.result, 'success')) && !(contains(needs.*.result, 'skipped')) && !(contains(needs.*.result, 'failure')) && !(contains(needs.*.result, 'cancelled'))) }}
with:
DOWNLOAD_ARTIFACT_KEY_NAME: ${{ needs.build-and-rego-test.outputs.REGO_ARTIFACT_KEY_NAME }}
BINARY_TESTS: '[ "scan_nsa",
"scan_mitre",
"scan_with_exceptions",
"scan_repository",
"scan_local_file",
"scan_local_glob_files",
"scan_nsa_and_submit_to_backend",
"scan_mitre_and_submit_to_backend",
"scan_local_repository_and_submit_to_backend",
"scan_repository_from_url_and_submit_to_backend",
"host_scanner",
"scan_local_list_of_files",
"scan_compliance_score"
]'
DOWNLOAD_ARTIFACT_PATH: ${{ needs.build-and-rego-test.outputs.REGO_ARTIFACT_PATH }}
secrets: inherit
# start release process
create-new-tag-and-release:
needs: [ks-and-rego-test]
if: ${{ (always() && (contains(needs.*.result, 'success')) && !(contains(needs.*.result, 'skipped')) && !(contains(needs.*.result, 'failure')) && !(contains(needs.*.result, 'cancelled'))) }}
name: create release and upload assets
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
name: Checkout repository
- name: 'Generate Release Tag'
id: generate_tag
uses: kubescape/workflows/.github/actions/tag-action@main
with:
ORIGINAL_TAG: ${{ github.ref_name }}
SUB_STRING: "-rc."
# Create and push the full version tag (e.g., v2.0.1)
- name: Create and Push Full Tag
uses: rickstaa/action-create-tag@v1
with:
tag: ${{ steps.generate_tag.outputs.NEW_TAG }}
force_push_tag: false
github_token: ${{ secrets.GITHUB_TOKEN }}
- name: Generate Short Tag
id: short_tag
run: |
SHORT_TAG=$(echo "${{ steps.generate_tag.outputs.NEW_TAG }}" | grep -oP '^v\d+')
echo "Short tag: $SHORT_TAG"
echo "SHORT_TAG=$SHORT_TAG" >> $GITHUB_ENV
- name: Force Push Short Tag
uses: rickstaa/action-create-tag@v1
with:
tag: ${{ env.SHORT_TAG }}
force_push_tag: true
github_token: ${{ secrets.GITHUB_TOKEN }}
- uses: actions/download-artifact@9bc31d5ccc31df68ecc42ccf4149144866c47d8a # ratchet:actions/[email protected]
id: download-artifact
with:
name: ${{ env.REGO_ARTIFACT_KEY_NAME }}
path: ${{ env.REGO_ARTIFACT_PATH }}
- name: Create or Update Release and Upload Assets
uses: softprops/action-gh-release@v2
with:
token: ${{ secrets.GITHUB_TOKEN }}
tag_name: ${{ env.SHORT_TAG }}
name: ${{ env.SHORT_TAG }}
body: "Automated release for ${{ env.SHORT_TAG}}"
files: ${{ env.REGO_ARTIFACT_PATH }}/*
draft: false
fail_on_unmatched_files: true
prerelease: false
make_latest: "false"
# Update regolibrary documentation with latest controls and rules.
update-documentation:
needs: [create-new-tag-and-release]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@8e5e7e5ab8b370d6c329ec480221332ada57f0ab # ratchet:actions/[email protected]
name: checkout repo content
- name: setup python
uses: actions/setup-python@57ded4d7d5e986d7296eab16560982c6dd7c923b # ratchet:actions/[email protected]
with:
python-version: 3.8
- name: install dependencies
run: |
python -m pip install --upgrade pip
pip install requests
- name: execute upload script
env:
README_API_KEY: ${{ secrets.README_API_KEY }}
run: |-
python ./scripts/upload-readme.py
- name: execute docs generator script
run: python ./scripts/mk-generator.py # Script to generate controls library documentation