Skip to content

Commit 4692853

Browse files
authored
cicd (#7)
1 parent 2314610 commit 4692853

14 files changed

Lines changed: 227 additions & 79 deletions

.github/workflows/codeql.yml

Lines changed: 79 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,98 @@
1+
# For most projects, this workflow file will not need changing; you simply need
2+
# to commit it to your repository.
3+
#
4+
# You may wish to alter this file to override the set of languages analyzed,
5+
# or to provide custom queries or build logic.
6+
#
7+
# ******** NOTE ********
8+
# We have attempted to detect the languages in your repository. Please check
9+
# the `language` matrix defined below to confirm you have the correct set of
10+
# supported CodeQL languages.
11+
#
112
name: 🚨 CodeQL Analysis
213

314
on:
4-
pull_request:
5-
paths:
6-
- "**.*"
15+
workflow_call:
716
push:
817
branches:
918
- develop
19+
1020
jobs:
1121
analyze:
12-
name: Analyze
13-
runs-on: ubuntu-latest
22+
name: Analyze (${{ matrix.language }})
23+
# Runner size impacts CodeQL analysis time. To learn more, please see:
24+
# - https://gh.io/recommended-hardware-resources-for-running-codeql
25+
# - https://gh.io/supported-runners-and-hardware-resources
26+
# - https://gh.io/using-larger-runners (GitHub.com only)
27+
# Consider using larger runners or machines with greater resources for possible analysis time improvements.
28+
runs-on: ${{ (matrix.language == 'swift' && 'macos-latest') || 'ubuntu-latest' }}
1429
permissions:
30+
# required for all workflows
31+
security-events: write
32+
33+
# required to fetch internal or private CodeQL packs
34+
packages: read
35+
36+
# only required for workflows in private repositories
1537
actions: read
1638
contents: read
17-
security-events: write
1839

1940
strategy:
2041
fail-fast: false
2142
matrix:
22-
language: ["go"]
23-
43+
include:
44+
- language: actions
45+
build-mode: none
46+
- language: go
47+
build-mode: autobuild
48+
# CodeQL supports the following values keywords for 'language': 'actions', 'c-cpp', 'csharp', 'go', 'java-kotlin', 'javascript-typescript', 'python', 'ruby', 'swift'
49+
# Use `c-cpp` to analyze code written in C, C++ or both
50+
# Use 'java-kotlin' to analyze code written in Java, Kotlin or both
51+
# Use 'javascript-typescript' to analyze code written in JavaScript, TypeScript or both
52+
# To learn more about changing the languages that are analyzed or customizing the build mode for your analysis,
53+
# see https://docs.github.com/en/code-security/code-scanning/creating-an-advanced-setup-for-code-scanning/customizing-your-advanced-setup-for-code-scanning.
54+
# If you are analyzing a compiled language, you can modify the 'build-mode' for that language to customize how
55+
# your codebase is analyzed, see https://docs.github.com/en/code-security/code-scanning/creating-an-advanced-setup-for-code-scanning/codeql-code-scanning-for-compiled-languages
2456
steps:
25-
- name: Checkout repository
26-
uses: actions/checkout@v3
57+
- name: Checkout repository
58+
uses: actions/checkout@v4
59+
60+
# Add any setup steps before running the `github/codeql-action/init` action.
61+
# This includes steps like installing compilers or runtimes (`actions/setup-node`
62+
# or others). This is typically only required for manual builds.
63+
# - name: Setup runtime (example)
64+
# uses: actions/setup-example@v1
65+
66+
# Initializes the CodeQL tools for scanning.
67+
- name: Initialize CodeQL
68+
uses: github/codeql-action/init@v3
69+
with:
70+
languages: ${{ matrix.language }}
71+
build-mode: ${{ matrix.build-mode }}
72+
# If you wish to specify custom queries, you can do so here or in a config file.
73+
# By default, queries listed here will override any specified in a config file.
74+
# Prefix the list here with "+" to use these queries and those in the config file.
2775

28-
# Initializes the CodeQL tools for scanning.
29-
- name: Initialize CodeQL
30-
uses: github/codeql-action/init@v2
31-
with:
32-
languages: ${{ matrix.language }}
76+
# For more details on CodeQL's query packs, refer to: https://docs.github.com/en/code-security/code-scanning/automatically-scanning-your-code-for-vulnerabilities-and-errors/configuring-code-scanning#using-queries-in-ql-packs
77+
# queries: security-extended,security-and-quality
3378

34-
- name: Autobuild
35-
uses: github/codeql-action/autobuild@v2
79+
# If the analyze step fails for one of the languages you are analyzing with
80+
# "We were unable to automatically build your code", modify the matrix above
81+
# to set the build mode to "manual" for that language. Then modify this step
82+
# to build your code.
83+
# ℹ️ Command-line programs to run using the OS shell.
84+
# 📚 See https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsrun
85+
- if: matrix.build-mode == 'manual'
86+
shell: bash
87+
run: |
88+
echo 'If you are using a "manual" build mode for one or more of the' \
89+
'languages you are analyzing, replace this with the commands to build' \
90+
'your code, for example:'
91+
echo ' make bootstrap'
92+
echo ' make release'
93+
exit 1
3694
37-
- name: Perform CodeQL Analysis
38-
uses: github/codeql-action/analyze@v2
95+
- name: Perform CodeQL Analysis
96+
uses: github/codeql-action/analyze@v3
97+
with:
98+
category: "/language:${{matrix.language}}"

.github/workflows/mkdocs-develop.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
11
name: 📖 Deploy Dev Docs
2+
23
on:
34
push:
45
paths:
56
- "docs/**"
67
- "mkdocs.yml"
78
branches:
89
- develop
10+
911
jobs:
1012
build-documents:
1113
name: Test Documentation Build
@@ -17,6 +19,7 @@ jobs:
1719
uses: actions/[email protected]
1820
with:
1921
fetch-depth: 0
22+
2023
- name: Configure Git Credentials
2124
run: |
2225
git config user.name github-actions[bot]
@@ -31,11 +34,14 @@ jobs:
3134
path: .cache
3235
restore-keys: |
3336
mkdocs-material-
37+
3438
- name: Install dependencies
3539
run: |
3640
python -m pip install --upgrade pip setuptools wheel
3741
pip install -r docs/build/requirements.txt
42+
3843
- name: Test Build
3944
run: mkdocs build --verbose --strict
45+
4046
- name: Deploy Docs
4147
run: mkdocs gh-deploy --force

.github/workflows/pr-review.yml

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
name: 🔍 PR Review
2+
3+
on:
4+
pull_request:
5+
paths:
6+
- "**.*"
7+
push:
8+
branches:
9+
- develop
10+
11+
permissions:
12+
id-token: write
13+
packages: write
14+
contents: write
15+
security-events: write
16+
actions: read
17+
18+
jobs:
19+
codeql:
20+
name: 🚨 CodeQL Analysis
21+
uses: ./.github/workflows/codeql.yml
22+
secrets: inherit
23+
24+
test-build:
25+
name: 🔨 Test Build
26+
uses: ./.github/workflows/test-build.yml
27+
secrets: inherit
28+
29+
test-docs:
30+
name: 📙 Test docs
31+
uses: ./.github/workflows/test-docs.yml
32+
secrets: inherit
33+
34+
verify:
35+
name: 🙏🏻 Verify
36+
uses: ./.github/workflows/verify.yml
37+
secrets: inherit
38+
39+
check:
40+
name: ✅ Check
41+
if: always()
42+
needs:
43+
- codeql
44+
- test-build
45+
- test-docs
46+
- verify
47+
48+
runs-on: ubuntu-latest
49+
50+
steps:
51+
- name: Require all jobs to succeed
52+
uses: re-actors/alls-green@release/v1
53+
with:
54+
jobs: ${{ toJSON(needs) }}

.github/workflows/publish.yml

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
name: 🎉 Publish
2+
3+
on:
4+
push:
5+
tags:
6+
- "*" # Trigger on all tags
7+
8+
permissions:
9+
id-token: write
10+
packages: write
11+
contents: write
12+
security-events: write
13+
actions: read
14+
15+
jobs:
16+
release:
17+
name: 🎉 Release
18+
uses: ./.github/workflows/release.yml
19+
secrets: inherit
20+
21+
publish:
22+
name: 🎉 Publish
23+
if: always()
24+
needs: release
25+
26+
runs-on: ubuntu-latest
27+
28+
steps:
29+
- name: Require all jobs to succeed
30+
uses: re-actors/alls-green@release/v1
31+
with:
32+
jobs: ${{ toJSON(needs) }}

.github/workflows/release.yml

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,33 @@
11
name: 🎉 Release
22

33
on:
4-
push:
5-
tags:
6-
- "*"
4+
workflow_call:
75

86
jobs:
97
release:
108
name: Release
119
uses: ./.github/workflows/reusable-build.yml
1210
with:
1311
goreleaser_config: goreleaser.yml
14-
goreleaser_options: ""
12+
goreleaser_options: "--clean"
1513
secrets: inherit
1614
permissions:
1715
id-token: write # For cosign
1816
packages: write # For GHCR
1917
contents: write # To upload archives as release assets
18+
19+
publish:
20+
name: Publish PyPi
21+
runs-on: ubuntu-latest
22+
steps:
23+
- name: Checkout code
24+
uses: actions/checkout@v3
25+
26+
- name: Setup Node
27+
uses: actions/setup-node@v4
28+
29+
30+
permissions:
31+
id-token: write # For cosign
32+
packages: write # For GHCR
33+
contents: write # To upload archives as release assets

.github/workflows/reusable-build.yml

Lines changed: 11 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Reusable Build
1+
name: ♻️ Reusable Build
22
on:
33
workflow_call:
44
inputs:
@@ -13,7 +13,7 @@ on:
1313
type: string
1414

1515
env:
16-
GO_VERSION: "1.22"
16+
GO_VERSION: "1.24"
1717

1818
jobs:
1919
prepare-linux:
@@ -36,12 +36,6 @@ jobs:
3636
username: ${{ github.actor }}
3737
password: ${{ secrets.GITHUB_TOKEN }}
3838

39-
- name: Login to docker.io registry
40-
uses: docker/login-action@v3
41-
with:
42-
username: ${{ secrets.DOCKERHUB_USERNAME }}
43-
password: ${{ secrets.DOCKERHUB_TOKEN }}
44-
4539
- name: Checkout code
4640
uses: actions/[email protected]
4741
with:
@@ -104,12 +98,6 @@ jobs:
10498
password: ${{ secrets.GITHUB_TOKEN }}
10599
if: matrix.os != 'macos-latest'
106100

107-
- name: Login to docker.io registry
108-
uses: docker/login-action@v3
109-
with:
110-
username: ${{ secrets.DOCKERHUB_USERNAME }}
111-
password: ${{ secrets.DOCKERHUB_TOKEN }}
112-
113101
- name: Checkout code
114102
uses: actions/[email protected]
115103
with:
@@ -173,19 +161,19 @@ jobs:
173161
- name: Install Syft
174162
uses: anchore/sbom-action/[email protected]
175163

176-
- name: Login to docker.io registry
177-
uses: docker/login-action@v3
178-
with:
179-
username: ${{ secrets.DOCKERHUB_USERNAME }}
180-
password: ${{ secrets.DOCKERHUB_TOKEN }}
181-
182164
- name: Login to ghcr.io registry
183165
uses: docker/login-action@v3
184166
with:
185167
registry: ghcr.io
186168
username: ${{ github.actor }}
187169
password: ${{ secrets.GITHUB_TOKEN }}
188170

171+
- name: Login to docker.io registry
172+
uses: docker/login-action@v3
173+
with:
174+
username: ${{ secrets.DOCKERHUB_USERNAME }}
175+
password: ${{ secrets.DOCKERHUB_TOKEN }}
176+
189177
- name: Checkout code
190178
uses: actions/[email protected]
191179
with:
@@ -215,7 +203,7 @@ jobs:
215203
mv artifacts/linux-dist/linux_arm64/build-linux_linux_arm64/* output/build-linux_arm64/
216204
mv artifacts/linux-dist/linux_amd64/build-linux_linux_amd64_v1/* output/build-linux_amd64/
217205
mv artifacts/windows-latest-dist/windows_amd64/build-windows_windows_amd64_v1/* output/build-windows_amd64/
218-
mv artifacts/macos-latest-dist/darwin_arm64/build-macos_darwin_arm64/* output/build-darwin_arm64/
206+
mv artifacts/macos-latest-dist/darwin_arm64/build-macos_darwin_arm64_v8.0/* output/build-darwin_arm64/
219207
shell: bash
220208

221209
- name: View Output
@@ -227,7 +215,8 @@ jobs:
227215
with:
228216
distribution: goreleaser-pro
229217
version: latest
230-
args: release -f=.goreleaser/goreleaser-publish.yml ${{ inputs.goreleaser_options}}
218+
args: release -f=.goreleaser/goreleaser-publish.yml ${{ inputs.goreleaser_options }}
231219
env:
232220
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
233221
GORELEASER_KEY: ${{ secrets.GORELEASER_KEY }}
222+
COSIGN_EXPERIMENTAL: "true"

.github/workflows/test-build.yml

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,19 @@
1-
name: 🔨 Build Test
1+
name: 🔨 Test Build
2+
23
on:
3-
pull_request:
4-
paths:
5-
- "**.*"
6-
- "main.go"
7-
- "go.mod"
8-
- "Dockerfile"
9-
push:
10-
branches:
11-
- develop
4+
workflow_call:
5+
126
concurrency:
137
group: ${{ github.ref }}
148
cancel-in-progress: true
9+
1510
jobs:
1611
build:
17-
name: Test Build
12+
name: 🔨 Reusable Go Build
1813
uses: ./.github/workflows/reusable-build.yml
1914
with:
2015
goreleaser_config: goreleaser.yml
21-
goreleaser_options: "--snapshot"
16+
goreleaser_options: "--clean --snapshot"
2217
secrets: inherit
2318
permissions:
2419
id-token: write # For cosign

0 commit comments

Comments
 (0)