Skip to content

Commit e11a182

Browse files
committed
cicd added
1 parent dd295f0 commit e11a182

20 files changed

+614
-4
lines changed

.github/workflows/release.yml

+119
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,119 @@
1+
name: Release
2+
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
versionNumber:
7+
description: 'Release version number (v#.#.#)'
8+
type: string
9+
required: true
10+
11+
permissions:
12+
contents: read # Changelog commit operations use service account PAT
13+
14+
jobs:
15+
changelog-version:
16+
runs-on: ubuntu-latest
17+
outputs:
18+
version: ${{ steps.changelog-version.outputs.version }}
19+
steps:
20+
- id: changelog-version
21+
run: echo "version=$(echo "${{ inputs.versionNumber }}" | cut -c 2-)" >> "$GITHUB_OUTPUT"
22+
23+
changelog:
24+
needs: changelog-version
25+
runs-on: ubuntu-latest
26+
steps:
27+
- name: Checkout
28+
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
29+
with:
30+
fetch-depth: 0
31+
# Avoid persisting GITHUB_TOKEN credentials as they take priority over our service account PAT for `git push` operations
32+
# More details: https://github.com/actions/checkout/blob/b4626ce19ce1106186ddf9bb20e706842f11a7c3/adrs/0153-checkout-v2.md#persist-credentials
33+
persist-credentials: false
34+
35+
- name: Batch changes
36+
uses: miniscruff/changie-action@6dcc2533cac0495148ed4046c438487e4dceaa23 # v2.0.0
37+
with:
38+
version: latest
39+
args: batch ${{ needs.changelog-version.outputs.version }}
40+
41+
- name: Merge changes
42+
uses: miniscruff/changie-action@6dcc2533cac0495148ed4046c438487e4dceaa23 # v2.0.0
43+
with:
44+
version: latest
45+
args: merge
46+
47+
- name: Git push changelog
48+
run: |
49+
git config --global user.name "${{ vars.TF_THESUDO_CI_COMMIT_AUTHOR }}"
50+
git config --global user.email "${{ vars.TF_THESUDO_CI_COMMIT_EMAIL }}"
51+
git add .
52+
git commit -a -m "Update changelog"
53+
git push "https://${{ vars.TF_THESUDO_CI_COMMIT_AUTHOR }}:${{ secrets.TF_THESUDO_COMMIT_GITHUB_TOKEN }}@github.com/${{ github.repository }}.git"
54+
55+
release-tag:
56+
needs: changelog
57+
runs-on: ubuntu-latest
58+
steps:
59+
- name: Checkout
60+
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
61+
with:
62+
fetch-depth: 0
63+
# Default input is the SHA that initially triggered the workflow. As we created a new commit in the previous job,
64+
# to ensure we get the latest commit we use the ref for checkout: 'refs/heads/<branch_name>'
65+
ref: ${{ github.ref }}
66+
# Avoid persisting GITHUB_TOKEN credentials as they take priority over our service account PAT for `git push` operations
67+
# More details: https://github.com/actions/checkout/blob/b4626ce19ce1106186ddf9bb20e706842f11a7c3/adrs/0153-checkout-v2.md#persist-credentials
68+
persist-credentials: false
69+
70+
- name: Git push release tag
71+
run: |
72+
git config --global user.name "${{ vars.TF_THESUDO_CI_COMMIT_AUTHOR }}"
73+
git config --global user.email "${{ vars.TF_THESUDO_CI_COMMIT_EMAIL }}"
74+
75+
git tag "${{ inputs.versionNumber }}"
76+
git push "https://${{ vars.TF_THESUDO_CI_COMMIT_AUTHOR }}:${{ secrets.TF_THESUDO_COMMIT_GITHUB_TOKEN }}@github.com/${{ github.repository }}.git" "${{ inputs.versionNumber }}"
77+
78+
release-notes:
79+
needs: [ changelog-version, changelog, release-tag ]
80+
runs-on: ubuntu-latest
81+
steps:
82+
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
83+
with:
84+
ref: ${{ inputs.versionNumber }}
85+
fetch-depth: 0
86+
87+
- name: Generate Release Notes
88+
run: |
89+
cd .changes
90+
sed -e "1{/# /d;}" -e "2{/^$/d;}" ${{ needs.changelog-version.outputs.version }}.md > release-notes.txt
91+
92+
- uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4.3.1
93+
with:
94+
name: release-notes
95+
path: ./.changes/release-notes.txt
96+
retention-days: 1
97+
98+
# terraform-provider-release:
99+
# name: 'Terraform Provider Release'
100+
# needs: [ release-notes ]
101+
# permissions:
102+
# contents: write # Needed for goreleaser to create GitHub release
103+
# issues: write # Needed for goreleaser to close associated milestone
104+
# uses: hashicorp/ghaction-terraform-provider-release/.github/workflows/hashicorp.yml@9b5d2ca4b85f3a54d5c4d12e7690ddad1526ff6c # v3.0.1
105+
# secrets:
106+
# hc-releases-key-prod: '${{ secrets.HC_RELEASES_KEY_PROD }}'
107+
# hc-releases-key-staging: '${{ secrets.HC_RELEASES_KEY_STAGING }}'
108+
# hc-releases-github-token: '${{ secrets.HASHI_RELEASES_GITHUB_TOKEN }}'
109+
# hc-releases-terraform-registry-sync-token: '${{ secrets.TF_PROVIDER_RELEASE_TERRAFORM_REGISTRY_SYNC_TOKEN }}'
110+
# setup-signore-github-token: '${{ secrets.HASHI_SIGNORE_GITHUB_TOKEN }}'
111+
# signore-client-id: '${{ secrets.SIGNORE_CLIENT_ID }}'
112+
# signore-client-secret: '${{ secrets.SIGNORE_CLIENT_SECRET }}'
113+
# hc-releases-host-staging: '${{ secrets.HC_RELEASES_HOST_STAGING }}'
114+
# hc-releases-host-prod: '${{ secrets.HC_RELEASES_HOST_PROD }}'
115+
# with:
116+
# release-notes: true
117+
# setup-go-version-file: 'go.mod'
118+
# # Product Version (e.g. v1.2.3)
119+
# product-version: '${{ inputs.versionNumber }}'

.github/workflows/test.yml

+80
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
name: Test
2+
3+
on:
4+
pull_request:
5+
branches: [ main ]
6+
paths-ignore:
7+
- 'README.md'
8+
- 'CHANGELOG.md'
9+
- 'website/*'
10+
push:
11+
branches: [ main ]
12+
paths-ignore:
13+
- 'README.md'
14+
- 'CHANGELOG.md'
15+
- 'website/*'
16+
17+
jobs:
18+
build:
19+
name: Build
20+
runs-on: ubuntu-latest
21+
timeout-minutes: 5
22+
steps:
23+
24+
- name: Check out code into the Go module directory
25+
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
26+
27+
- name: Set up Go
28+
uses: actions/setup-go@0c52d547c9bc32b1aa3301fd7a9cb496313a4491 # v5.0.0
29+
with:
30+
go-version-file: 'go.mod'
31+
id: go
32+
33+
- name: Run linters
34+
uses: golangci/golangci-lint-action@3cfe3a4abbb849e10058ce4af15d205b6da42804 # v4.0.0
35+
with:
36+
version: latest
37+
38+
- name: Generate
39+
run: make generate
40+
41+
- name: Confirm no diff
42+
run: |
43+
git diff --compact-summary --exit-code || \
44+
(echo "*** Unexpected differences after code generation. Run 'make generate' and commit."; exit 1)
45+
46+
- name: Build
47+
run: make build
48+
49+
test:
50+
name: 'Acc. Tests (OS: ${{ matrix.os }} / TF: ${{ matrix.terraform }})'
51+
needs: build
52+
runs-on: ${{ matrix.os }}
53+
timeout-minutes: 20
54+
strategy:
55+
fail-fast: false
56+
matrix:
57+
os:
58+
- macos-latest
59+
- windows-latest
60+
- ubuntu-latest
61+
terraform: ${{ fromJSON(vars.TF_VERSIONS_PROTOCOL_V5) }}
62+
steps:
63+
64+
- name: Check out code
65+
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
66+
67+
- name: Setup Go
68+
uses: actions/setup-go@0c52d547c9bc32b1aa3301fd7a9cb496313a4491 # v5.0.0
69+
with:
70+
go-version-file: 'go.mod'
71+
check-latest: true
72+
73+
- name: Setup Terraform ${{ matrix.terraform }}
74+
uses: hashicorp/setup-terraform@97f030cf6dc0b4f5e0da352c7bca9cca34579800 # v3.1.0
75+
with:
76+
terraform_version: ${{ matrix.terraform }}
77+
terraform_wrapper: false
78+
79+
- name: Run acceptance test
80+
run: make testacc

.github/workflows/update_docs.yml

+38
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
name: Update Documentation
2+
3+
on:
4+
pull_request:
5+
branches:
6+
- main
7+
8+
jobs:
9+
update_docs:
10+
runs-on: ubuntu-latest
11+
steps:
12+
- name: Checkout Repository
13+
uses: actions/checkout@v2
14+
15+
- name: Set up Go
16+
uses: actions/setup-go@v2
17+
with:
18+
go-version: '1.22.2'
19+
20+
- name: Run go generate
21+
run: go generate ./...
22+
23+
- name: Execute build_media_map script
24+
run: chmod +x ./scripts/build_media_map.sh && ./scripts/build_media_map.sh
25+
id: script_output
26+
27+
- name: Append output to docs/index.md
28+
run: |
29+
echo -e "\n# epic Provider\n$(cat docs/index.md)" > docs/index.md
30+
echo "${{ steps.script_output.outputs.result }}" >> docs/index.md
31+
32+
- name: Commit and Push changes
33+
run: |
34+
git config --global user.name "${{ vars.TF_THESUDO_CI_COMMIT_AUTHOR }}"
35+
git config --global user.email "${{ vars.TF_THESUDO_CI_COMMIT_EMAIL }}"
36+
git add .
37+
git commit -a -m "Update changelog"
38+
git push "https://${{ vars.TF_THESUDO_CI_COMMIT_AUTHOR }}:${{ secrets.TF_THESUDO_COMMIT_GITHUB_TOKEN }}@github.com/${{ github.repository }}.git"

.github/workflows/validate_data.yml

+42-3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,43 @@
1-
2-
# Validate validate_data.go validCombinations matches the structure of /data
31
# Validate .json files under /data/* are formatted as expected
4-
# replace spaces with _ and validate file contents are valid json syntax
2+
# replace spaces with _ and validate file contents are valid json syntax
3+
4+
name: Validate JSON Data Files
5+
6+
on:
7+
push:
8+
paths:
9+
- 'data/**'
10+
pull_request:
11+
paths:
12+
- 'data/**'
13+
14+
jobs:
15+
validate_json:
16+
runs-on: ubuntu-latest
17+
steps:
18+
- name: Checkout Repository
19+
uses: actions/checkout@v2
20+
21+
- name: Set up Python 3.x
22+
uses: actions/setup-python@v2
23+
with:
24+
python-version: '3.x'
25+
26+
- name: Install JSON validation tool
27+
run: pip install jsonschema
28+
29+
- name: Validate JSON Files
30+
run: |
31+
find data -type f -name '*.json' | while read file; do
32+
# Check file name format (all lowercase and no spaces)
33+
if [[ ! "$file" =~ ^data/[a-zA-Z0-9_]+/[a-z0-9_]+\.json$ ]]; then
34+
echo "File name format error: $file"
35+
exit 1
36+
fi
37+
# Check JSON syntax
38+
python -m json.tool "$file" > /dev/null
39+
if [ $? -ne 0 ]; then
40+
echo "JSON syntax error in file: $file"
41+
exit 1
42+
fi
43+
done

.golangci.yml

+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# Visit https://golangci-lint.run/ for usage documentation
2+
# and information on other useful linters
3+
issues:
4+
max-per-linter: 0
5+
max-same-issues: 0
6+
7+
linters:
8+
disable-all: true
9+
enable:
10+
- durationcheck
11+
- errcheck
12+
- exportloopref
13+
- forcetypeassert
14+
- godot
15+
- gofmt
16+
- gosimple
17+
- ineffassign
18+
- makezero
19+
- misspell
20+
- nilerr
21+
- predeclared
22+
- staticcheck
23+
- tenv
24+
- unconvert
25+
- unparam
26+
- unused
27+
- vet

.goreleaser.yml

+58
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
# Visit https://goreleaser.com for documentation on how to customize this
2+
# behavior.
3+
before:
4+
hooks:
5+
- go mod tidy
6+
builds:
7+
- env:
8+
- CGO_ENABLED=0
9+
mod_timestamp: '{{ .CommitTimestamp }}'
10+
flags:
11+
- -trimpath
12+
ldflags:
13+
- '-s -w -X main.version={{.Version}} -X main.commit={{.Commit}}'
14+
goos:
15+
- freebsd
16+
- windows
17+
- linux
18+
- darwin
19+
goarch:
20+
- amd64
21+
- '386'
22+
- arm
23+
- arm64
24+
ignore:
25+
- goos: darwin
26+
goarch: '386'
27+
binary: '{{ .ProjectName }}_v{{ .Version }}'
28+
archives:
29+
- files:
30+
- LICENSE
31+
- data/*
32+
- format: zip
33+
name_template: '{{ .ProjectName }}_{{ .Version }}_{{ .Os }}_{{ .Arch }}'
34+
checksum:
35+
extra_files:
36+
- glob: 'terraform-registry-manifest.json'
37+
name_template: '{{ .ProjectName }}_{{ .Version }}_manifest.json'
38+
name_template: '{{ .ProjectName }}_{{ .Version }}_SHA256SUMS'
39+
algorithm: sha256
40+
signs:
41+
- artifacts: checksum
42+
args:
43+
# if you are using this in a GitHub action or some other automated pipeline, you
44+
# need to pass the batch flag to indicate its not interactive.
45+
- "--batch"
46+
- "--local-user"
47+
- "{{ .Env.GPG_FINGERPRINT }}" # set this environment variable for your signing key
48+
- "--output"
49+
- "${signature}"
50+
- "--detach-sign"
51+
- "${artifact}"
52+
release:
53+
extra_files:
54+
- glob: 'terraform-registry-manifest.json'
55+
name_template: '{{ .ProjectName }}_{{ .Version }}_manifest.json'
56+
# draft: true
57+
changelog:
58+
skip: true

CHANGELOG.md

Whitespace-only changes.

0 commit comments

Comments
 (0)