Skip to content

Commit 8fdcc18

Browse files
committed
Initial attempt for GitHub Actions
1 parent b93c184 commit 8fdcc18

11 files changed

+504
-4
lines changed

.github/continuous-delivery.yml

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
name: CD
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
- support/*
8+
paths-ignore:
9+
- 'docs/**'
10+
- 'README.md'
11+
- '.editorconfig'
12+
- '.gitattributes'
13+
- '.gitignore'
14+
- '.github/ISSUE_TEMPLATE/**'
15+
- '.github/pull_request_template.md'
16+
17+
defaults: *default-defaults
18+
19+
jobs:
20+
build:
21+
name: 'Continuous delivery'
22+
runs-on: ubuntu-24.04
23+
steps:
24+
- *checkout
25+
- *setup-dotnet
26+
- *setup-nuget
27+
- *restore
28+
- *build
29+
- *test
30+
- *pack
31+
- *build-css-package
32+
- *upload-artifacts
33+
- *publish-github

.github/continuous-integration.yml

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
name: CI
2+
3+
on:
4+
pull_request:
5+
branches:
6+
- main
7+
- support/*
8+
paths-ignore:
9+
- 'docs/**'
10+
- 'README.md'
11+
- '.editorconfig'
12+
- '.gitattributes'
13+
- '.gitignore'
14+
- '.github/ISSUE_TEMPLATE/**'
15+
- '.github/pull_request_template.md'
16+
17+
defaults: *default-defaults
18+
19+
jobs:
20+
build:
21+
name: 'Continuous integration'
22+
runs-on: ubuntu-24.04
23+
steps:
24+
- *checkout
25+
- *setup-dotnet
26+
- *setup-nuget
27+
- *restore
28+
- *build
29+
- *test
30+
- *pack
31+
- *build-css-package
32+
- *upload-artifacts

.github/dependabot.yml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
version: 2
2+
updates:
3+
- package-ecosystem: nuget
4+
directory: "/"
5+
schedule:
6+
interval: weekly
7+
time: "11:00"
8+
open-pull-requests-limit: 10
9+
groups:
10+
all:
11+
patterns:
12+
- "*"
13+
update-types:
14+
- "minor"
15+
- "patch"
16+
ignore:
17+
- dependency-name: "*"
18+
update-types: ["version-update:semver-major"]

.github/deploy-release.yml

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
name: Release
2+
3+
on:
4+
release:
5+
types:
6+
- published
7+
8+
defaults: *default-defaults
9+
10+
jobs:
11+
build:
12+
name: 'Deploy release'
13+
runs-on: ubuntu-24.04
14+
steps:
15+
- *checkout
16+
- *setup-dotnet
17+
- *setup-nuget
18+
- *restore
19+
- *build
20+
- *test
21+
- *pack
22+
- *build-css-package
23+
- *upload-artifacts
24+
- name: 'Upload release'
25+
run: |
26+
set -x
27+
tag="${GITHUB_REF#refs/*/}"
28+
files=()
29+
30+
IFS=$'\n';
31+
for asset in $(find ./artifacts -name "CSSUniversalMenuAPI-*.zip"); do
32+
files+=("$asset")
33+
done
34+
35+
IFS=$'\n';
36+
for asset in $(find ./artifacts -name "*.nupkg"); do
37+
files+=("$asset")
38+
done
39+
40+
gh release upload "$tag" "${files[@]}"
41+
env:
42+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
43+
- *publish-github
44+
45+
- name: 'Publish NuGet.org'
46+
run: |
47+
dotnet nuget push 'artifacts/*.nupkg' -k ${NUGETORG_TOKEN} -s https://api.nuget.org/v3/index.json --skip-duplicate --no-symbols
48+
env:
49+
NUGETORG_TOKEN: ${{ secrets.NUGETORG_TOKEN }}

.github/regenerate-actions.sh

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
#!/bin/bash
2+
set -eou pipefail
3+
4+
yaml --version > /dev/null || {
5+
echo "yaml not installed, install with:"
6+
echo " pip install ruamel.yaml.cmd"
7+
exit 1
8+
}
9+
10+
generate () {
11+
echo "generating $1"
12+
echo "# WARNING: This file is automatically generated by ../regenerate-actions.sh" > "workflows/$1"
13+
cat shared.yml "$1" \
14+
| yaml merge-expand - - \
15+
| perl -0777 -pe 's|(#<shared>.+?#<\/shared>)||gs' \
16+
| perl -0777 -pe 's|#<\/shared>\s*||gs' \
17+
>> "workflows/$1"
18+
}
19+
20+
generate continuous-integration.yml
21+
generate continuous-delivery.yml
22+
generate deploy-release.yml
23+
echo "done"

.github/shared.yml

Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
#<shared>
2+
3+
definitions:
4+
default-defaults: &default-defaults
5+
run:
6+
shell: bash
7+
8+
checkout: &checkout
9+
uses: actions/checkout@v4
10+
with:
11+
fetch-depth: '0'
12+
13+
setup-dotnet: &setup-dotnet
14+
name: Setup .NET
15+
uses: actions/setup-dotnet@v3
16+
with:
17+
dotnet-version: |
18+
8.x
19+
9.x
20+
21+
setup-nuget: &setup-nuget
22+
name: Setup NuGet
23+
run: |
24+
dotnet nuget update source csgals --store-password-in-clear-text --username CSGALS --password ${{ secrets.GITHUB_TOKEN }}
25+
dotnet nuget enable source csgals
26+
27+
restore: &restore
28+
name: Restore
29+
run: dotnet restore
30+
31+
build: &build
32+
name: Build
33+
run: dotnet build --configuration Release --no-restore
34+
35+
test: &test
36+
name: Test
37+
run: dotnet test --configuration Debug --logger GitHubActions -p:CollectCoverage=true -p:CoverletOutputFormat=cobertura
38+
39+
pack: &pack
40+
name: Pack
41+
run: dotnet pack -p:PackageOutputPath="$(pwd)/artifacts" --configuration Release --no-restore
42+
43+
upload-artifacts: &upload-artifacts
44+
name: Upload Artifacts
45+
uses: actions/upload-artifact@v4
46+
if: success() || failure()
47+
with:
48+
name: artifacts
49+
if-no-files-found: error
50+
path: |
51+
artifacts/*
52+
53+
download-artifacts: &download-artifacts
54+
name: Download Artifacts
55+
uses: actions/download-artifact@v4
56+
with:
57+
path: artifacts
58+
pattern: '*'
59+
merge-multiple: true
60+
61+
publish-github: &publish-github
62+
name: Publish NuGet GitHub
63+
run: dotnet nuget push 'artifacts/*.nupkg' -k ${{ secrets.GITHUB_TOKEN }} -s csgals --skip-duplicate --no-symbols
64+
65+
build-css-package: &build-css-package
66+
name: 'Build CSS Package'
67+
run: |
68+
src="./src/CSSUniversalMenuAPI/bin/Release/net8.0"
69+
dst="./artifacts/CSSUniversalMenuAPI"
70+
dst_shared="$dst/addons/counterstrikesharp/shared/CSSUniversalMenuAPI"
71+
mkdir -p "$dst_shared"
72+
cp "$src/CSSUniversalMenuAPI.dll" "$dst_shared/"
73+
cp "$src/CSSUniversalMenuAPI.deps.json" "$dst_shared/"
74+
pushd "$dst"
75+
7z a ../CSSUniversalMenuAPI.zip ./
76+
popd
77+
78+
empty: "hi" # fixes the yml parser from messing the last value up
79+
80+
#</shared>
Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
# WARNING: This file is automatically generated by ../regenerate-actions.sh
2+
3+
name: CD
4+
5+
on:
6+
push:
7+
branches:
8+
- main
9+
- support/*
10+
paths-ignore:
11+
- docs/**
12+
- README.md
13+
- .editorconfig
14+
- .gitattributes
15+
- .gitignore
16+
- .github/ISSUE_TEMPLATE/**
17+
- .github/pull_request_template.md
18+
19+
defaults:
20+
run:
21+
shell: bash
22+
23+
24+
jobs:
25+
build:
26+
name: Continuous delivery
27+
runs-on: ubuntu-24.04
28+
steps:
29+
- uses: actions/checkout@v4
30+
with:
31+
fetch-depth: '0'
32+
33+
- name: Setup .NET
34+
uses: actions/setup-dotnet@v3
35+
with:
36+
dotnet-version: |
37+
8.x
38+
9.x
39+
40+
- name: Setup NuGet
41+
run: |
42+
dotnet nuget update source csgals --store-password-in-clear-text --username CSGALS --password ${{ secrets.GITHUB_TOKEN }}
43+
dotnet nuget enable source csgals
44+
45+
- name: Restore
46+
run: dotnet restore
47+
48+
- name: Build
49+
run: dotnet build --configuration Release --no-restore
50+
51+
- name: Test
52+
run: dotnet test --configuration Debug --logger GitHubActions -p:CollectCoverage=true
53+
-p:CoverletOutputFormat=cobertura
54+
55+
- name: Pack
56+
run: dotnet pack -p:PackageOutputPath="$(pwd)/artifacts" --configuration Release
57+
--no-restore
58+
59+
- name: Build CSS Package
60+
run: |
61+
src="./src/CSSUniversalMenuAPI/bin/Release/net8.0"
62+
dst="./artifacts/CSSUniversalMenuAPI"
63+
dst_shared="$dst/addons/counterstrikesharp/shared/CSSUniversalMenuAPI"
64+
mkdir -p "$dst_shared"
65+
cp "$src/CSSUniversalMenuAPI.dll" "$dst_shared/"
66+
cp "$src/CSSUniversalMenuAPI.deps.json" "$dst_shared/"
67+
pushd "$dst"
68+
7z a ../CSSUniversalMenuAPI.zip ./
69+
popd
70+
71+
- name: Upload Artifacts
72+
uses: actions/upload-artifact@v4
73+
if: success() || failure()
74+
with:
75+
name: artifacts
76+
if-no-files-found: error
77+
path: |
78+
artifacts/*
79+
80+
- name: Publish NuGet GitHub
81+
run: dotnet nuget push 'artifacts/*.nupkg' -k ${{ secrets.GITHUB_TOKEN }} -s
82+
csgals --skip-duplicate --no-symbols
83+

0 commit comments

Comments
 (0)