Skip to content

Commit fb0dd59

Browse files
committed
Add basic CD workflow (#8055)
1 parent 6c4c766 commit fb0dd59

7 files changed

+373
-0
lines changed

.github/.editorconfig

+83
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
### Header #########################################################################################
2+
3+
# Author: Florian Bernd
4+
5+
### Common Settings ################################################################################
6+
7+
# Documentation:
8+
# http://docs.editorconfig.org/en/master/editorconfig-format.html
9+
10+
# This file is the top-most EditorConfig file
11+
root = false
12+
13+
### All Files --------------------------------------------------------------------------------------
14+
15+
[*]
16+
charset = utf-8
17+
indent_style = space
18+
indent_size = 4
19+
insert_final_newline = true
20+
trim_trailing_whitespace = true
21+
22+
### File Extension Settings ------------------------------------------------------------------------
23+
24+
# XML Configuration Files
25+
[*.{xml,config}]
26+
indent_size = 2
27+
28+
# JSON Files
29+
[*.{json,json5,webmanifest}]
30+
indent_size = 2
31+
32+
# YAML Files
33+
[*.{yml,yaml}]
34+
indent_size = 2
35+
36+
# Markdown Files
37+
[*.{md,mdx}]
38+
indent_size = 2
39+
trim_trailing_whitespace = false
40+
41+
# Web Files
42+
[*.{htm,html,js,jsm,jsx,ts,tsx,cjs,cts,ctsx,mjs,mts,mtsx,css,sass,scss,less,pcss,svg,vue}]
43+
indent_size = 2
44+
45+
# Batch Scripts
46+
[*.{bat,cmd,ps1}]
47+
end_of_line = crlf
48+
49+
# Bash Scripts
50+
[*.{bash,fish,sh,zsh}]
51+
end_of_line = lf
52+
53+
# Makefiles
54+
[Makefile]
55+
indent_style = tab
56+
57+
### ------------------------------------------------------------------------------------------------
58+
59+
### License ########################################################################################
60+
61+
# The MIT License (MIT)
62+
#
63+
# Copyright (c) 2024 Florian Bernd
64+
#
65+
# Permission is hereby granted, free of charge, to any person obtaining a copy
66+
# of this software and associated documentation files (the "Software"), to deal
67+
# in the Software without restriction, including without limitation the rights
68+
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
69+
# copies of the Software, and to permit persons to whom the Software is
70+
# furnished to do so, subject to the following conditions:
71+
#
72+
# The above copyright notice and this permission notice shall be included in all
73+
# copies or substantial portions of the Software.
74+
#
75+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
76+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
77+
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
78+
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
79+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
80+
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
81+
# SOFTWARE.
82+
83+
####################################################################################################

.github/.gitattributes

+106
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,106 @@
1+
### Header #########################################################################################
2+
3+
# Author: Florian Bernd
4+
5+
### Git Line Endings ###############################################################################
6+
7+
# Set default behavior to automatically normalize line endings
8+
* text=auto
9+
10+
# Documents
11+
*.md text diff=markdown
12+
*.mdx text diff=markdown
13+
14+
# Serialization
15+
*.json text
16+
*.toml text
17+
*.xml text
18+
*.yml text linguist-language=YAML linguist-detectable -linguist-vendored
19+
*.yaml text linguist-language=YAML linguist-detectable -linguist-vendored
20+
21+
# Graphics
22+
*.eps binary
23+
*.gif binary
24+
*.ico binary
25+
*.jpg binary
26+
*.jpeg binary
27+
*.png binary
28+
*.tif binary
29+
*.tiff binary
30+
31+
# Force batch scripts to always use CRLF line endings
32+
*.bat text eol=crlf
33+
*.cmd text eol=crlf
34+
*.ps1 text eol=crlf
35+
36+
# Force bash scripts to always use LF line endings
37+
*.bash text eol=lf
38+
*.fish text eol=lf
39+
*.sh text eol=lf
40+
*.zsh text eol=lf
41+
42+
# Text files where line endings should be preserved
43+
*.patch -text
44+
45+
### TypeScript / JavaScript ########################################################################
46+
47+
*.js text
48+
*.jsx text
49+
*.ts text
50+
*.tsx text
51+
52+
### Python #########################################################################################
53+
54+
# Source
55+
*.pxd text diff=python
56+
*.py text diff=python
57+
*.py3 text diff=python
58+
*.pyw text diff=python
59+
*.pyx text diff=python
60+
*.pyz text diff=python
61+
*.pyi text diff=python
62+
63+
# Binary
64+
*.db binary
65+
*.p binary
66+
*.pkl binary
67+
*.pickle binary
68+
*.pyc binary export-ignore
69+
*.pyo binary export-ignore
70+
*.pyd binary
71+
72+
### Linguist exclusions ############################################################################
73+
74+
test/* linguist-vendored
75+
76+
### Exclude files from exporting ###################################################################
77+
78+
.gitattributes export-ignore
79+
.gitignore export-ignore
80+
.gitkeep export-ignore
81+
82+
### License ########################################################################################
83+
84+
# The MIT License (MIT)
85+
#
86+
# Copyright (c) 2024 Florian Bernd
87+
#
88+
# Permission is hereby granted, free of charge, to any person obtaining a copy
89+
# of this software and associated documentation files (the "Software"), to deal
90+
# in the Software without restriction, including without limitation the rights
91+
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
92+
# copies of the Software, and to permit persons to whom the Software is
93+
# furnished to do so, subject to the following conditions:
94+
#
95+
# The above copyright notice and this permission notice shall be included in all
96+
# copies or substantial portions of the Software.
97+
#
98+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
99+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
100+
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
101+
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
102+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
103+
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
104+
# SOFTWARE.
105+
106+
####################################################################################################

.github/workflows/release.yml

+130
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,130 @@
1+
name: 'CD'
2+
3+
on:
4+
workflow_call:
5+
inputs:
6+
flavor:
7+
description: 'The release flavor (either ''stack'' or ''serverless'')'
8+
type: 'string'
9+
required: true
10+
solution:
11+
description: 'The filename of the .NET solution file'
12+
type: 'string'
13+
required: true
14+
release_tag:
15+
description: 'The release tag (release version)'
16+
type: 'string'
17+
required: true
18+
release_body:
19+
description: 'The release body (release notes)'
20+
type: 'string'
21+
required: true
22+
secrets:
23+
NUGET_API_KEY:
24+
required: true
25+
26+
concurrency:
27+
group: 'release-${{ inputs.flavor }}'
28+
cancel-in-progress: false
29+
30+
env:
31+
# Configuration
32+
BUILD_CONFIG: 'Release'
33+
GLOBAL_JSON_FILE: 'global.json'
34+
LOCKFILE_PATTERN: '**/packages.lock.json'
35+
PACKAGE_PATH: 'nupkg'
36+
# .NET SDK related environment variables
37+
DOTNET_NOLOGO: 1
38+
DOTNET_SKIP_FIRST_TIME_EXPERIENCE: 1
39+
DOTNET_CLI_TELEMETRY_OPTOUT: 1
40+
DOTNET_GENERATE_ASPNET_CERTIFICATE: 0
41+
42+
jobs:
43+
build:
44+
name: 'Build'
45+
runs-on: 'ubuntu-latest'
46+
steps:
47+
- name: 'Parse Version'
48+
id: 'version'
49+
uses: 'zyactions/semver@v1'
50+
with:
51+
version: ${{ inputs.release_tag }}
52+
prefixes: 'serverless-'
53+
54+
- name: 'Checkout'
55+
uses: 'actions/checkout@v4'
56+
57+
- name: '.NET Setup'
58+
uses: 'actions/setup-dotnet@v4'
59+
with:
60+
global-json-file: '${{ github.workspace }}/${{ env.GLOBAL_JSON_FILE }}'
61+
62+
- name: '.NET Cache Packages'
63+
uses: 'actions/cache@v4'
64+
with:
65+
path: '~/.nuget/packages'
66+
key: '${{ runner.os }}-nuget-${{ inputs.flavor }}-${{ hashFiles(env.LOCKFILE_PATTERN) }}'
67+
restore-keys: '${{ runner.os }}-nuget-${{ inputs.flavor }}-'
68+
69+
- name: '.NET Restore'
70+
run: >-
71+
dotnet restore "${{ github.workspace }}/${{ inputs.solution }}"
72+
73+
- name: '.NET Pack'
74+
env:
75+
# The complete semver version string
76+
CURRENT_VERSION: ${{ steps.version.outputs.version }}
77+
# Assembly version is sticky to MAJOR.0.0.0 to avoid binding redirects because we strong name our assemblies
78+
CURRENT_ASSEMBLY_VERSION: '${{ steps.version.outputs.major }}.0.0.0'
79+
# File version reflects actual version number without prelease and build since these are not allowed in its struct
80+
CURRENT_ASSEMBLY_FILE_VERSION: '${{ steps.version.outputs.major }}.${{ steps.version.outputs.minor }}.${{ steps.version.outputs.patch }}'
81+
run: >-
82+
dotnet pack
83+
"${{ github.workspace }}/${{ inputs.solution }}"
84+
--no-restore
85+
--configuration "${{ env.BUILD_CONFIG }}"
86+
-p:ContinuousIntegrationBuild=true
87+
-p:CurrentVersion=${{ env.CURRENT_VERSION }}
88+
-p:CurrentAssemblyVersion=${{ env.CURRENT_ASSEMBLY_VERSION }}
89+
-p:CurrentAssemblyFileVersion=${{ env.CURRENT_ASSEMBLY_FILE_VERSION }}
90+
-o "${{ github.workspace }}/${{ env.PACKAGE_PATH }}"
91+
92+
- name: 'Upload Artifacts'
93+
uses: 'actions/upload-artifact@v4'
94+
with:
95+
name: 'packages'
96+
path: '${{ github.workspace }}/${{ env.PACKAGE_PATH }}'
97+
if-no-files-found: 'error'
98+
retention-days: 1
99+
100+
publish:
101+
name: Publish to ${{ matrix.feed.name }}
102+
needs: build
103+
runs-on: ubuntu-latest
104+
strategy:
105+
fail-fast: false
106+
matrix:
107+
feed:
108+
- { name: 'NuGet' , source: 'https://api.nuget.org/v3/index.json' , key: 'NUGET_API_KEY' }
109+
# - { name: 'GitHub', source: 'https://nuget.pkg.github.com/${{ github.repository_owner }}/index.json', key: 'GITHUB_TOKEN' }
110+
steps:
111+
- name: 'Checkout'
112+
uses: 'actions/checkout@v4'
113+
114+
- name: '.NET Setup'
115+
uses: 'actions/setup-dotnet@v4'
116+
with:
117+
global-json-file: '${{ github.workspace }}/${{ env.GLOBAL_JSON_FILE }}'
118+
119+
- name: 'Download Artifacts'
120+
uses: actions/download-artifact@v4
121+
with:
122+
name: 'packages'
123+
path: '${{ github.workspace }}/${{ env.PACKAGE_PATH }}'
124+
125+
- name: '.NET NuGet Push'
126+
run: >-
127+
dotnet nuget push ${{ format('{0}/{1}/*.nupkg', github.workspace, env.PACKAGE_PATH) }}
128+
--source ${{ matrix.feed.source }}
129+
--api-key ${{ secrets[matrix.feed.key] }}
130+
--skip-duplicate
+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
name: 'CD'
2+
3+
on:
4+
release:
5+
types:
6+
- 'published'
7+
8+
jobs:
9+
release:
10+
name: 'Release'
11+
if: ${{ startsWith(github.event.release.tag_name, 'serverless-') }}
12+
uses: ./.github/workflows/release.yml
13+
with:
14+
flavor: 'serverless'
15+
solution: 'Packages.Serverless.slnf'
16+
release_tag: ${{ github.event.release.tag_name }}
17+
release_body: ${{ github.event.release.body }}
18+
secrets: 'inherit'

.github/workflows/release_stack.yml

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
name: 'CD'
2+
3+
on:
4+
release:
5+
types:
6+
- 'published'
7+
8+
jobs:
9+
release:
10+
name: 'Release'
11+
if: ${{ !startsWith(github.event.release.tag_name, 'serverless-') }}
12+
uses: ./.github/workflows/release.yml
13+
with:
14+
flavor: 'stack'
15+
solution: 'Packages.Stack.slnf'
16+
release_tag: ${{ github.event.release.tag_name }}
17+
release_body: ${{ github.event.release.body }}
18+
secrets: 'inherit'

Packages.Serverless.slnf

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"solution": {
3+
"path": "Elasticsearch.sln",
4+
"projects": [
5+
"src\\Elastic.Clients.Elasticsearch.Serverless\\Elastic.Clients.Elasticsearch.Serverless.csproj",
6+
"src\\Elastic.Clients.Elasticsearch.Shared\\Elastic.Clients.Elasticsearch.Shared.shproj"
7+
]
8+
}
9+
}

Packages.Stack.slnf

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"solution": {
3+
"path": "Elasticsearch.sln",
4+
"projects": [
5+
"src\\Elastic.Clients.Elasticsearch.Shared\\Elastic.Clients.Elasticsearch.Shared.shproj",
6+
"src\\Elastic.Clients.Elasticsearch\\Elastic.Clients.Elasticsearch.csproj"
7+
]
8+
}
9+
}

0 commit comments

Comments
 (0)